# Load libraries
from sklearn import datasets
import matplotlib.pyplot as plt 

"""
Explanation: Title: Loading scikit-learn's Digits Dataset
Slug: loading_scikit-learns_digits-dataset
Summary: Loading the built-in digits datasets of scikit-learn. 
Date: 2016-08-31 12:00
Category: Machine Learning
Tags: Basics
Authors: Chris Albon 
Preliminaries
End of explanation
"""


# Load digits dataset
digits = datasets.load_digits()

# Create feature matrix
X = digits.data

# Create target vector
y = digits.target

# View the first observation's feature values
X[0]

"""
Explanation: Load Digits Dataset
Digits is a dataset of handwritten digits. Each feature is the intensity of one pixel of an 8 x 8 image.
End of explanation
"""


# View the first observation's feature values as a matrix
digits.images[0]

# Visualize the first observation's feature values as an image
plt.gray() 
plt.matshow(digits.images[0]) 
plt.show()

"""
Explanation: The observation's feature values are presented as a vector. However, by using the images method we can load the the same feature values as a matrix and then visualize the actual handwritten character:
End of explanation
"""


