In [1]:
import numpy as np
from sklearn import datasets
import matplotlib.pyplot as plt
%matplotlib inline
In [2]:
digits = datasets.load_digits()
In [3]:
print(digits.data.shape)
print(digits.images.shape)
In [4]:
img = digits.images[0, :, :]
In [5]:
plt.imshow(img, cmap='gray')
Out[5]:
In [6]:
for image_index in range(10):
# images are 0-indexed, but subplots are 1-indexed
subplot_index = image_index + 1
plt.subplot(2, 5, subplot_index)
plt.imshow(digits.images[image_index, :, :],\
cmap='gray')
In [ ]: