What is datasets.load_digits() in sklearn?
The datasets.load_digits() function helps to load and return the digit dataset. This classification contains data points, where each data point is an 8X8 image of a single digit.
Syntax
sklearn.datasets.load_digits(*[, n_class=10, return_X_y=False, as_frame=False])
Parameters
n_class, type:int: It contains the total number of classes that have to be returned. It ranges between 0 and 10. Its value is 10 by default.return X_y, type=bool: Its value isfalseby default. It returns(data, target)rather than a bunch object.as_frame, type=bool: Its value isfalseby default. If it istrue, the data will be a pandas data frame with columns of numeric type. The target will be dependent upon the number of columns that are set as the target.
Return values
The datasets.load_digits() function will return data with multiple attributes:
- data, {ndarray, dataframe} of (1797, 64) shape: It is a data matrix.
- target, {ndarray, series} of (1797,) shape: The target regarding classification.
- feature_names, type=list: The dataset columns’ name.
- target_names,type= list: The name of the classes regarding targets.
- frame, (1797, 65) shape of data frame: If
as_frame=true, it will return the data frame with the target and data. - images, ndarray of (1797, 8, 8) shape: The raw image data.
- DESCR, type=str: The thorough description of data.
- (data, target): It will return the data as a tuple if
return_X_y= true.
# Loading libraryfrom sklearn.datasets import load_digitsdgts = load_digits()print(dgts.data.shape)import matplotlib.pyplot as pltplt.gray()plt.matshow(dgts.images[1])plt.show()