<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 This notebook follows the tutorial from 
An introduction to machine learning with scikit-learn.
Let's load some test data from sklearn
Step1:  Let's investigate the data that we just loaded. A dataset contains the original data (digits.images), a 2 dimensional data array and some metadata about the dataset.
Step2:  The original data is however always normalized to a single dimensional array. This leads to the digits.data array being of dimension len(digits.images) (the number of images) x len(digits.images[i]) (the one-dimensional image data)
Step3:  Our goal is now to train a machine learning algorithm with the given digits dataset, so that it can use what it has learned to later predict or classify new digits. In this case, we'll have 9 target classes (numbers 0-9).
For the digits training set, we already provide these target classes so that they can be used to train our classification algorithm. These classes are stored in digits.target and are also refered to as the "ground truth" for the digit dataset.
Step4:  For example, for digits.images[3], we have digits.target[3] ==  3, as the digits.images[3] contains the number 3.
Step5:  The algorithm that we will use to do the classification is a so-called estimator. Well-known matematical estimators inlcude
Step6:  We now train the classifier with all but the last item in the dataset (using python's [
Step7:  Now you can predict new values, in particular, we can ask to the classifier what is the digit of our last image in the digits dataset, which we have not used to train the classifier
<ASSISTANT_TASK:>
Python Code:
from sklearn import datasets
digits = datasets.load_digits()
Explanation: This notebook follows the tutorial from 
An introduction to machine learning with scikit-learn.
Let's load some test data from sklearn
End of explanation
%matplotlib inline
from matplotlib import pyplot
# Show first 10 images
for i in xrange(10):
    pyplot.figure(i+1)
    ax = pyplot.gca() # gca = get current axis
    ax.imshow(digits.images[i],cmap=pyplot.cm.binary)
Explanation: Let's investigate the data that we just loaded. A dataset contains the original data (digits.images), a 2 dimensional data array and some metadata about the dataset.
End of explanation
digits.data
Explanation: The original data is however always normalized to a single dimensional array. This leads to the digits.data array being of dimension len(digits.images) (the number of images) x len(digits.images[i]) (the one-dimensional image data)
End of explanation
digits.target
Explanation: Our goal is now to train a machine learning algorithm with the given digits dataset, so that it can use what it has learned to later predict or classify new digits. In this case, we'll have 9 target classes (numbers 0-9).
For the digits training set, we already provide these target classes so that they can be used to train our classification algorithm. These classes are stored in digits.target and are also refered to as the "ground truth" for the digit dataset.
End of explanation
%matplotlib inline
print "Class for digits.images[3] =", digits.target[3]
pyplot.imshow(digits.images[3],cmap=pyplot.cm.binary)
Explanation: For example, for digits.images[3], we have digits.target[3] ==  3, as the digits.images[3] contains the number 3.
End of explanation
from sklearn import svm
clf = svm.SVC(gamma=0.001, C=100)
Explanation: The algorithm that we will use to do the classification is a so-called estimator. Well-known matematical estimators inlcude: absolute error, mean squared error, variance, ... In scikit-learn, an estimator for classification is a Python object that implements the methods fit(X, y) and predict(T).
An example of an estimator is the class sklearn.svm.SVC that implements support vector classification. A Support  Vector Machine is non-probabilistic binary linear classifier.
The constructor of an estimator takes as arguments the parameters of the model, but for the time being, we will consider the estimator as a black box:
End of explanation
clf.fit(digits.data[:-1], digits.target[:-1])
Explanation: We now train the classifier with all but the last item in the dataset (using python's [:-1] syntax) by calling the fit method.
End of explanation
result = clf.predict(digits.data[-1:])
%matplotlib inline
print "Class for digits.images[-1] =", result[0]
pyplot.imshow(digits.images[-1],cmap=pyplot.cm.binary)
Explanation: Now you can predict new values, in particular, we can ask to the classifier what is the digit of our last image in the digits dataset, which we have not used to train the classifier:
End of explanation
<END_TASK>