Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

sklearn
communitycreator

What is datasets.load_digits() in sklearn?

AKASH BAJWA

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

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 is false by default. It returns (data, target) rather than a bunch object.
  • as_frame, type=bool: Its value is false by default. If it is true, 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 library
from sklearn.datasets import load_digits
dgts = load_digits()
print(dgts.data.shape)
import matplotlib.pyplot as plt
plt.gray()
plt.matshow(dgts.images[1])
plt.show()

RELATED TAGS

sklearn
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring