%matplotlib inline
import matplotlib.pyplot as plt
from IPython.html.widgets import interact
import numpy as np

digits.images[0]/10

from sklearn.datasets import load_digits
digits = load_digits()
print(digits.data.shape)

def show_digit(i):
    plt.matshow(digits.images[i]);

interact(show_digit, i=(300,400));

"""
Explanation: Neural Networks
This project was created by Brian Granger. All content is licensed under the MIT License.

Introduction
Neural networks are a class of algorithms that can learn how to compute the value of a function given previous examples of the functions output. Because neural networks are capable of learning how to compute the output of a function based on existing data, they generally fall under the field of Machine Learning.
Let's say that we don't know how to compute some function $f$:
$$ f(x) \rightarrow y $$
But we do have some data about the output that $f$ produces for particular input $x$:
$$ f(x_1) \rightarrow y_1 $$
$$ f(x_2) \rightarrow y_2 $$
$$ \ldots $$
$$ f(x_n) \rightarrow y_n $$
A neural network learns how to use that existing data to compute the value of the function $f$ on yet unseen data. Neural networks get their name from the similarity of their design to how neurons in the brain work.
Work on neural networks began in the 1940s, but significant advancements were made in the 1970s (backpropagation) and more recently, since the late 2000s, with the advent of deep neural networks. These days neural networks are starting to be used extensively in products that you use. A great example of the application of neural networks is the recently released Flickr automated image tagging. With these algorithms, Flickr is able to determine what tags ("kitten", "puppy") should be applied to each photo, without human involvement.
In this case the function takes an image as input and outputs a set of tags for that image:
$$ f(image) \rightarrow {tag_1, \ldots} $$
For the purpose of this project, good introductions to neural networks can be found at:

The Nature of Code, Daniel Shiffman.
Neural Networks and Deep Learning, Michael Nielsen.
Data Science from Scratch, Joel Grus

The Project
Your general goal is to write Python code to predict the number associated with handwritten digits. The dataset for these digits can be found in sklearn:
End of explanation
"""


digits.target

"""
Explanation: The actual, known values (0,1,2,3,4,5,6,7,8,9) associated with each image can be found in the target array:
End of explanation
"""


