sklearn/examples/datasets/plot_digits_last_image.py

32 lines
875 B
Python
Raw Normal View History

2024-08-05 09:32:03 +02:00
"""
=========================================================
The Digit Dataset
=========================================================
This dataset is made up of 1797 8x8 images. Each image,
like the one shown below, is of a hand-written digit.
In order to utilize an 8x8 figure like this, we'd have to
first transform it into a feature vector with length 64.
See `here
<https://archive.ics.uci.edu/dataset/81/pen+based+recognition+of+handwritten+digits>`_
for more information about this dataset.
"""
# Code source: Gaël Varoquaux
# Modified for documentation by Jaques Grobler
# License: BSD 3 clause
import matplotlib.pyplot as plt
from sklearn import datasets
# Load the digits dataset
digits = datasets.load_digits()
# Display the last digit
plt.figure(1, figsize=(3, 3))
plt.imshow(digits.images[-1], cmap=plt.cm.gray_r, interpolation="nearest")
plt.show()