-
sklearn.datasets.load_digits(n_class=10, return_X_y=False)
[source] -
Load and return the digits dataset (classification).
Each datapoint is a 8x8 image of a digit.
Classes 10 Samples per class ~180 Samples total 1797 Dimensionality 64 Features integers 0-16 Read more in the User Guide.
Parameters: n_class : integer, between 0 and 10, optional (default=10)
The number of classes to return.
return_X_y : boolean, default=False.
If True, returns
(data, target)
instead of a Bunch object. See below for more information about thedata
andtarget
object.New in version 0.18.
Returns: data : Bunch
Dictionary-like object, the interesting attributes are: ?data?, the data to learn, ?images?, the images corresponding to each sample, ?target?, the classification labels for each sample, ?target_names?, the meaning of the labels, and ?DESCR?, the full description of the dataset.
(data, target) : tuple if
return_X_y
is TrueNew in version 0.18.
Examples
To load the data and visualize the images:
12345678>>>
from
sklearn.datasets
import
load_digits
>>> digits
=
load_digits()
>>>
print
(digits.data.shape)
(
1797
,
64
)
>>>
import
matplotlib.pyplot as plt
>>> plt.gray()
>>> plt.matshow(digits.images[
0
])
>>> plt.show()
sklearn.datasets.load_digits()
Examples using

2025-01-10 15:47:30
Please login to continue.