Load the filenames and data from the 20 newsgroups dataset (classification).
Download it if necessary.
Classes
20
Samples total
18846
Dimensionality
1
Features
text
Read more in the User Guide.
Specify a download and cache folder for the datasets. If None, all scikit-learn data is stored in ‘~/scikit_learn_data’ subfolders.
Select the dataset to load: ‘train’ for the training set, ‘test’ for the test set, ‘all’ for both, with shuffled ordering.
If None (default), load all the categories. If not None, list of category names to load (other categories ignored).
Whether or not to shuffle the data: might be important for models that make the assumption that the samples are independent and identically distributed (i.i.d.), such as stochastic gradient descent.
Determines random number generation for dataset shuffling. Pass an int for reproducible output across multiple function calls. See Glossary.
May contain any subset of (‘headers’, ‘footers’, ‘quotes’). Each of these are kinds of text that will be detected and removed from the newsgroup posts, preventing classifiers from overfitting on metadata.
‘headers’ removes newsgroup headers, ‘footers’ removes blocks at the ends of posts that look like signatures, and ‘quotes’ removes lines that appear to be quoting another post.
‘headers’ follows an exact standard; the other filters are not always correct.
If False, raise an IOError if the data is not locally available instead of trying to download the data from the source site.
If True, returns (data.data, data.target) instead of a Bunch object.
New in version 0.22.
Dictionary-like object, with the following attributes.
The data list to learn.
The target labels.
The path to the location of the data.
The full description of the dataset.
The names of target classes.
New in version 0.22.


Load and vectorize the 20 newsgroups dataset (classification).
Download it if necessary.
This is a convenience function; the transformation is done using the default settings for CountVectorizer. For more advanced usage (stopword filtering, n-gram extraction, etc.), combine fetch_20newsgroups with a custom CountVectorizer, HashingVectorizer, TfidfTransformer or TfidfVectorizer.
The resulting counts are normalized using sklearn.preprocessing.normalize unless normalize is set to False.
Classes
20
Samples total
18846
Dimensionality
130107
Features
real
Read more in the User Guide.
Select the dataset to load: ‘train’ for the training set, ‘test’ for the test set, ‘all’ for both, with shuffled ordering.
May contain any subset of (‘headers’, ‘footers’, ‘quotes’). Each of these are kinds of text that will be detected and removed from the newsgroup posts, preventing classifiers from overfitting on metadata.
‘headers’ removes newsgroup headers, ‘footers’ removes blocks at the ends of posts that look like signatures, and ‘quotes’ removes lines that appear to be quoting another post.
Specify an download and cache folder for the datasets. If None, all scikit-learn data is stored in ‘~/scikit_learn_data’ subfolders.
If False, raise an IOError if the data is not locally available instead of trying to download the data from the source site.
If True, returns (data.data, data.target) instead of a Bunch object.
New in version 0.20.
If True, normalizes each document’s feature vector to unit norm using sklearn.preprocessing.normalize.
New in version 0.22.
If True, the data is a pandas DataFrame including columns with appropriate dtypes (numeric, string, or categorical). The target is a pandas DataFrame or Series depending on the number of target_columns.
New in version 0.24.
Dictionary-like object, with the following attributes.
The input data matrix. If as_frame is True, data is a pandas DataFrame with sparse columns.
The target labels. If as_frame is True, target is a pandas Series.
The names of target classes.
The full description of the dataset.
Only present when as_frame=True. Pandas DataFrame with data and target.
New in version 0.24.
data and target would be of the format defined in the Bunch description above.
New in version 0.20.


Load the California housing dataset (regression).
Samples total
20640
Dimensionality
8
Features
real
Target
real 0.15 - 5.
Read more in the User Guide.
Specify another download and cache folder for the datasets. By default all scikit-learn data is stored in ‘~/scikit_learn_data’ subfolders.
If False, raise a IOError if the data is not locally available instead of trying to download the data from the source site.
If True, returns (data.data, data.target) instead of a Bunch object.
New in version 0.20.
If True, the data is a pandas DataFrame including columns with appropriate dtypes (numeric, string or categorical). The target is a pandas DataFrame or Series depending on the number of target_columns.
New in version 0.23.
Dictionary-like object, with the following attributes.
Each row corresponding to the 8 feature values in order. If as_frame is True, data is a pandas object.
Each value corresponds to the average house value in units of 100,000. If as_frame is True, target is a pandas object.
Array of ordered feature names used in the dataset.
Description of the California housing dataset.
Only present when as_frame=True. DataFrame with data and target.
New in version 0.23.
New in version 0.20.
This dataset consists of 20,640 samples and 9 features.


Load the covertype dataset (classification).
Download it if necessary.
Classes
7
Samples total
581012
Dimensionality
54
Features
int
Read more in the User Guide.
Specify another download and cache folder for the datasets. By default all scikit-learn data is stored in ‘~/scikit_learn_data’ subfolders.
If False, raise a IOError if the data is not locally available instead of trying to download the data from the source site.
Determines random number generation for dataset shuffling. Pass an int for reproducible output across multiple function calls. See Glossary.
Whether to shuffle dataset.
If True, returns (data.data, data.target) instead of a Bunch object.
New in version 0.20.
If True, the data is a pandas DataFrame including columns with appropriate dtypes (numeric). The target is a pandas DataFrame or Series depending on the number of target columns. If return_X_y is True, then (data, target) will be pandas DataFrames or Series as described below.
New in version 0.24.
Dictionary-like object, with the following attributes.
Each row corresponds to the 54 features in the dataset.
Each value corresponds to one of the 7 forest covertypes with values ranging between 1 to 7.
Only present when as_frame=True. Contains data and target.
Description of the forest covertype dataset.
The names of the dataset columns.
The names of the target columns.
New in version 0.20.


Load the kddcup99 dataset (classification).
Download it if necessary.
Classes
23
Samples total
4898431
Dimensionality
41
Features
discrete (int) or continuous (float)
Read more in the User Guide.
New in version 0.18.
To return the corresponding classical subsets of kddcup 99. If None, return the entire kddcup 99 dataset.
Specify another download and cache folder for the datasets. By default all scikit-learn data is stored in ‘~/scikit_learn_data’ subfolders. .. versionadded:: 0.19
Whether to shuffle dataset.
Determines random number generation for dataset shuffling and for selection of abnormal samples if subset='SA'. Pass an int for reproducible output across multiple function calls. See Glossary.
Whether to load only 10 percent of the data.
If False, raise a IOError if the data is not locally available instead of trying to download the data from the source site.
If True, returns (data, target) instead of a Bunch object. See below for more information about the data and target object.
New in version 0.20.
If True, returns a pandas Dataframe for the data and target objects in the Bunch returned object; Bunch return object will also have a frame member.
New in version 0.24.
Dictionary-like object, with the following attributes.
The data matrix to learn. If as_frame=True, data will be a pandas DataFrame.
The regression target for each sample. If as_frame=True, target will be a pandas Series.
Only present when as_frame=True. Contains data and target.
The full description of the dataset.
The names of the dataset columns
The names of the target columns
New in version 0.20.


Load the Labeled Faces in the Wild (LFW) pairs dataset (classification).
Download it if necessary.
Classes
2
Samples total
13233
Dimensionality
5828
Features
real, between 0 and 255
In the official README.txt this task is described as the “Restricted” task. As I am not sure as to implement the “Unrestricted” variant correctly, I left it as unsupported for now.
The original images are 250 x 250 pixels, but the default slice and resize arguments reduce them to 62 x 47.
Read more in the User Guide.
Select the dataset to load: ‘train’ for the development training set, ‘test’ for the development test set, and ‘10_folds’ for the official evaluation set that is meant to be used with a 10-folds cross validation.
Specify another download and cache folder for the datasets. By default all scikit-learn data is stored in ‘~/scikit_learn_data’ subfolders.
Download and use the funneled variant of the dataset.
Ratio used to resize the each face picture.
Keep the 3 RGB channels instead of averaging them to a single gray level channel. If color is True the shape of the data has one more dimension than the shape with color = False.
Provide a custom 2D slice (height, width) to extract the ‘interesting’ part of the jpeg files and avoid use statistical correlation from the background
If False, raise a IOError if the data is not locally available instead of trying to download the data from the source site.
Dictionary-like object, with the following attributes.
Each row corresponds to 2 ravel’d face images of original size 62 x 47 pixels. Changing the slice_, resize or subset parameters will change the shape of the output.
Each row has 2 face images corresponding to same or different person from the dataset containing 5749 people. Changing the slice_, resize or subset parameters will change the shape of the output.
Labels associated to each pair of images. The two label values being different persons or the same person.
Description of the Labeled Faces in the Wild (LFW) dataset.


Load the Labeled Faces in the Wild (LFW) people dataset (classification).
Download it if necessary.
Classes
5749
Samples total
13233
Dimensionality
5828
Features
real, between 0 and 255
Read more in the User Guide.
Specify another download and cache folder for the datasets. By default all scikit-learn data is stored in ‘~/scikit_learn_data’ subfolders.
Download and use the funneled variant of the dataset.
Ratio used to resize the each face picture.
The extracted dataset will only retain pictures of people that have at least min_faces_per_person different pictures.
Keep the 3 RGB channels instead of averaging them to a single gray level channel. If color is True the shape of the data has one more dimension than the shape with color = False.
Provide a custom 2D slice (height, width) to extract the ‘interesting’ part of the jpeg files and avoid use statistical correlation from the background
If False, raise a IOError if the data is not locally available instead of trying to download the data from the source site.
If True, returns (dataset.data, dataset.target) instead of a Bunch object. See below for more information about the dataset.data and dataset.target object.
New in version 0.20.
Dictionary-like object, with the following attributes.
Each row corresponds to a ravelled face image of original size 62 x 47 pixels. Changing the slice_ or resize parameters will change the shape of the output.
Each row is a face image corresponding to one of the 5749 people in the dataset. Changing the slice_ or resize parameters will change the shape of the output.
Labels associated to each face image. Those labels range from 0-5748 and correspond to the person IDs.
Description of the Labeled Faces in the Wild (LFW) dataset.
New in version 0.20.


Load the Olivetti faces data-set from AT&T (classification).
Download it if necessary.
Classes
40
Samples total
400
Dimensionality
4096
Features
real, between 0 and 1
Read more in the User Guide.
Specify another download and cache folder for the datasets. By default all scikit-learn data is stored in ‘~/scikit_learn_data’ subfolders.
If True the order of the dataset is shuffled to avoid having images of the same person grouped.
Determines random number generation for dataset shuffling. Pass an int for reproducible output across multiple function calls. See Glossary.
If False, raise a IOError if the data is not locally available instead of trying to download the data from the source site.
If True, returns (data, target) instead of a Bunch object. See below for more information about the data and target object.
New in version 0.22.
Dictionary-like object, with the following attributes.
Each row corresponds to a ravelled face image of original size 64 x 64 pixels.
Each row is a face image corresponding to one of the 40 subjects of the dataset.
Labels associated to each face image. Those labels are ranging from 0-39 and correspond to the Subject IDs.
Description of the modified Olivetti Faces Dataset.
New in version 0.22.


Fetch dataset from openml by name or dataset id.
Datasets are uniquely identified by either an integer ID or by a combination of name and version (i.e. there might be multiple versions of the ‘iris’ dataset). Please give either name or data_id (not both). In case a name is given, a version can also be provided.
Read more in the User Guide.
New in version 0.20.
Note
EXPERIMENTAL
The API is experimental (particularly the return value structure), and might have small backward-incompatible changes without notice or warning in future releases.
String identifier of the dataset. Note that OpenML can have multiple datasets with the same name.
Version of the dataset. Can only be provided if also name is given. If ‘active’ the oldest version that’s still active is used. Since there may be more than one active version of a dataset, and those versions may fundamentally be different from one another, setting an exact version is highly recommended.
OpenML ID of the dataset. The most specific way of retrieving a dataset. If data_id is not given, name (and potential version) are used to obtain a dataset.
Specify another download and cache folder for the data sets. By default all scikit-learn data is stored in ‘~/scikit_learn_data’ subfolders.
Specify the column name in the data to use as target. If ‘default-target’, the standard target column a stored on the server is used. If None, all columns are returned as data and the target is None. If list (of strings), all columns with these names are returned as multi-target (Note: not all scikit-learn classifiers can handle all types of multi-output combinations)
Whether to cache downloaded datasets using joblib.
If True, returns (data, target) instead of a Bunch object. See below for more information about the data and target objects.
If True, the data is a pandas DataFrame including columns with appropriate dtypes (numeric, string or categorical). The target is a pandas DataFrame or Series depending on the number of target_columns. The Bunch will contain a frame attribute with the target and the data. If return_X_y is True, then (data, target) will be pandas DataFrames or Series as describe above.
If as_frame is ‘auto’, the data and target will be converted to DataFrame or Series as if as_frame is set to True, unless the dataset is stored in sparse format.
Changed in version 0.24: The default value of as_frame changed from False to 'auto' in 0.24.
Dictionary-like object, with the following attributes.
The feature matrix. Categorical features are encoded as ordinals.
The regression target or classification labels, if applicable. Dtype is float if numeric, and object if categorical. If as_frame is True, target is a pandas object.
The full description of the dataset
The names of the dataset columns
The names of the target columns
New in version 0.22.
Maps each categorical feature name to a list of values, such that the value encoded as i is ith in the list. If as_frame is True, this is None.
More metadata from OpenML
Only present when as_frame=True. DataFrame with data and target.
Note
EXPERIMENTAL
This interface is experimental and subsequent releases may change attributes without notice (although there should only be minor changes to data and target).
Missing values in the ‘data’ are represented as NaN’s. Missing values in ‘target’ are represented as NaN’s (numerical target) or None (categorical target)


Load the RCV1 multilabel dataset (classification).
Download it if necessary.
Version: RCV1-v2, vectors, full sets, topics multilabels.
Classes
103
Samples total
804414
Dimensionality
47236
Features
real, between 0 and 1
Read more in the User Guide.
New in version 0.17.
Specify another download and cache folder for the datasets. By default all scikit-learn data is stored in ‘~/scikit_learn_data’ subfolders.
Select the dataset to load: ‘train’ for the training set (23149 samples), ‘test’ for the test set (781265 samples), ‘all’ for both, with the training samples first if shuffle is False. This follows the official LYRL2004 chronological split.
If False, raise a IOError if the data is not locally available instead of trying to download the data from the source site.
Determines random number generation for dataset shuffling. Pass an int for reproducible output across multiple function calls. See Glossary.
Whether to shuffle dataset.
If True, returns (dataset.data, dataset.target) instead of a Bunch object. See below for more information about the dataset.data and dataset.target object.
New in version 0.20.
Dictionary-like object, with the following attributes.
The array has 0.16% of non zero values. Will be of CSR format.
Each sample has a value of 1 in its categories, and 0 in others. The array has 3.15% of non zero values. Will be of CSR format.
Identification number of each sample, as ordered in dataset.data.
Names of each target (RCV1 topics), as ordered in dataset.target.
Description of the RCV1 dataset.
New in version 0.20.


Loader for species distribution dataset from Phillips et. al. (2006)
Read more in the User Guide.
Specify another download and cache folder for the datasets. By default all scikit-learn data is stored in ‘~/scikit_learn_data’ subfolders.
If False, raise a IOError if the data is not locally available instead of trying to download the data from the source site.
Dictionary-like object, with the following attributes.
These represent the 14 features measured at each point of the map grid. The latitude/longitude values for the grid are discussed below. Missing data is represented by the value -9999.
The training points for the data. Each point has three fields:
The test points for the data. Same format as the training data.
The number of longitudes (x) and latitudes (y) in the grid
The (x,y) position of the lower-left corner, in degrees
The spacing between points of the grid, in degrees
This dataset represents the geographic distribution of species. The dataset is provided by Phillips et. al. (2006).
The two species are:


Return the path of the scikit-learn data dir.
This folder is used by some large dataset loaders to avoid downloading the data several times.
By default the data dir is set to a folder named ‘scikit_learn_data’ in the user home folder.
Alternatively, it can be set by the ‘SCIKIT_LEARN_DATA’ environment variable or programmatically by giving an explicit folder path. The ‘~’ symbol is expanded to the user home folder.
If the folder does not already exist, it is automatically created.
The path to scikit-learn data directory. If None, the default path is ~/sklearn_learn_data.


Load and return the boston house-prices dataset (regression).
Samples total
506
Dimensionality
13
Features
real, positive
Targets
real 5. - 50.
Read more in the User Guide.
If True, returns (data, target) instead of a Bunch object. See below for more information about the data and target object.
New in version 0.18.
Dictionary-like object, with the following attributes.
The data matrix.
The regression target.
The physical location of boston csv dataset.
New in version 0.20.
The full description of the dataset.
The names of features
New in version 0.18.
Changed in version 0.20: Fixed a wrong data point at [445, 0].


Load and return the breast cancer wisconsin dataset (classification).
The breast cancer dataset is a classic and very easy binary classification dataset.
Classes
2
Samples per class
212(M),357(B)
Samples total
569
Dimensionality
30
Features
real, positive
Read more in the User Guide.
If True, returns (data, target) instead of a Bunch object. See below for more information about the data and target object.
New in version 0.18.
If True, the data is a pandas DataFrame including columns with appropriate dtypes (numeric). The target is a pandas DataFrame or Series depending on the number of target columns. If return_X_y is True, then (data, target) will be pandas DataFrames or Series as described below.
New in version 0.23.
Dictionary-like object, with the following attributes.
The data matrix. If as_frame=True, data will be a pandas DataFrame.
The classification target. If as_frame=True, target will be a pandas Series.
The names of the dataset columns.
The names of target classes.
Only present when as_frame=True. DataFrame with data and target.
New in version 0.23.
The full description of the dataset.
The path to the location of the data.
New in version 0.20.
New in version 0.18.
Let’s say you are interested in the samples 10, 50, and 85, and want to know their class name.


