7.3. Generated datasets¶
In addition, scikit-learn includes various random sample generators that can be used to build artificial datasets of controlled size and complexity.
7.3.1. Generators for classification and clustering¶
These generators produce a matrix of features and corresponding discrete targets.
188.8.131.52. Single label¶
make_classification create multiclass
datasets by allocating each class one or more normally-distributed clusters of
make_blobs provides greater control regarding the centers and
standard deviations of each cluster, and is used to demonstrate clustering.
make_classification specialises in introducing noise by way of:
correlated, redundant and uninformative features; multiple Gaussian clusters
per class; and linear transformations of the feature space.
make_moons generate 2d binary classification
datasets that are challenging to certain algorithms (e.g. centroid-based
clustering or linear classification), including optional Gaussian noise.
They are useful for visualisation.
make_circles produces Gaussian data
with a spherical decision boundary for binary classification, while
make_moons produces two interleaving half circles.
make_multilabel_classification generates random samples with multiple
labels, reflecting a bag of words drawn from a mixture of topics. The number of
topics for each document is drawn from a Poisson distribution, and the topics
themselves are drawn from a fixed random distribution. Similarly, the number of
words is drawn from Poisson, with words drawn from a multinomial, where each
topic defines a probability distribution over words. Simplifications with
respect to true bag-of-words mixtures include:
Per-topic word distributions are independently drawn, where in reality all would be affected by a sparse base distribution, and would be correlated.
For a document generated from multiple topics, all topics are weighted equally in generating its bag of words.
Documents without labels words at random, rather than from a base distribution.
7.3.2. Generators for regression¶
make_regression produces regression targets as an optionally-sparse
random linear combination of random features, with noise. Its informative
features may be uncorrelated, or low rank (few features account for most of the
Other regression generators generate functions deterministically from
make_sparse_uncorrelated produces a target as a
linear combination of four features with fixed coefficients.
Others encode explicitly non-linear relations:
make_friedman1 is related by polynomial and sine transforms;
make_friedman2 includes feature multiplication and reciprocation; and
make_friedman3 is similar with an arctan transformation on the target.
7.3.3. Generators for manifold learning¶
Generate an S curve dataset.
Generate a swiss roll dataset.
7.3.4. Generators for decomposition¶
Generate a mostly low rank matrix with bell-shaped singular values.
Generate a signal as a sparse combination of dictionary elements.
Generate a random symmetric, positive-definite matrix.
Generate a sparse symmetric definite positive matrix.