7. Dataset loading utilities¶
sklearn.datasets package embeds some small toy datasets
as introduced in the Getting Started section.
This package also features helpers to fetch larger datasets commonly used by the machine learning community to benchmark algorithms on data that comes from the ‘real world’.
To evaluate the impact of the scale of the dataset (
n_features) while controlling the statistical properties of the data
(typically the correlation and informativeness of the features), it is
also possible to generate synthetic data.
General dataset API. There are three main kinds of dataset interfaces that can be used to get datasets depending on the desired type of dataset.
The dataset loaders. They can be used to load small standard datasets, described in the Toy datasets section.
The dataset fetchers. They can be used to download and load larger datasets, described in the Real world datasets section.
Both loaders and fetchers functions return a
object holding at least two items:
an array of shape
data (except for 20newsgroups) and a numpy array of
n_samples, containing the target values, with key
The Bunch object is a dictionary that exposes its keys as attributes.
For more information about Bunch object, see
It’s also possible for almost all of these function to constrain the output
to be a tuple containing only the data and the target, by setting the
return_X_y parameter to
The datasets also contain a full description in their
DESCR attribute and
target_names. See the dataset
descriptions below for details.
The dataset generation functions. They can be used to generate controlled synthetic datasets, described in the Generated datasets section.
These functions return a tuple
(X, y) consisting of a
n_features numpy array
X and an array of length
containing the targets
In addition, there are also miscellaneous tools to load datasets of other formats or from other locations, described in the Loading other datasets section.
- 7.1. Toy datasets
- 7.2. Real world datasets
- 7.3. Generated datasets
- 7.4. Loading other datasets