Load and return the diabetes dataset (regression).
Samples total
442
Dimensionality
10
Features
real, -.2 < x < .2
Targets
integer 25 - 346
Read more in the User Guide.
If True, returns (data, target) instead of a Bunch object. See below for more information about the data and target object.
New in version 0.18.
If True, the data is a pandas DataFrame including columns with appropriate dtypes (numeric). The target is a pandas DataFrame or Series depending on the number of target columns. If return_X_y is True, then (data, target) will be pandas DataFrames or Series as described below.
New in version 0.23.
Dictionary-like object, with the following attributes.
The data matrix. If as_frame=True, data will be a pandas DataFrame.
The regression target. If as_frame=True, target will be a pandas Series.
The names of the dataset columns.
Only present when as_frame=True. DataFrame with data and target.
New in version 0.23.
The full description of the dataset.
The path to the location of the data.
The path to the location of the target.
New in version 0.18.


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.
The number of classes to return. Between 0 and 10.
If True, returns (data, target) instead of a Bunch object. See below for more information about the data and target object.
New in version 0.18.
If True, the data is a pandas DataFrame including columns with appropriate dtypes (numeric). The target is a pandas DataFrame or Series depending on the number of target columns. If return_X_y is True, then (data, target) will be pandas DataFrames or Series as described below.
New in version 0.23.
Dictionary-like object, with the following attributes.
The flattened data matrix. If as_frame=True, data will be a pandas DataFrame.
The classification target. If as_frame=True, target will be a pandas Series.
The names of the dataset columns.
The names of target classes.
New in version 0.20.
Only present when as_frame=True. DataFrame with data and target.
New in version 0.23.
The raw image data.
The full description of the dataset.
New in version 0.18.
To load the data and visualize the images:


Load text files with categories as subfolder names.
Individual samples are assumed to be files stored a two levels folder structure such as the following:
file_1.txt file_2.txt … file_42.txt
file_43.txt file_44.txt …
The folder names are used as supervised signal label names. The individual file names are not important.
This function does not try to extract features into a numpy array or scipy sparse matrix. In addition, if load_content is false it does not try to load the files in memory.
To use text files in a scikit-learn classification or clustering algorithm, you will need to use the :mod`~sklearn.feature_extraction.text` module to build a feature extraction transformer that suits your problem.
If you set load_content=True, you should also specify the encoding of the text using the ‘encoding’ parameter. For many modern text files, ‘utf-8’ will be the correct encoding. If you leave encoding equal to None, then the content will be made of bytes instead of Unicode, and you will not be able to use most functions in text.
Similar feature extractors should be built for other kind of unstructured data input such as images, audio, video, …
Read more in the User Guide.
Path to the main folder holding one subfolder per category
A paragraph describing the characteristic of the dataset: its source, reference, etc.
If None (default), load all the categories. If not None, list of category names to load (other categories ignored).
Whether to load or not the content of the different files. If true a ‘data’ attribute containing the text information is present in the data structure returned. If not, a filenames attribute gives the path to the files.
Whether or not to shuffle the data: might be important for models that make the assumption that the samples are independent and identically distributed (i.i.d.), such as stochastic gradient descent.
If None, do not try to decode the content of the files (e.g. for images or other non-text content). If not None, encoding to use to decode text files to Unicode if load_content is True.
Instruction on what to do if a byte sequence is given to analyze that contains characters not of the given encoding. Passed as keyword argument ‘errors’ to bytes.decode.
Determines random number generation for dataset shuffling. Pass an int for reproducible output across multiple function calls. See Glossary.
Dictionary-like object, with the following attributes.
Only present when load_content=True. The raw text data to learn.
The target labels (integer index).
The names of target classes.
The full description of the dataset.
The filenames holding the dataset.


Load and return the iris dataset (classification).
The iris dataset is a classic and very easy multi-class classification dataset.
Classes
3
Samples per class
50
Samples total
150
Dimensionality
4
Features
real, positive
Read more in the User Guide.
If True, returns (data, target) instead of a Bunch object. See below for more information about the data and target object.
New in version 0.18.
If True, the data is a pandas DataFrame including columns with appropriate dtypes (numeric). The target is a pandas DataFrame or Series depending on the number of target columns. If return_X_y is True, then (data, target) will be pandas DataFrames or Series as described below.
New in version 0.23.
Dictionary-like object, with the following attributes.
The data matrix. If as_frame=True, data will be a pandas DataFrame.
The classification target. If as_frame=True, target will be a pandas Series.
The names of the dataset columns.
The names of target classes.
Only present when as_frame=True. DataFrame with data and target.
New in version 0.23.
The full description of the dataset.
The path to the location of the data.
New in version 0.20.
New in version 0.18.
Changed in version 0.20: Fixed two wrong data points according to Fisher’s paper. The new version is the same as in R, but not as in the UCI Machine Learning Repository.
Let’s say you are interested in the samples 10, 25, and 50, and want to know their class name.


Load and return the physical excercise linnerud dataset.
This dataset is suitable for multi-ouput regression tasks.
Samples total
20
Dimensionality
3 (for both data and target)
Features
integer
Targets
integer
Read more in the User Guide.
If True, returns (data, target) instead of a Bunch object. See below for more information about the data and target object.
New in version 0.18.
If True, the data is a pandas DataFrame including columns with appropriate dtypes (numeric, string or categorical). The target is a pandas DataFrame or Series depending on the number of target columns. If return_X_y is True, then (data, target) will be pandas DataFrames or Series as described below.
New in version 0.23.
Dictionary-like object, with the following attributes.
The data matrix. If as_frame=True, data will be a pandas DataFrame.
The regression targets. If as_frame=True, target will be a pandas DataFrame.
The names of the dataset columns.
The names of the target columns.
Only present when as_frame=True. DataFrame with data and target.
New in version 0.23.
The full description of the dataset.
The path to the location of the data.
The path to the location of the target.
New in version 0.20.
New in version 0.18.


Load the numpy array of a single sample image
Read more in the User Guide.
The name of the sample image loaded
The image as a numpy array: height x width x color


Load sample images for image manipulation.
Loads both, china and flower.
Read more in the User Guide.
Dictionary-like object, with the following attributes.
The two sample image.
The filenames for the images.
The full description of the dataset.
To load the data and visualize the images:


Load datasets in the svmlight / libsvm format into sparse CSR matrix
This format is a text-based format, with one sample per line. It does not store zero valued features hence is suitable for sparse dataset.
The first element of each line can be used to store a target variable to predict.
This format is used as the default format for both svmlight and the libsvm command line programs.
Parsing a text based source can be expensive. When working on repeatedly on the same dataset, it is recommended to wrap this loader with joblib.Memory.cache to store a memmapped backup of the CSR results of the first call and benefit from the near instantaneous loading of memmapped structures for the subsequent calls.
In case the file contains a pairwise preference constraint (known as “qid” in the svmlight format) these are ignored unless the query_id parameter is set to True. These pairwise preference constraints can be used to constraint the combination of samples when using pairwise loss functions (as is the case in some learning to rank problems) so that only pairs with the same query_id value are considered.
This implementation is written in Cython and is reasonably fast. However, a faster API-compatible loader is also available at:
https://github.com/mblondel/svmlight-loader
(Path to) a file to load. If a path ends in “.gz” or “.bz2”, it will be uncompressed on the fly. If an integer is passed, it is assumed to be a file descriptor. A file-like or file descriptor will not be closed by this function. A file-like object must be opened in binary mode.
The number of features to use. If None, it will be inferred. This argument is useful to load several files that are subsets of a bigger sliced dataset: each subset might not have examples of every feature, hence the inferred shape might vary from one slice to another. n_features is only required if offset or length are passed a non-default value.
Data type of dataset to be loaded. This will be the data type of the output numpy arrays X and y.
Samples may have several labels each (see https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/multilabel.html)
Whether column indices in f are zero-based (True) or one-based (False). If column indices are one-based, they are transformed to zero-based to match Python/NumPy conventions. If set to “auto”, a heuristic check is applied to determine this from the file contents. Both kinds of files occur “in the wild”, but they are unfortunately not self-identifying. Using “auto” or True should always be safe when no offset or length is passed. If offset or length are passed, the “auto” mode falls back to zero_based=True to avoid having the heuristic check yield inconsistent results on different segments of the file.
If True, will return the query_id array for each file.
Ignore the offset first bytes by seeking forward, then discarding the following bytes up until the next new line character.
If strictly positive, stop reading any new line of data once the position in the file has reached the (offset + length) bytes threshold.
tuples of length n_samples.
query_id for each sample. Only returned when query_id is set to True.
See also
Similar function for loading multiple files in this format, enforcing the same number of features/columns on all of them.
To use joblib.Memory to cache the svmlight file:


Load dataset from multiple files in SVMlight format
This function is equivalent to mapping load_svmlight_file over a list of files, except that the results are concatenated into a single, flat list and the samples vectors are constrained to all have the same number of features.
In case the file contains a pairwise preference constraint (known as “qid” in the svmlight format) these are ignored unless the query_id parameter is set to True. These pairwise preference constraints can be used to constraint the combination of samples when using pairwise loss functions (as is the case in some learning to rank problems) so that only pairs with the same query_id value are considered.
(Paths of) files to load. If a path ends in “.gz” or “.bz2”, it will be uncompressed on the fly. If an integer is passed, it is assumed to be a file descriptor. File-likes and file descriptors will not be closed by this function. File-like objects must be opened in binary mode.
The number of features to use. If None, it will be inferred from the maximum column index occurring in any of the files.
This can be set to a higher value than the actual number of features in any of the input files, but setting it to a lower value will cause an exception to be raised.
Data type of dataset to be loaded. This will be the data type of the output numpy arrays X and y.
Samples may have several labels each (see https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/multilabel.html)
Whether column indices in f are zero-based (True) or one-based (False). If column indices are one-based, they are transformed to zero-based to match Python/NumPy conventions. If set to “auto”, a heuristic check is applied to determine this from the file contents. Both kinds of files occur “in the wild”, but they are unfortunately not self-identifying. Using “auto” or True should always be safe when no offset or length is passed. If offset or length are passed, the “auto” mode falls back to zero_based=True to avoid having the heuristic check yield inconsistent results on different segments of the file.
If True, will return the query_id array for each file.
Ignore the offset first bytes by seeking forward, then discarding the following bytes up until the next new line character.
If strictly positive, stop reading any new line of data once the position in the file has reached the (offset + length) bytes threshold.
See also
When fitting a model to a matrix X_train and evaluating it against a matrix X_test, it is essential that X_train and X_test have the same number of features (X_train.shape[1] == X_test.shape[1]). This may not be the case if you load the files individually with load_svmlight_file.


Load and return the wine dataset (classification).
New in version 0.18.
The wine dataset is a classic and very easy multi-class classification dataset.
Classes
3
Samples per class
[59,71,48]
Samples total
178
Dimensionality
13
Features
real, positive
Read more in the User Guide.
If True, returns (data, target) instead of a Bunch object. See below for more information about the data and target object.
If True, the data is a pandas DataFrame including columns with appropriate dtypes (numeric). The target is a pandas DataFrame or Series depending on the number of target columns. If return_X_y is True, then (data, target) will be pandas DataFrames or Series as described below.
New in version 0.23.
Dictionary-like object, with the following attributes.
The data matrix. If as_frame=True, data will be a pandas DataFrame.
The classification target. If as_frame=True, target will be a pandas Series.
The names of the dataset columns.
The names of target classes.
Only present when as_frame=True. DataFrame with data and target.
New in version 0.23.
The full description of the dataset.
Let’s say you are interested in the samples 10, 80, and 140, and want to know their class name.


Generate an array with constant block diagonal structure for biclustering.
Read more in the User Guide.
The shape of the result.
The number of biclusters.
The standard deviation of the gaussian noise.
Minimum value of a bicluster.
Maximum value of a bicluster.
Shuffle the samples.
Determines random number generation for dataset creation. Pass an int for reproducible output across multiple function calls. See Glossary.
The generated array.
The indicators for cluster membership of each row.
The indicators for cluster membership of each column.
See also
Dhillon, I. S. (2001, August). Co-clustering documents and words using bipartite spectral graph partitioning. In Proceedings of the seventh ACM SIGKDD international conference on Knowledge discovery and data mining (pp. 269-274). ACM.


Generate isotropic Gaussian blobs for clustering.
Read more in the User Guide.
If int, it is the total number of points equally divided among clusters. If array-like, each element of the sequence indicates the number of samples per cluster.
Changed in version v0.20: one can now pass an array-like to the n_samples parameter
The number of features for each sample.
The number of centers to generate, or the fixed center locations. If n_samples is an int and centers is None, 3 centers are generated. If n_samples is array-like, centers must be either None or an array of length equal to the length of n_samples.
The standard deviation of the clusters.
The bounding box for each cluster center when centers are generated at random.
Shuffle the samples.
Determines random number generation for dataset creation. Pass an int for reproducible output across multiple function calls. See Glossary.
If True, then return the centers of each cluster
New in version 0.23.
The generated samples.
The integer labels for cluster membership of each sample.
The centers of each cluster. Only returned if return_centers=True.
See also
A more intricate variant.


Generate an array with block checkerboard structure for biclustering.
Read more in the User Guide.
The shape of the result.
The number of row and column clusters.
The standard deviation of the gaussian noise.
Minimum value of a bicluster.
Maximum value of a bicluster.
Shuffle the samples.
Determines random number generation for dataset creation. Pass an int for reproducible output across multiple function calls. See Glossary.
The generated array.
The indicators for cluster membership of each row.
The indicators for cluster membership of each column.
See also
Kluger, Y., Basri, R., Chang, J. T., & Gerstein, M. (2003). Spectral biclustering of microarray data: coclustering genes and conditions. Genome research, 13(4), 703-716.


Make a large circle containing a smaller circle in 2d.
A simple toy dataset to visualize clustering and classification algorithms.
Read more in the User Guide.
If int, it is the total number of points generated. For odd numbers, the inner circle will have one point more than the outer circle. If two-element tuple, number of points in outer circle and inner circle.
Changed in version 0.23: Added two-element tuple.
Whether to shuffle the samples.
Standard deviation of Gaussian noise added to the data.
Determines random number generation for dataset shuffling and noise. Pass an int for reproducible output across multiple function calls. See Glossary.
Scale factor between inner and outer circle in the range (0, 1).
The generated samples.
The integer labels (0 or 1) for class membership of each sample.


Generate a random n-class classification problem.
This initially creates clusters of points normally distributed (std=1) about vertices of an n_informative-dimensional hypercube with sides of length 2*class_sep and assigns an equal number of clusters to each class. It introduces interdependence between these features and adds various types of further noise to the data.
Without shuffling, X horizontally stacks features in the following order: the primary n_informative features, followed by n_redundant linear combinations of the informative features, followed by n_repeated duplicates, drawn randomly with replacement from the informative and redundant features. The remaining features are filled with random noise. Thus, without shuffling, all useful features are contained in the columns X[:, :n_informative + n_redundant + n_repeated].
Read more in the User Guide.
The number of samples.
The total number of features. These comprise n_informative informative features, n_redundant redundant features, n_repeated duplicated features and n_features-n_informative-n_redundant-n_repeated useless features drawn at random.
The number of informative features. Each class is composed of a number of gaussian clusters each located around the vertices of a hypercube in a subspace of dimension n_informative. For each cluster, informative features are drawn independently from N(0, 1) and then randomly linearly combined within each cluster in order to add covariance. The clusters are then placed on the vertices of the hypercube.
The number of redundant features. These features are generated as random linear combinations of the informative features.
The number of duplicated features, drawn randomly from the informative and the redundant features.
The number of classes (or labels) of the classification problem.
The number of clusters per class.
The proportions of samples assigned to each class. If None, then classes are balanced. Note that if len(weights) == n_classes - 1, then the last class weight is automatically inferred. More than n_samples samples may be returned if the sum of weights exceeds 1. Note that the actual class proportions will not exactly match weights when flip_y isn’t 0.
The fraction of samples whose class is assigned randomly. Larger values introduce noise in the labels and make the classification task harder. Note that the default setting flip_y > 0 might lead to less than n_classes in y in some cases.
The factor multiplying the hypercube size. Larger values spread out the clusters/classes and make the classification task easier.
If True, the clusters are put on the vertices of a hypercube. If False, the clusters are put on the vertices of a random polytope.
Shift features by the specified value. If None, then features are shifted by a random value drawn in [-class_sep, class_sep].
Multiply features by the specified value. If None, then features are scaled by a random value drawn in [1, 100]. Note that scaling happens after shifting.
Shuffle the samples and the features.
Determines random number generation for dataset creation. Pass an int for reproducible output across multiple function calls. See Glossary.
The generated samples.
The integer labels for class membership of each sample.
See also
Simplified variant.
Unrelated generator for multilabel tasks.
The algorithm is adapted from Guyon [1] and was designed to generate the “Madelon” dataset.
I. Guyon, “Design of experiments for the NIPS 2003 variable selection benchmark”, 2003.


Generate the “Friedman #1” regression problem.
This dataset is described in Friedman [1] and Breiman [2].
Inputs X are independent features uniformly distributed on the interval [0, 1]. The output y is created according to the formula:
Out of the n_features features, only 5 are actually used to compute y. The remaining features are independent of y.
The number of features has to be >= 5.
Read more in the User Guide.
The number of samples.
The number of features. Should be at least 5.
The standard deviation of the gaussian noise applied to the output.
Determines random number generation for dataset noise. Pass an int for reproducible output across multiple function calls. See Glossary.
The input samples.
The output values.
J. Friedman, “Multivariate adaptive regression splines”, The Annals of Statistics 19 (1), pages 1-67, 1991.
L. Breiman, “Bagging predictors”, Machine Learning 24, pages 123-140, 1996.


Generate the “Friedman #2” regression problem.
This dataset is described in Friedman [1] and Breiman [2].
Inputs X are 4 independent features uniformly distributed on the intervals:
The output y is created according to the formula:
Read more in the User Guide.
The number of samples.
The standard deviation of the gaussian noise applied to the output.
Determines random number generation for dataset noise. Pass an int for reproducible output across multiple function calls. See Glossary.
The input samples.
The output values.
J. Friedman, “Multivariate adaptive regression splines”, The Annals of Statistics 19 (1), pages 1-67, 1991.
L. Breiman, “Bagging predictors”, Machine Learning 24, pages 123-140, 1996.


Generate the “Friedman #3” regression problem.
This dataset is described in Friedman [1] and Breiman [2].
Inputs X are 4 independent features uniformly distributed on the intervals:
The output y is created according to the formula:
Read more in the User Guide.
The number of samples.
The standard deviation of the gaussian noise applied to the output.
Determines random number generation for dataset noise. Pass an int for reproducible output across multiple function calls. See Glossary.
The input samples.
The output values.
J. Friedman, “Multivariate adaptive regression splines”, The Annals of Statistics 19 (1), pages 1-67, 1991.
L. Breiman, “Bagging predictors”, Machine Learning 24, pages 123-140, 1996.


Generate isotropic Gaussian and label samples by quantile.
This classification dataset is constructed by taking a multi-dimensional standard normal distribution and defining classes separated by nested concentric multi-dimensional spheres such that roughly equal numbers of samples are in each class (quantiles of the \(\chi^2\) distribution).
Read more in the User Guide.
The mean of the multi-dimensional normal distribution. If None then use the origin (0, 0, …).
The covariance matrix will be this value times the unit matrix. This dataset only produces symmetric normal distributions.
The total number of points equally divided among classes.
The number of features for each sample.
The number of classes
Shuffle the samples.
Determines random number generation for dataset creation. Pass an int for reproducible output across multiple function calls. See Glossary.
The generated samples.
The integer labels for quantile membership of each sample.
The dataset is from Zhu et al [1].


Generates data for binary classification used in Hastie et al. 2009, Example 10.2.
The ten features are standard independent Gaussian and the target y is defined by:
Read more in the User Guide.
The number of samples.
Determines random number generation for dataset creation. Pass an int for reproducible output across multiple function calls. See Glossary.
The input samples.
The output values.
See also
A generalization of this dataset approach.
T. Hastie, R. Tibshirani and J. Friedman, “Elements of Statistical Learning Ed. 2”, Springer, 2009.


Generate a mostly low rank matrix with bell-shaped singular values.
Most of the variance can be explained by a bell-shaped curve of width effective_rank: the low rank part of the singular values profile is:
The remaining singular values’ tail is fat, decreasing as:
The low rank part of the profile can be considered the structured signal part of the data while the tail can be considered the noisy part of the data that cannot be summarized by a low number of linear components (singular vectors).
Read more in the User Guide.
The number of samples.
The number of features.
The approximate number of singular vectors required to explain most of the data by linear combinations.
The relative importance of the fat noisy tail of the singular values profile. The value should be between 0 and 1.
Determines random number generation for dataset creation. Pass an int for reproducible output across multiple function calls. See Glossary.
The matrix.


Make two interleaving half circles.
A simple toy dataset to visualize clustering and classification algorithms. Read more in the User Guide.
If int, the total number of points generated. If two-element tuple, number of points in each of two moons.
Changed in version 0.23: Added two-element tuple.
Whether to shuffle the samples.
Standard deviation of Gaussian noise added to the data.
Determines random number generation for dataset shuffling and noise. Pass an int for reproducible output across multiple function calls. See Glossary.
The generated samples.
The integer labels (0 or 1) for class membership of each sample.


Generate a random multilabel classification problem.
In the above process, rejection sampling is used to make sure that n is never zero or more than n_classes, and that the document length is never zero. Likewise, we reject classes which have already been chosen.
Read more in the User Guide.
The number of samples.
The total number of features.
The number of classes of the classification problem.
The average number of labels per instance. More precisely, the number of labels per sample is drawn from a Poisson distribution with n_labels as its expected value, but samples are bounded (using rejection sampling) by n_classes, and must be nonzero if allow_unlabeled is False.
The sum of the features (number of words if documents) is drawn from a Poisson distribution with this expected value.
If True, some instances might not belong to any class.
If True, return a sparse feature matrix
New in version 0.17: parameter to allow sparse output.
If 'dense' return Y in the dense binary indicator format. If 'sparse' return Y in the sparse binary indicator format. False returns a list of lists of labels.
If True, return the prior class probability and conditional probabilities of features given classes, from which the data was drawn.
Determines random number generation for dataset creation. Pass an int for reproducible output across multiple function calls. See Glossary.
The generated samples.
The label sets. Sparse matrix should be of CSR format.
The probability of each class being drawn. Only returned if return_distributions=True.
The probability of each feature being drawn given each class. Only returned if return_distributions=True.


Generate a random regression problem.
The input set can either be well conditioned (by default) or have a low rank-fat tail singular profile. See make_low_rank_matrix for more details.
The output is generated by applying a (potentially biased) random linear regression model with n_informative nonzero regressors to the previously generated input and some gaussian centered noise with some adjustable scale.
Read more in the User Guide.
The number of samples.
The number of features.
The number of informative features, i.e., the number of features used to build the linear model used to generate the output.
The number of regression targets, i.e., the dimension of the y output vector associated with a sample. By default, the output is a scalar.
The bias term in the underlying linear model.
The approximate number of singular vectors required to explain most of the input data by linear combinations. Using this kind of singular spectrum in the input allows the generator to reproduce the correlations often observed in practice.
The input set is well conditioned, centered and gaussian with unit variance.
The relative importance of the fat noisy tail of the singular values profile if effective_rank is not None. When a float, it should be between 0 and 1.
The standard deviation of the gaussian noise applied to the output.
Shuffle the samples and the features.
If True, the coefficients of the underlying linear model are returned.
Determines random number generation for dataset creation. Pass an int for reproducible output across multiple function calls. See Glossary.
The input samples.
The output values.
The coefficient of the underlying linear model. It is returned only if coef is True.


Generate a signal as a sparse combination of dictionary elements.
Returns a matrix Y = DX, such as D is (n_features, n_components), X is (n_components, n_samples) and each column of X has exactly n_nonzero_coefs non-zero elements.
Read more in the User Guide.
Number of samples to generate
Number of components in the dictionary
Number of features of the dataset to generate
Number of active (non-zero) coefficients in each sample
Determines random number generation for dataset creation. Pass an int for reproducible output across multiple function calls. See Glossary.
The encoded signal (Y).
The dictionary with normalized components (D).
The sparse code such that each column of this matrix has exactly n_nonzero_coefs non-zero items (X).


Generate a sparse symmetric definite positive matrix.
Read more in the User Guide.
The size of the random matrix to generate.
The probability that a coefficient is zero (see notes). Larger values enforce more sparsity. The value should be in the range 0 and 1.
Whether to normalize the output matrix to make the leading diagonal elements all 1
The value of the smallest coefficient between 0 and 1.
The value of the largest coefficient between 0 and 1.
Determines random number generation for dataset creation. Pass an int for reproducible output across multiple function calls. See Glossary.
The generated matrix.
See also
The sparsity is actually imposed on the cholesky factor of the matrix. Thus alpha does not translate directly into the filling fraction of the matrix itself.


Generate a random regression problem with sparse uncorrelated design.
This dataset is described in Celeux et al [1]. as:
Only the first 4 features are informative. The remaining features are useless.
Read more in the User Guide.
The number of samples.
The number of features.
Determines random number generation for dataset creation. Pass an int for reproducible output across multiple function calls. See Glossary.
The input samples.
The output values.
G. Celeux, M. El Anbari, J.-M. Marin, C. P. Robert, “Regularization in regression: comparing Bayesian and frequentist methods in a poorly informative situation”, 2009.


Generate a random symmetric, positive-definite matrix.
Read more in the User Guide.
The matrix dimension.
Determines random number generation for dataset creation. Pass an int for reproducible output across multiple function calls. See Glossary.
The random symmetric, positive-definite matrix.
See also


Generate a swiss roll dataset.
Read more in the User Guide.
The number of sample points on the S curve.
The standard deviation of the gaussian noise.
Determines random number generation for dataset creation. Pass an int for reproducible output across multiple function calls. See Glossary.
The points.
The univariate position of the sample according to the main dimension of the points in the manifold.
The algorithm is from Marsland [1].
S. Marsland, “Machine Learning: An Algorithmic Perspective”, Chapter 10, 2009. http://seat.massey.ac.nz/personal/s.r.marsland/Code/10/lle.py


Generate an S curve dataset.
Read more in the User Guide.
The number of sample points on the S curve.
The standard deviation of the gaussian noise.
Determines random number generation for dataset creation. Pass an int for reproducible output across multiple function calls. See Glossary.
The points.
The univariate position of the sample according to the main dimension of the points in the manifold.


Dictionary learning
Finds a dictionary (a set of atoms) that can best be used to represent data using a sparse code.
Solves the optimization problem:
Read more in the User Guide.
Number of dictionary elements to extract.
Sparsity controlling parameter.
Maximum number of iterations to perform.
Tolerance for numerical error.
New in version 0.17: cd coordinate descent method to improve speed.
Algorithm used to transform the data:
New in version 0.17: lasso_cd coordinate descent method to improve speed.
Number of nonzero coefficients to target in each column of the solution. This is only used by algorithm='lars' and algorithm='omp' and is overridden by alpha in the omp case. If None, then transform_n_nonzero_coefs=int(n_features / 10).
If algorithm='lasso_lars' or algorithm='lasso_cd', alpha is the penalty applied to the L1 norm. If algorithm='threshold', alpha is the absolute value of the threshold below which coefficients will be squashed to zero. If algorithm='omp', alpha is the tolerance parameter: the value of the reconstruction error targeted. In this case, it overrides n_nonzero_coefs. If None, default to 1.0
Number of parallel jobs to run. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors. See Glossary for more details.
Initial value for the code, for warm restart.
Initial values for the dictionary, for warm restart.
To control the verbosity of the procedure.
Whether to split the sparse feature vector into the concatenation of its negative part and its positive part. This can improve the performance of downstream classifiers.
Used for initializing the dictionary when dict_init is not specified, randomly shuffling the data when shuffle is set to True, and updating the dictionary. Pass an int for reproducible results across multiple function calls. See Glossary.
Whether to enforce positivity when finding the code.
New in version 0.20.
Whether to enforce positivity when finding the dictionary
New in version 0.20.
Maximum number of iterations to perform if algorithm='lasso_cd' or 'lasso_lars'.
New in version 0.22.
dictionary atoms extracted from the data
vector of errors at each iteration
Number of iterations run.
See also
References:
J. Mairal, F. Bach, J. Ponce, G. Sapiro, 2009: Online dictionary learning for sparse coding (https://www.di.ens.fr/sierra/pdfs/icml09.pdf)
We can check the level of sparsity of X_transformed:
We can compare the average squared euclidean norm of the reconstruction error of the sparse coded signal relative to the squared euclidean norm of the original signal:
fit(X[, y])
Fit the model from data in X.
fit_transform(X[, y])
Fit to data, then transform it.
get_params([deep])
Get parameters for this estimator.
set_params(**params)
Set the parameters of this estimator.
transform(X)
Encode the data as a sparse combination of the dictionary atoms.
Fit the model from data in X.
Training vector, where n_samples in the number of samples and n_features is the number of features.
Returns the object itself.
Fit to data, then transform it.
Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.
Input samples.
Target values (None for unsupervised transformations).
Additional fit parameters.
Transformed array.
Get parameters for this estimator.
If True, will return the parameters for this estimator and contained subobjects that are estimators.
Parameter names mapped to their values.
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.
Estimator parameters.
Estimator instance.
Encode the data as a sparse combination of the dictionary atoms.
Coding method is determined by the object parameter transform_algorithm.
Test data to be transformed, must have the same number of features as the data used to train the model.
Transformed data.


Fit the model from data in X.
Training vector, where n_samples in the number of samples and n_features is the number of features.
Returns the object itself.


Fit to data, then transform it.
Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.
Input samples.
Target values (None for unsupervised transformations).
Additional fit parameters.
Transformed array.


Get parameters for this estimator.
If True, will return the parameters for this estimator and contained subobjects that are estimators.
Parameter names mapped to their values.


Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.
Estimator parameters.
Estimator instance.


Encode the data as a sparse combination of the dictionary atoms.
Coding method is determined by the object parameter transform_algorithm.
Test data to be transformed, must have the same number of features as the data used to train the model.
Transformed data.


Solves a dictionary learning matrix factorization problem.
Finds the best dictionary and the corresponding sparse code for approximating the data matrix X by solving:
where V is the dictionary and U is the sparse code.
Read more in the User Guide.
Data matrix.
Number of dictionary atoms to extract.
Sparsity controlling parameter.
Maximum number of iterations to perform.
Tolerance for the stopping condition.
The method used:
problem (linear_model.lars_path);
Number of parallel jobs to run. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors. See Glossary for more details.
Initial value for the dictionary for warm restart scenarios.
Initial value for the sparse code for warm restart scenarios.
Callable that gets invoked every five iterations
To control the verbosity of the procedure.
Used for randomly initializing the dictionary. Pass an int for reproducible results across multiple function calls. See Glossary.
Whether or not to return the number of iterations.
Whether to enforce positivity when finding the dictionary.
New in version 0.20.
Whether to enforce positivity when finding the code.
New in version 0.20.
Maximum number of iterations to perform.
New in version 0.22.
The sparse code factor in the matrix factorization.
The dictionary factor in the matrix factorization.
Vector of errors at each iteration.
Number of iterations run. Returned only if return_n_iter is set to True.
See also


Solves a dictionary learning matrix factorization problem online.
Finds the best dictionary and the corresponding sparse code for approximating the data matrix X by solving:
where V is the dictionary and U is the sparse code. This is accomplished by repeatedly iterating over mini-batches by slicing the input data.
Read more in the User Guide.
Data matrix.
Number of dictionary atoms to extract.
Sparsity controlling parameter.
Number of mini-batch iterations to perform.
Whether to also return the code U or just the dictionary V.
Initial value for the dictionary for warm restart scenarios.
callable that gets invoked every five iterations.
The number of samples to take in each batch.
To control the verbosity of the procedure.
Whether to shuffle the data before splitting it in batches.
Number of parallel jobs to run. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors. See Glossary for more details.
Number of previous iterations completed on the dictionary used for initialization.
Used for initializing the dictionary when dict_init is not specified, randomly shuffling the data when shuffle is set to True, and updating the dictionary. Pass an int for reproducible results across multiple function calls. See Glossary.
Return the inner statistics A (dictionary covariance) and B (data approximation). Useful to restart the algorithm in an online setting. If return_inner_stats is True, return_code is ignored.
Inner sufficient statistics that are kept by the algorithm. Passing them at initialization is useful in online settings, to avoid losing the history of the evolution. A (n_components, n_components) is the dictionary covariance matrix. B (n_features, n_components) is the data approximation matrix.
Whether or not to return the number of iterations.
Whether to enforce positivity when finding the dictionary.
New in version 0.20.
Whether to enforce positivity when finding the code.
New in version 0.20.
Maximum number of iterations to perform when solving the lasso problem.
New in version 0.22.
The sparse code (only returned if return_code=True).
The solutions to the dictionary learning problem.
Number of iterations run. Returned only if return_n_iter is set to True.
See also


Factor Analysis (FA).
A simple linear generative model with Gaussian latent variables.
The observations are assumed to be caused by a linear transformation of lower dimensional latent factors and added Gaussian noise. Without loss of generality the factors are distributed according to a Gaussian with zero mean and unit covariance. The noise is also zero mean and has an arbitrary diagonal covariance matrix.
If we would restrict the model further, by assuming that the Gaussian noise is even isotropic (all diagonal entries are the same) we would obtain PPCA.
FactorAnalysis performs a maximum likelihood estimate of the so-called loading matrix, the transformation of the latent variables to the observed ones, using SVD based approach.
Read more in the User Guide.
New in version 0.13.
Dimensionality of latent space, the number of components of X that are obtained after transform. If None, n_components is set to the number of features.
Stopping tolerance for log-likelihood increase.
Whether to make a copy of X. If False, the input X gets overwritten during fitting.
Maximum number of iterations.
The initial guess of the noise variance for each feature. If None, it defaults to np.ones(n_features).
Which SVD method to use. If ‘lapack’ use standard SVD from scipy.linalg, if ‘randomized’ use fast randomized_svd function. Defaults to ‘randomized’. For most applications ‘randomized’ will be sufficiently precise while providing significant speed gains. Accuracy can also be improved by setting higher values for iterated_power. If this is not sufficient, for maximum precision you should choose ‘lapack’.
Number of iterations for the power method. 3 by default. Only used if svd_method equals ‘randomized’.
If not None, apply the indicated rotation. Currently, varimax and quartimax are implemented. See “The varimax criterion for analytic rotation in factor analysis” H. F. Kaiser, 1958.
New in version 0.24.
Only used when svd_method equals ‘randomized’. Pass an int for reproducible results across multiple function calls. See Glossary.
Components with maximum variance.
The log likelihood at each iteration.
The estimated noise variance for each feature.
Number of iterations run.
Per-feature empirical mean, estimated from the training set.
See also
Principal component analysis is also a latent linear variable model which however assumes equal noise variance for each feature. This extra assumption makes probabilistic PCA faster as it can be computed in closed form.
Independent component analysis, a latent variable model with non-Gaussian latent variables.
fit(X[, y])
Fit the FactorAnalysis model to X using SVD based approach
fit_transform(X[, y])
Fit to data, then transform it.
get_covariance()
Compute data covariance with the FactorAnalysis model.
get_params([deep])
Get parameters for this estimator.
get_precision()
Compute data precision matrix with the FactorAnalysis model.
score(X[, y])
Compute the average log-likelihood of the samples
score_samples(X)
Compute the log-likelihood of each sample
set_params(**params)
Set the parameters of this estimator.
transform(X)
Apply dimensionality reduction to X using the model.
Fit the FactorAnalysis model to X using SVD based approach
Training data.
Fit to data, then transform it.
Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.
Input samples.
Target values (None for unsupervised transformations).
Additional fit parameters.
Transformed array.
Compute data covariance with the FactorAnalysis model.
cov = components_.T * components_ + diag(noise_variance)
Estimated covariance of data.
Get parameters for this estimator.
If True, will return the parameters for this estimator and contained subobjects that are estimators.
Parameter names mapped to their values.
Compute data precision matrix with the FactorAnalysis model.
Estimated precision of data.
Compute the average log-likelihood of the samples
The data
Average log-likelihood of the samples under the current model
Compute the log-likelihood of each sample
The data
Log-likelihood of each sample under the current model
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.
Estimator parameters.
Estimator instance.
Apply dimensionality reduction to X using the model.
Compute the expected mean of the latent variables. See Barber, 21.2.33 (or Bishop, 12.66).
Training data.
The latent variables of X.


Factor Analysis (FA).
A simple linear generative model with Gaussian latent variables.
The observations are assumed to be caused by a linear transformation of lower dimensional latent factors and added Gaussian noise. Without loss of generality the factors are distributed according to a Gaussian with zero mean and unit covariance. The noise is also zero mean and has an arbitrary diagonal covariance matrix.
If we would restrict the model further, by assuming that the Gaussian noise is even isotropic (all diagonal entries are the same) we would obtain PPCA.
FactorAnalysis performs a maximum likelihood estimate of the so-called loading matrix, the transformation of the latent variables to the observed ones, using SVD based approach.
Read more in the User Guide.
New in version 0.13.
Dimensionality of latent space, the number of components of X that are obtained after transform. If None, n_components is set to the number of features.
Stopping tolerance for log-likelihood increase.
Whether to make a copy of X. If False, the input X gets overwritten during fitting.
Maximum number of iterations.
The initial guess of the noise variance for each feature. If None, it defaults to np.ones(n_features).
Which SVD method to use. If ‘lapack’ use standard SVD from scipy.linalg, if ‘randomized’ use fast randomized_svd function. Defaults to ‘randomized’. For most applications ‘randomized’ will be sufficiently precise while providing significant speed gains. Accuracy can also be improved by setting higher values for iterated_power. If this is not sufficient, for maximum precision you should choose ‘lapack’.
Number of iterations for the power method. 3 by default. Only used if svd_method equals ‘randomized’.
If not None, apply the indicated rotation. Currently, varimax and quartimax are implemented. See “The varimax criterion for analytic rotation in factor analysis” H. F. Kaiser, 1958.
New in version 0.24.
Only used when svd_method equals ‘randomized’. Pass an int for reproducible results across multiple function calls. See Glossary.
Components with maximum variance.
The log likelihood at each iteration.
The estimated noise variance for each feature.
Number of iterations run.
Per-feature empirical mean, estimated from the training set.
See also
Principal component analysis is also a latent linear variable model which however assumes equal noise variance for each feature. This extra assumption makes probabilistic PCA faster as it can be computed in closed form.
Independent component analysis, a latent variable model with non-Gaussian latent variables.
fit(X[, y])
Fit the FactorAnalysis model to X using SVD based approach
fit_transform(X[, y])
Fit to data, then transform it.
get_covariance()
Compute data covariance with the FactorAnalysis model.
get_params([deep])
Get parameters for this estimator.
get_precision()
Compute data precision matrix with the FactorAnalysis model.
score(X[, y])
Compute the average log-likelihood of the samples
score_samples(X)
Compute the log-likelihood of each sample
set_params(**params)
Set the parameters of this estimator.
transform(X)
Apply dimensionality reduction to X using the model.
Fit the FactorAnalysis model to X using SVD based approach
Training data.
Fit to data, then transform it.
Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.
Input samples.
Target values (None for unsupervised transformations).
Additional fit parameters.
Transformed array.
Compute data covariance with the FactorAnalysis model.
cov = components_.T * components_ + diag(noise_variance)
Estimated covariance of data.
Get parameters for this estimator.
If True, will return the parameters for this estimator and contained subobjects that are estimators.
Parameter names mapped to their values.
Compute data precision matrix with the FactorAnalysis model.
Estimated precision of data.
Compute the average log-likelihood of the samples
The data
Average log-likelihood of the samples under the current model
Compute the log-likelihood of each sample
The data
Log-likelihood of each sample under the current model
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.
Estimator parameters.
Estimator instance.
Apply dimensionality reduction to X using the model.
Compute the expected mean of the latent variables. See Barber, 21.2.33 (or Bishop, 12.66).
Training data.
The latent variables of X.
Factor Analysis (with rotation) to visualize patterns
Model selection with Probabilistic PCA and Factor Analysis (FA)
Faces dataset decompositions


Fit the FactorAnalysis model to X using SVD based approach
Training data.


Compute data covariance with the FactorAnalysis model.
cov = components_.T * components_ + diag(noise_variance)
Estimated covariance of data.


Compute data precision matrix with the FactorAnalysis model.
Estimated precision of data.


Compute the average log-likelihood of the samples
The data
Average log-likelihood of the samples under the current model


Compute the log-likelihood of each sample
The data
Log-likelihood of each sample under the current model


Apply dimensionality reduction to X using the model.
Compute the expected mean of the latent variables. See Barber, 21.2.33 (or Bishop, 12.66).
Training data.
The latent variables of X.


FastICA: a fast algorithm for Independent Component Analysis.
Read more in the User Guide.
Number of components to use. If None is passed, all are used.
Apply parallel or deflational algorithm for FastICA.
If whiten is false, the data is already considered to be whitened, and no whitening is performed.
The functional form of the G function used in the approximation to neg-entropy. Could be either ‘logcosh’, ‘exp’, or ‘cube’. You can also provide your own function. It should return a tuple containing the value of the function, and of its derivative, in the point. Example:
Arguments to send to the functional form. If empty and if fun=’logcosh’, fun_args will take value {‘alpha’ : 1.0}.
Maximum number of iterations during fit.
Tolerance on update at each iteration.
The mixing matrix to be used to initialize the algorithm.
Used to initialize w_init when not specified, with a normal distribution. Pass an int, for reproducible results across multiple function calls. See Glossary.
The linear operator to apply to the data to get the independent sources. This is equal to the unmixing matrix when whiten is False, and equal to np.dot(unmixing_matrix, self.whitening_) when whiten is True.
The pseudo-inverse of components_. It is the linear operator that maps independent sources to the data.
The mean over features. Only set if self.whiten is True.
If the algorithm is “deflation”, n_iter is the maximum number of iterations run across all components. Else they are just the number of iterations taken to converge.
Only set if whiten is ‘True’. This is the pre-whitening matrix that projects data onto the first n_components principal components.
Implementation based on A. Hyvarinen and E. Oja, Independent Component Analysis: Algorithms and Applications, Neural Networks, 13(4-5), 2000, pp. 411-430
fit(X[, y])
Fit the model to X.
fit_transform(X[, y])
Fit the model and recover the sources from X.
get_params([deep])
Get parameters for this estimator.
inverse_transform(X[, copy])
Transform the sources back to the mixed data (apply mixing matrix).
set_params(**params)
Set the parameters of this estimator.
transform(X[, copy])
Recover the sources from X (apply the unmixing matrix).
Fit the model to X.
Training data, where n_samples is the number of samples and n_features is the number of features.
Fit the model and recover the sources from X.
Training data, where n_samples is the number of samples and n_features is the number of features.
Get parameters for this estimator.
If True, will return the parameters for this estimator and contained subobjects that are estimators.
Parameter names mapped to their values.
Transform the sources back to the mixed data (apply mixing matrix).
Sources, where n_samples is the number of samples and n_components is the number of components.
If False, data passed to fit are overwritten. Defaults to True.
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.
Estimator parameters.
Estimator instance.
Recover the sources from X (apply the unmixing matrix).
Data to transform, where n_samples is the number of samples and n_features is the number of features.
If False, data passed to fit can be overwritten. Defaults to True.


Perform Fast Independent Component Analysis.
Read more in the User Guide.
Training vector, where n_samples is the number of samples and n_features is the number of features.
Number of components to extract. If None no dimension reduction is performed.
Apply a parallel or deflational FASTICA algorithm.
If True perform an initial whitening of the data. If False, the data is assumed to have already been preprocessed: it should be centered, normed and white. Otherwise you will get incorrect results. In this case the parameter n_components will be ignored.
The functional form of the G function used in the approximation to neg-entropy. Could be either ‘logcosh’, ‘exp’, or ‘cube’. You can also provide your own function. It should return a tuple containing the value of the function, and of its derivative, in the point. The derivative should be averaged along its last dimension. Example:
return x ** 3, np.mean(3 * x ** 2, axis=-1)
Arguments to send to the functional form. If empty or None and if fun=’logcosh’, fun_args will take value {‘alpha’ : 1.0}
Maximum number of iterations to perform.
A positive scalar giving the tolerance at which the un-mixing matrix is considered to have converged.
Initial un-mixing array of dimension (n.comp,n.comp). If None (default) then an array of normal r.v.’s is used.
Used to initialize w_init when not specified, with a normal distribution. Pass an int, for reproducible results across multiple function calls. See Glossary.
If True, X_mean is returned too.
If False, sources are not computed, but only the rotation matrix. This can save memory when working with big data. Defaults to True.
Whether or not to return the number of iterations.
If whiten is ‘True’, K is the pre-whitening matrix that projects data onto the first n_components principal components. If whiten is ‘False’, K is ‘None’.
The square matrix that unmixes the data after whitening. The mixing matrix is the pseudo-inverse of matrix W K if K is not None, else it is the inverse of W.
Estimated source matrix
The mean over features. Returned only if return_X_mean is True.
If the algorithm is “deflation”, n_iter is the maximum number of iterations run across all components. Else they are just the number of iterations taken to converge. This is returned only when return_n_iter is set to True.
The data matrix X is considered to be a linear combination of non-Gaussian (independent) components i.e. X = AS where columns of S contain the independent components and A is a linear mixing matrix. In short ICA attempts to un-mix' the data by estimating an
un-mixing matrix W where ``S = W K X.` While FastICA was proposed to estimate as many sources as features, it is possible to estimate less by setting n_components < n_features. It this case K is not a square matrix and the estimated A is the pseudo-inverse of W K.
This implementation was originally made for data of shape [n_features, n_samples]. Now the input is transposed before the algorithm is applied. This makes it slightly faster for Fortran-ordered input.
Implemented using FastICA: A. Hyvarinen and E. Oja, Independent Component Analysis: Algorithms and Applications, Neural Networks, 13(4-5), 2000, pp. 411-430


FastICA: a fast algorithm for Independent Component Analysis.
Read more in the User Guide.
Number of components to use. If None is passed, all are used.
Apply parallel or deflational algorithm for FastICA.
If whiten is false, the data is already considered to be whitened, and no whitening is performed.
The functional form of the G function used in the approximation to neg-entropy. Could be either ‘logcosh’, ‘exp’, or ‘cube’. You can also provide your own function. It should return a tuple containing the value of the function, and of its derivative, in the point. Example:
Arguments to send to the functional form. If empty and if fun=’logcosh’, fun_args will take value {‘alpha’ : 1.0}.
Maximum number of iterations during fit.
Tolerance on update at each iteration.
The mixing matrix to be used to initialize the algorithm.
Used to initialize w_init when not specified, with a normal distribution. Pass an int, for reproducible results across multiple function calls. See Glossary.
The linear operator to apply to the data to get the independent sources. This is equal to the unmixing matrix when whiten is False, and equal to np.dot(unmixing_matrix, self.whitening_) when whiten is True.
The pseudo-inverse of components_. It is the linear operator that maps independent sources to the data.
The mean over features. Only set if self.whiten is True.
If the algorithm is “deflation”, n_iter is the maximum number of iterations run across all components. Else they are just the number of iterations taken to converge.
Only set if whiten is ‘True’. This is the pre-whitening matrix that projects data onto the first n_components principal components.
Implementation based on A. Hyvarinen and E. Oja, Independent Component Analysis: Algorithms and Applications, Neural Networks, 13(4-5), 2000, pp. 411-430
fit(X[, y])
Fit the model to X.
fit_transform(X[, y])
Fit the model and recover the sources from X.
get_params([deep])
Get parameters for this estimator.
inverse_transform(X[, copy])
Transform the sources back to the mixed data (apply mixing matrix).
set_params(**params)
Set the parameters of this estimator.
transform(X[, copy])
Recover the sources from X (apply the unmixing matrix).
Fit the model to X.
Training data, where n_samples is the number of samples and n_features is the number of features.
Fit the model and recover the sources from X.
Training data, where n_samples is the number of samples and n_features is the number of features.
Get parameters for this estimator.
If True, will return the parameters for this estimator and contained subobjects that are estimators.
Parameter names mapped to their values.
Transform the sources back to the mixed data (apply mixing matrix).
Sources, where n_samples is the number of samples and n_components is the number of components.
If False, data passed to fit are overwritten. Defaults to True.
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.
Estimator parameters.
Estimator instance.
Recover the sources from X (apply the unmixing matrix).
Data to transform, where n_samples is the number of samples and n_features is the number of features.
If False, data passed to fit can be overwritten. Defaults to True.
Blind source separation using FastICA
FastICA on 2D point clouds
Faces dataset decompositions


Fit the model to X.
Training data, where n_samples is the number of samples and n_features is the number of features.


Fit the model and recover the sources from X.
Training data, where n_samples is the number of samples and n_features is the number of features.


Get parameters for this estimator.
If True, will return the parameters for this estimator and contained subobjects that are estimators.
Parameter names mapped to their values.


Transform the sources back to the mixed data (apply mixing matrix).
Sources, where n_samples is the number of samples and n_components is the number of components.
If False, data passed to fit are overwritten. Defaults to True.


Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.
Estimator parameters.
Estimator instance.


Recover the sources from X (apply the unmixing matrix).
Data to transform, where n_samples is the number of samples and n_features is the number of features.
If False, data passed to fit can be overwritten. Defaults to True.


Incremental principal components analysis (IPCA).
Linear dimensionality reduction using Singular Value Decomposition of the data, keeping only the most significant singular vectors to project the data to a lower dimensional space. The input data is centered but not scaled for each feature before applying the SVD.
Depending on the size of the input data, this algorithm can be much more memory efficient than a PCA, and allows sparse input.
This algorithm has constant memory complexity, on the order of batch_size * n_features, enabling use of np.memmap files without loading the entire file into memory. For sparse matrices, the input is converted to dense in batches (in order to be able to subtract the mean) which avoids storing the entire dense matrix at any one time.
The computational overhead of each SVD is O(batch_size * n_features ** 2), but only 2 * batch_size samples remain in memory at a time. There will be n_samples / batch_size SVD computations to get the principal components, versus 1 large SVD of complexity O(n_samples * n_features ** 2) for PCA.
Read more in the User Guide.
New in version 0.16.
Number of components to keep. If n_components is None, then n_components is set to min(n_samples, n_features).
When True (False by default) the components_ vectors are divided by n_samples times components_ to ensure uncorrelated outputs with unit component-wise variances.
Whitening will remove some information from the transformed signal (the relative variance scales of the components) but can sometimes improve the predictive accuracy of the downstream estimators by making data respect some hard-wired assumptions.
If False, X will be overwritten. copy=False can be used to save memory but is unsafe for general use.
The number of samples to use for each batch. Only used when calling fit. If batch_size is None, then batch_size is inferred from the data and set to 5 * n_features, to provide a balance between approximation accuracy and memory consumption.
Components with maximum variance.
Variance explained by each of the selected components.
Percentage of variance explained by each of the selected components. If all components are stored, the sum of explained variances is equal to 1.0.
The singular values corresponding to each of the selected components. The singular values are equal to the 2-norms of the n_components variables in the lower-dimensional space.
Per-feature empirical mean, aggregate over calls to partial_fit.
Per-feature empirical variance, aggregate over calls to partial_fit.
The estimated noise covariance following the Probabilistic PCA model from Tipping and Bishop 1999. See “Pattern Recognition and Machine Learning” by C. Bishop, 12.2.1 p. 574 or http://www.miketipping.com/papers/met-mppca.pdf.
The estimated number of components. Relevant when n_components=None.
The number of samples processed by the estimator. Will be reset on new calls to fit, but increments across partial_fit calls.
Inferred batch size from batch_size.
See also
Implements the incremental PCA model from: D. Ross, J. Lim, R. Lin, M. Yang, Incremental Learning for Robust Visual Tracking, International Journal of Computer Vision, Volume 77, Issue 1-3, pp. 125-141, May 2008. See https://www.cs.toronto.edu/~dross/ivt/RossLimLinYang_ijcv.pdf
This model is an extension of the Sequential Karhunen-Loeve Transform from: A. Levy and M. Lindenbaum, Sequential Karhunen-Loeve Basis Extraction and its Application to Images, IEEE Transactions on Image Processing, Volume 9, Number 8, pp. 1371-1374, August 2000. See https://www.cs.technion.ac.il/~mic/doc/skl-ip.pdf
We have specifically abstained from an optimization used by authors of both papers, a QR decomposition used in specific situations to reduce the algorithmic complexity of the SVD. The source for this technique is Matrix Computations, Third Edition, G. Holub and C. Van Loan, Chapter 5, section 5.4.4, pp 252-253.. This technique has been omitted because it is advantageous only when decomposing a matrix with n_samples (rows) >= 5/3 * n_features (columns), and hurts the readability of the implemented algorithm. This would be a good opportunity for future optimization, if it is deemed necessary.
D. Ross, J. Lim, R. Lin, M. Yang. Incremental Learning for Robust Visual Tracking, International Journal of Computer Vision, Volume 77, Issue 1-3, pp. 125-141, May 2008.
G. Golub and C. Van Loan. Matrix Computations, Third Edition, Chapter 5, Section 5.4.4, pp. 252-253.
fit(X[, y])
Fit the model with X, using minibatches of size batch_size.
fit_transform(X[, y])
Fit to data, then transform it.
get_covariance()
Compute data covariance with the generative model.
get_params([deep])
Get parameters for this estimator.
get_precision()
Compute data precision matrix with the generative model.
inverse_transform(X)
Transform data back to its original space.
partial_fit(X[, y, check_input])
Incremental fit with X.
set_params(**params)
Set the parameters of this estimator.
transform(X)
Apply dimensionality reduction to X.
Fit the model with X, using minibatches of size batch_size.
Training data, where n_samples is the number of samples and n_features is the number of features.
Returns the instance itself.
Fit to data, then transform it.
Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.
Input samples.
Target values (None for unsupervised transformations).
Additional fit parameters.
Transformed array.
Compute data covariance with the generative model.
cov = components_.T * S**2 * components_ + sigma2 * eye(n_features) where S**2 contains the explained variances, and sigma2 contains the noise variances.
Estimated covariance of data.
Get parameters for this estimator.
If True, will return the parameters for this estimator and contained subobjects that are estimators.
Parameter names mapped to their values.
Compute data precision matrix with the generative model.
Equals the inverse of the covariance but computed with the matrix inversion lemma for efficiency.
Estimated precision of data.
Transform data back to its original space.
In other words, return an input X_original whose transform would be X.
New data, where n_samples is the number of samples and n_components is the number of components.
If whitening is enabled, inverse_transform will compute the exact inverse operation, which includes reversing whitening.
Incremental fit with X. All of X is processed as a single batch.
Training data, where n_samples is the number of samples and n_features is the number of features.
Run check_array on X.
Returns the instance itself.
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.
Estimator parameters.
Estimator instance.
Apply dimensionality reduction to X.
X is projected on the first principal components previously extracted from a training set, using minibatches of size batch_size if X is sparse.
New data, where n_samples is the number of samples and n_features is the number of features.