API Reference¶
This is the class and function reference of scikit-learn. Please refer to the full user guide for further details, as the class and function raw specifications may not be enough to give full guidelines on their uses. For reference on concepts repeated across the API, see Glossary of Common Terms and API Elements.
sklearn.base
: Base classes and utility functions¶
Base classes for all estimators.
Base classes¶
Base class for all estimators in scikit-learn |
|
Mixin class for all bicluster estimators in scikit-learn |
|
Mixin class for all classifiers in scikit-learn. |
|
Mixin class for all cluster estimators in scikit-learn. |
|
Mixin class for all density estimators in scikit-learn. |
|
Mixin class for all regression estimators in scikit-learn. |
|
Mixin class for all transformers in scikit-learn. |
Functions¶
|
Constructs a new estimator with the same parameters. |
|
Returns True if the given estimator is (probably) a classifier. |
|
Returns True if the given estimator is (probably) a regressor. |
|
Context manager for global scikit-learn configuration |
Retrieve current values for configuration set by |
|
|
Set global scikit-learn configuration |
Print useful debugging information |
sklearn.calibration
: Probability Calibration¶
Calibration of predicted probabilities.
User guide: See the Probability calibration section for further details.
Probability calibration with isotonic regression or sigmoid. |
|
Compute true and predicted probabilities for a calibration curve. |
sklearn.cluster
: Clustering¶
The sklearn.cluster
module gathers popular unsupervised clustering
algorithms.
User guide: See the Clustering section for further details.
Classes¶
|
Perform Affinity Propagation Clustering of data. |
Agglomerative Clustering |
|
|
Implements the Birch clustering algorithm. |
|
Perform DBSCAN clustering from vector array or distance matrix. |
|
Agglomerate features. |
|
K-Means clustering |
|
Mini-Batch K-Means clustering |
|
Mean shift clustering using a flat kernel. |
|
Estimate clustering structure from vector array |
|
Apply clustering to a projection of the normalized Laplacian. |
Functions¶
|
Perform Affinity Propagation Clustering of data |
|
Performs DBSCAN extraction for an arbitrary epsilon. |
|
Automatically extract clusters according to the Xi-steep method. |
|
Computes the OPTICS reachability graph. |
|
Perform DBSCAN clustering from vector array or distance matrix. |
|
Estimate the bandwidth to use with the mean-shift algorithm. |
|
K-means clustering algorithm. |
|
Perform mean shift clustering of data using a flat kernel. |
|
Apply clustering to a projection of the normalized Laplacian. |
|
Ward clustering based on a Feature matrix. |
sklearn.cluster.bicluster
: Biclustering¶
Spectral biclustering algorithms.
User guide: See the Biclustering section for further details.
Classes¶
|
Spectral biclustering (Kluger, 2003). |
|
Spectral Co-Clustering algorithm (Dhillon, 2001). |
sklearn.compose
: Composite Estimators¶
Meta-estimators for building composite models with transformers
In addition to its current contents, this module will eventually be home to refurbished versions of Pipeline and FeatureUnion.
User guide: See the Pipelines and composite estimators section for further details.
|
Applies transformers to columns of an array or pandas DataFrame. |
Meta-estimator to regress on a transformed target. |
Construct a ColumnTransformer from the given transformers. |
sklearn.covariance
: Covariance Estimators¶
The sklearn.covariance
module includes methods and algorithms to
robustly estimate the covariance of features given a set of points. The
precision matrix defined as the inverse of the covariance is also estimated.
Covariance estimation is closely related to the theory of Gaussian Graphical
Models.
User guide: See the Covariance estimation section for further details.
Maximum likelihood covariance estimator |
|
An object for detecting outliers in a Gaussian distributed dataset. |
|
|
Sparse inverse covariance estimation with an l1-penalized estimator. |
|
Sparse inverse covariance w/ cross-validated choice of the l1 penalty. |
|
LedoitWolf Estimator |
|
Minimum Covariance Determinant (MCD): robust estimator of covariance. |
|
Oracle Approximating Shrinkage Estimator |
Covariance estimator with shrinkage |
|
Computes the Maximum likelihood covariance estimator |
|
l1-penalized covariance estimator |
|
Estimates the shrunk Ledoit-Wolf covariance matrix. |
|
Estimate covariance with the Oracle Approximating Shrinkage algorithm. |
|
Calculates a covariance matrix shrunk on the diagonal |
sklearn.cross_decomposition
: Cross decomposition¶
User guide: See the Cross decomposition section for further details.
|
CCA Canonical Correlation Analysis. |
PLSCanonical implements the 2 blocks canonical PLS of the original Wold algorithm [Tenenhaus 1998] p.204, referred as PLS-C2A in [Wegelin 2000]. |
|
PLS regression |
|
|
Partial Least Square SVD |
sklearn.datasets
: Datasets¶
The sklearn.datasets
module includes utilities to load datasets,
including methods to load and fetch popular reference datasets. It also
features some artificial data generators.
User guide: See the Dataset loading utilities section for further details.
Loaders¶
|
Delete all the content of the data home cache. |
|
Dump the dataset in svmlight / libsvm file format. |
|
Load the filenames and data from the 20 newsgroups dataset (classification). |
Load the 20 newsgroups dataset and vectorize it into token counts (classification). |
|
Load the California housing dataset (regression). |
|
|
Load the covertype dataset (classification). |
|
Load the kddcup99 dataset (classification). |
|
Load the Labeled Faces in the Wild (LFW) pairs dataset (classification). |
|
Load the Labeled Faces in the Wild (LFW) people dataset (classification). |
|
Load the Olivetti faces data-set from AT&T (classification). |
|
Fetch dataset from openml by name or dataset id. |
|
Load the RCV1 multilabel dataset (classification). |
Loader for species distribution dataset from Phillips et. |
|
|
Return the path of the scikit-learn data dir. |
|
Load and return the boston house-prices dataset (regression). |
|
Load and return the breast cancer wisconsin dataset (classification). |
|
Load and return the diabetes dataset (regression). |
|
Load and return the digits dataset (classification). |
|
Load text files with categories as subfolder names. |
|
Load and return the iris dataset (classification). |
|
Load and return the linnerud dataset (multivariate regression). |
|
Load the numpy array of a single sample image |
Load sample images for image manipulation. |
|
|
Load datasets in the svmlight / libsvm format into sparse CSR matrix |
|
Load dataset from multiple files in SVMlight format |
|
Load and return the wine dataset (classification). |
Samples generator¶
|
Generate an array with constant block diagonal structure for biclustering. |
|
Generate isotropic Gaussian blobs for clustering. |
|
Generate an array with block checkerboard structure for biclustering. |
|
Make a large circle containing a smaller circle in 2d. |
|
Generate a random n-class classification problem. |
|
Generate the “Friedman #1” regression problem |
|
Generate the “Friedman #2” regression problem |
|
Generate the “Friedman #3” regression problem |
|
Generate isotropic Gaussian and label samples by quantile |
|
Generates data for binary classification used in Hastie et al. |
|
Generate a mostly low rank matrix with bell-shaped singular values |
|
Make two interleaving half circles |
Generate a random multilabel classification problem. |
|
|
Generate a random regression problem. |
|
Generate an S curve dataset. |
|
Generate a signal as a sparse combination of dictionary elements. |
|
Generate a sparse symmetric definite positive matrix. |
Generate a random regression problem with sparse uncorrelated design |
|
|
Generate a random symmetric, positive-definite matrix. |
|
Generate a swiss roll dataset. |
sklearn.decomposition
: Matrix Decomposition¶
The sklearn.decomposition
module includes matrix decomposition
algorithms, including among others PCA, NMF or ICA. Most of the algorithms of
this module can be regarded as dimensionality reduction techniques.
User guide: See the Decomposing signals in components (matrix factorization problems) section for further details.
Dictionary learning |
|
|
Factor Analysis (FA) |
|
FastICA: a fast algorithm for Independent Component Analysis. |
|
Incremental principal components analysis (IPCA). |
|
Kernel Principal component analysis (KPCA) |
Latent Dirichlet Allocation with online variational Bayes algorithm |
|
Mini-batch dictionary learning |
|
Mini-batch Sparse Principal Components Analysis |
|
|
Non-Negative Matrix Factorization (NMF) |
|
Principal component analysis (PCA) |
|
Sparse Principal Components Analysis (SparsePCA) |
|
Sparse coding |
|
Dimensionality reduction using truncated SVD (aka LSA). |
|
Solves a dictionary learning matrix factorization problem. |
Solves a dictionary learning matrix factorization problem online. |
|
|
Perform Fast Independent Component Analysis. |
Compute Non-negative Matrix Factorization (NMF) |
|
|
Sparse coding |
sklearn.discriminant_analysis
: Discriminant Analysis¶
Linear Discriminant Analysis and Quadratic Discriminant Analysis
User guide: See the Linear and Quadratic Discriminant Analysis section for further details.
Linear Discriminant Analysis |
|
Quadratic Discriminant Analysis |
sklearn.dummy
: Dummy estimators¶
User guide: See the Model evaluation: quantifying the quality of predictions section for further details.
|
DummyClassifier is a classifier that makes predictions using simple rules. |
|
DummyRegressor is a regressor that makes predictions using simple rules. |
sklearn.ensemble
: Ensemble Methods¶
The sklearn.ensemble
module includes ensemble-based methods for
classification, regression and anomaly detection.
User guide: See the Ensemble methods section for further details.
An AdaBoost classifier. |
|
|
An AdaBoost regressor. |
|
A Bagging classifier. |
|
A Bagging regressor. |
An extra-trees classifier. |
|
|
An extra-trees regressor. |
|
Gradient Boosting for classification. |
|
Gradient Boosting for regression. |
|
Isolation Forest Algorithm |
A random forest classifier. |
|
A random forest regressor. |
|
An ensemble of totally random trees. |
|
|
Stack of estimators with a final classifier. |
|
Stack of estimators with a final regressor. |
|
Soft Voting/Majority Rule classifier for unfitted estimators. |
|
Prediction voting regressor for unfitted estimators. |
Histogram-based Gradient Boosting Regression Tree. |
|
Histogram-based Gradient Boosting Classification Tree. |
sklearn.exceptions
: Exceptions and warnings¶
The sklearn.exceptions
module includes all custom warnings and error
classes used across scikit-learn.
Warning class used to notify the user of any change in the behavior. |
|
Custom warning to capture convergence problems |
|
Warning used to notify implicit data conversions happening in the code. |
|
Custom warning to notify potential issues with data dimensionality. |
|
Warning used to notify the user of inefficient computation. |
|
Warning class used if there is an error while fitting the estimator. |
|
Exception class to raise if estimator is used before fitting. |
|
Warning used when the dot operation does not use BLAS. |
|
Warning used when the metric is invalid |
sklearn.experimental
: Experimental¶
The sklearn.experimental
module provides importable modules that enable
the use of experimental features or estimators.
The features and estimators that are experimental aren’t subject to deprecation cycles. Use them at your own risks!
Enables histogram-based gradient boosting estimators. |
|
Enables IterativeImputer |
sklearn.feature_extraction
: Feature Extraction¶
The sklearn.feature_extraction
module deals with feature extraction
from raw data. It currently includes methods to extract features from text and
images.
User guide: See the Feature extraction section for further details.
|
Transforms lists of feature-value mappings to vectors. |
Implements feature hashing, aka the hashing trick. |
From images¶
The sklearn.feature_extraction.image
submodule gathers utilities to
extract features from images.
Reshape a 2D image into a collection of patches |
|
|
Graph of the pixel-to-pixel connections |
|
Graph of the pixel-to-pixel gradient connections |
Reconstruct the image from all of its patches. |
|
Extracts patches from a collection of images |
From text¶
The sklearn.feature_extraction.text
submodule gathers utilities to
build feature vectors from text documents.
Convert a collection of text documents to a matrix of token counts |
|
Convert a collection of text documents to a matrix of token occurrences |
|
Transform a count matrix to a normalized tf or tf-idf representation |
|
Convert a collection of raw documents to a matrix of TF-IDF features. |
sklearn.feature_selection
: Feature Selection¶
The sklearn.feature_selection
module implements feature selection
algorithms. It currently includes univariate filter selection methods and the
recursive feature elimination algorithm.
User guide: See the Feature selection section for further details.
Univariate feature selector with configurable strategy. |
|
Select features according to a percentile of the highest scores. |
|
|
Select features according to the k highest scores. |
|
Filter: Select the pvalues below alpha based on a FPR test. |
|
Filter: Select the p-values for an estimated false discovery rate |
|
Meta-transformer for selecting features based on importance weights. |
|
Filter: Select the p-values corresponding to Family-wise error rate |
|
Feature ranking with recursive feature elimination. |
|
Feature ranking with recursive feature elimination and cross-validated selection of the best number of features. |
|
Feature selector that removes all low-variance features. |
|
Compute chi-squared stats between each non-negative feature and class. |
Compute the ANOVA F-value for the provided sample. |
|
|
Univariate linear regression tests. |
Estimate mutual information for a discrete target variable. |
|
Estimate mutual information for a continuous target variable. |
sklearn.gaussian_process
: Gaussian Processes¶
The sklearn.gaussian_process
module implements Gaussian Process
based regression and classification.
User guide: See the Gaussian Processes section for further details.
Gaussian process classification (GPC) based on Laplace approximation. |
|
Gaussian process regression (GPR). |
Kernels:
Kernel which is composed of a set of other kernels. |
|
Constant kernel. |
|
Dot-Product kernel. |
|
Exp-Sine-Squared kernel. |
|
Exponentiate kernel by given exponent. |
|
A kernel hyperparameter’s specification in form of a namedtuple. |
|
Base class for all kernels. |
|
Matern kernel. |
|
Wrapper for kernels in sklearn.metrics.pairwise. |
|
|
Product-kernel k1 * k2 of two kernels k1 and k2. |
|
Radial-basis function kernel (aka squared-exponential kernel). |
Rational Quadratic kernel. |
|
|
Sum-kernel k1 + k2 of two kernels k1 and k2. |
White kernel. |
sklearn.impute
: Impute¶
Transformers for missing value imputation
User guide: See the Imputation of missing values section for further details.
|
Imputation transformer for completing missing values. |
|
Multivariate imputer that estimates each feature from all the others. |
|
Binary indicators for missing values. |
|
Imputation for completing missing values using k-Nearest Neighbors. |
sklearn.inspection
: inspection¶
The sklearn.inspection
module includes tools for model inspection.
|
Partial dependence of |
|
Permutation importance for feature evaluation [Rd9e56ef97513-BRE]. |
sklearn.isotonic
: Isotonic regression¶
User guide: See the Isotonic regression section for further details.
|
Isotonic regression model. |
Determine whether y is monotonically correlated with x. |
|
|
Solve the isotonic regression model. |
sklearn.kernel_approximation
Kernel Approximation¶
The sklearn.kernel_approximation
module implements several
approximate kernel feature maps base on Fourier transforms.
User guide: See the Kernel Approximation section for further details.
Approximate feature map for additive chi2 kernel. |
|
|
Approximate a kernel map using a subset of the training data. |
|
Approximates feature map of an RBF kernel by Monte Carlo approximation of its Fourier transform. |
Approximates feature map of the “skewed chi-squared” kernel by Monte Carlo approximation of its Fourier transform. |
sklearn.kernel_ridge
Kernel Ridge Regression¶
Module sklearn.kernel_ridge
implements kernel ridge regression.
User guide: See the Kernel ridge regression section for further details.
|
Kernel ridge regression. |
sklearn.linear_model
: Generalized Linear Models¶
The sklearn.linear_model
module implements generalized linear models. It
includes Ridge regression, Bayesian Regression, Lasso and Elastic Net
estimators computed with Least Angle Regression and coordinate descent. It also
implements Stochastic Gradient Descent related algorithms.
User guide: See the Generalized Linear Models section for further details.
|
Bayesian ARD regression. |
|
Bayesian ridge regression. |
|
Linear regression with combined L1 and L2 priors as regularizer. |
|
Elastic Net model with iterative fitting along a regularization path. |
|
Linear regression model that is robust to outliers. |
|
Least Angle Regression model a.k.a. |
|
Cross-validated Least Angle Regression model. |
|
Linear Model trained with L1 prior as regularizer (aka the Lasso) |
|
Lasso linear model with iterative fitting along a regularization path. |
|
Lasso model fit with Least Angle Regression a.k.a. |
|
Cross-validated Lasso, using the LARS algorithm. |
|
Lasso model fit with Lars using BIC or AIC for model selection |
Ordinary least squares Linear Regression. |
|
|
Logistic Regression (aka logit, MaxEnt) classifier. |
|
Logistic Regression CV (aka logit, MaxEnt) classifier. |
|
Multi-task Lasso model trained with L1/L2 mixed-norm as regularizer. |
|
Multi-task ElasticNet model trained with L1/L2 mixed-norm as regularizer |
|
Multi-task Lasso model trained with L1/L2 mixed-norm as regularizer. |
Multi-task L1/L2 ElasticNet with built-in cross-validation. |
|
Orthogonal Matching Pursuit model (OMP) |
|
Cross-validated Orthogonal Matching Pursuit model (OMP). |
|
Passive Aggressive Classifier |
|
Passive Aggressive Regressor |
|
|
Read more in the User Guide. |
RANSAC (RANdom SAmple Consensus) algorithm. |
|
|
Linear least squares with l2 regularization. |
|
Classifier using Ridge regression. |
|
Ridge classifier with built-in cross-validation. |
|
Ridge regression with built-in cross-validation. |
|
Linear classifiers (SVM, logistic regression, a.o.) with SGD training. |
|
Linear model fitted by minimizing a regularized empirical loss with SGD |
Theil-Sen Estimator: robust multivariate regression model. |
|
Compute elastic net path with coordinate descent |
|
Compute Least Angle Regression or Lasso path using LARS algorithm [1] |
|
lars_path in the sufficient stats mode [1] |
|
Compute Lasso path with coordinate descent |
|
Orthogonal Matching Pursuit (OMP) |
|
Gram Orthogonal Matching Pursuit (OMP) |
|
Solve the ridge equation by the method of normal equations. |
sklearn.manifold
: Manifold Learning¶
The sklearn.manifold
module implements data embedding techniques.
User guide: See the Manifold learning section for further details.
|
Isomap Embedding |
Locally Linear Embedding |
|
|
Multidimensional scaling |
|
Spectral embedding for non-linear dimensionality reduction. |
|
t-distributed Stochastic Neighbor Embedding. |
|
Perform a Locally Linear Embedding analysis on the data. |
|
Computes multidimensional scaling using the SMACOF algorithm. |
|
Project the sample on the first eigenvectors of the graph Laplacian. |
|
Expresses to what extent the local structure is retained. |
sklearn.metrics
: Metrics¶
See the Model evaluation: quantifying the quality of predictions section and the Pairwise metrics, Affinities and Kernels section of the user guide for further details.
The sklearn.metrics
module includes score functions, performance metrics
and pairwise metrics and distance computations.
Model Selection Interface¶
See the The scoring parameter: defining model evaluation rules section of the user guide for further details.
|
Determine scorer from user options. |
|
Get a scorer from string |
|
Make a scorer from a performance metric or loss function. |
Classification metrics¶
See the Classification metrics section of the user guide for further details.
|
Accuracy classification score. |
|
Compute Area Under the Curve (AUC) using the trapezoidal rule |
|
Compute average precision (AP) from prediction scores |
|
Compute the balanced accuracy |
|
Compute the Brier score. |
|
Build a text report showing the main classification metrics |
|
Cohen’s kappa: a statistic that measures inter-annotator agreement. |
|
Compute confusion matrix to evaluate the accuracy of a classification |
|
Compute Discounted Cumulative Gain. |
|
Compute the F1 score, also known as balanced F-score or F-measure |
|
Compute the F-beta score |
|
Compute the average Hamming loss. |
|
Average hinge loss (non-regularized) |
|
Jaccard similarity coefficient score |
|
Log loss, aka logistic loss or cross-entropy loss. |
|
Compute the Matthews correlation coefficient (MCC) |
|
Compute a confusion matrix for each class or sample |
|
Compute Normalized Discounted Cumulative Gain. |
|
Compute precision-recall pairs for different probability thresholds |
Compute precision, recall, F-measure and support for each class |
|
|
Compute the precision |
|
Compute the recall |
|
Compute Area Under the Receiver Operating Characteristic Curve (ROC AUC) from prediction scores. |
|
Compute Receiver operating characteristic (ROC) |
|
Zero-one classification loss. |
Regression metrics¶
See the Regression metrics section of the user guide for further details.
|
Explained variance regression score function |
|
max_error metric calculates the maximum residual error. |
|
Mean absolute error regression loss |
|
Mean squared error regression loss |
|
Mean squared logarithmic error regression loss |
|
Median absolute error regression loss |
|
R^2 (coefficient of determination) regression score function. |
|
Mean Poisson deviance regression loss. |
|
Mean Gamma deviance regression loss. |
|
Mean Tweedie deviance regression loss. |
Multilabel ranking metrics¶
See the Multilabel ranking metrics section of the user guide for further details.
|
Coverage error measure |
Compute ranking-based average precision |
|
|
Compute Ranking loss measure |
Clustering metrics¶
See the Clustering performance evaluation section of the user guide for further details.
The sklearn.metrics.cluster
submodule contains evaluation metrics for
cluster analysis results. There are two forms of evaluation:
supervised, which uses a ground truth class values for each sample.
unsupervised, which does not and measures the ‘quality’ of the model itself.
Adjusted Mutual Information between two clusterings. |
|
|
Rand index adjusted for chance. |
|
Compute the Calinski and Harabasz score. |
|
Computes the Davies-Bouldin score. |
|
Completeness metric of a cluster labeling given a ground truth. |
Build a contingency matrix describing the relationship between labels. |
|
|
Measure the similarity of two clusterings of a set of points. |
Compute the homogeneity and completeness and V-Measure scores at once. |
|
|
Homogeneity metric of a cluster labeling given a ground truth. |
|
Mutual Information between two clusterings. |
Normalized Mutual Information between two clusterings. |
|
|
Compute the mean Silhouette Coefficient of all samples. |
|
Compute the Silhouette Coefficient for each sample. |
|
V-measure cluster labeling given a ground truth. |
Biclustering metrics¶
See the Biclustering evaluation section of the user guide for further details.
|
The similarity of two sets of biclusters. |
Pairwise metrics¶
See the Pairwise metrics, Affinities and Kernels section of the user guide for further details.
Computes the additive chi-squared kernel between observations in X and Y |
|
|
Computes the exponential chi-squared kernel X and Y. |
|
Compute cosine similarity between samples in X and Y. |
Compute cosine distance between samples in X and Y. |
|
Valid metrics for pairwise_distances. |
|
|
Considering the rows of X (and Y=X) as vectors, compute the distance matrix between each pair of vectors. |
Compute the Haversine distance between samples in X and Y |
|
Valid metrics for pairwise_kernels |
|
|
Compute the laplacian kernel between X and Y. |
|
Compute the linear kernel between X and Y. |
|
Compute the L1 distances between the vectors in X and Y. |
Calculate the euclidean distances in the presence of missing values. |
|
|
Compute the kernel between arrays X and optional array Y. |
|
Compute the polynomial kernel between X and Y. |
|
Compute the rbf (gaussian) kernel between X and Y. |
|
Compute the sigmoid kernel between X and Y. |
Computes the paired euclidean distances between X and Y |
|
Compute the L1 distances between the vectors in X and Y. |
|
Computes the paired cosine distances between X and Y |
|
|
Computes the paired distances between X and Y. |
|
Compute the distance matrix from a vector array X and optional Y. |
|
Compute minimum distances between one point and a set of points. |
Compute minimum distances between one point and a set of points. |
|
|
Generate a distance matrix chunk by chunk with optional reduction |
Plotting¶
See the Visualizations section of the user guide for further details.
|
Plot Receiver operating characteristic (ROC) curve. |
|
ROC Curve visualization. |
sklearn.mixture
: Gaussian Mixture Models¶
The sklearn.mixture
module implements mixture modeling algorithms.
User guide: See the Gaussian mixture models section for further details.
Variational Bayesian estimation of a Gaussian mixture. |
|
|
Gaussian Mixture. |
sklearn.model_selection
: Model Selection¶
User guide: See the Cross-validation: evaluating estimator performance, Tuning the hyper-parameters of an estimator and Learning curve sections for further details.
Splitter Classes¶
|
K-fold iterator variant with non-overlapping groups. |
Shuffle-Group(s)-Out cross-validation iterator |
|
|
K-Folds cross-validator |
Leave One Group Out cross-validator |
|
|
Leave P Group(s) Out cross-validator |
Leave-One-Out cross-validator |
|
Leave-P-Out cross-validator |
|
|
Predefined split cross-validator |
|
Repeated K-Fold cross validator. |
Repeated Stratified K-Fold cross validator. |
|
|
Random permutation cross-validator |
|
Stratified K-Folds cross-validator |
Stratified ShuffleSplit cross-validator |
|
|
Time Series cross-validator |
Splitter Functions¶
|
Input checker utility for building a cross-validator |
|
Split arrays or matrices into random train and test subsets |
Hyper-parameter optimizers¶
|
Exhaustive search over specified parameter values for an estimator. |
|
Grid of parameters with a discrete number of values for each. |
|
Generator on parameters sampled from given distributions. |
Randomized search on hyper parameters. |
|
Run fit on one set of parameters. |
Model validation¶
|
Evaluate metric(s) by cross-validation and also record fit/score times. |
|
Generate cross-validated estimates for each input data point |
|
Evaluate a score by cross-validation |
|
Learning curve. |
Evaluate the significance of a cross-validated score with permutations |
|
|
Validation curve. |
sklearn.multiclass
: Multiclass and multilabel classification¶
Multiclass and multilabel classification strategies¶
- This module implements multiclass learning algorithms:
one-vs-the-rest / one-vs-all
one-vs-one
error correcting output codes
The estimators provided in this module are meta-estimators: they require a base estimator to be provided in their constructor. For example, it is possible to use these estimators to turn a binary classifier or a regressor into a multiclass classifier. It is also possible to use these estimators with multiclass estimators in the hope that their accuracy or runtime performance improves.
All classifiers in scikit-learn implement multiclass classification; you only need to use this module if you want to experiment with custom multiclass strategies.
The one-vs-the-rest meta-classifier also implements a predict_proba
method,
so long as such a method is implemented by the base classifier. This method
returns probabilities of class membership in both the single label and
multilabel case. Note that in the multilabel case, probabilities are the
marginal probability that a given sample falls in the given class. As such, in
the multilabel case the sum of these probabilities over all possible labels
for a given sample will not sum to unity, as they do in the single label
case.
User guide: See the Multiclass and multilabel algorithms section for further details.
|
One-vs-the-rest (OvR) multiclass/multilabel strategy |
|
One-vs-one multiclass strategy |
|
(Error-Correcting) Output-Code multiclass strategy |
sklearn.multioutput
: Multioutput regression and classification¶
This module implements multioutput regression and classification.
The estimators provided in this module are meta-estimators: they require a base estimator to be provided in their constructor. The meta-estimator extends single output estimators to multioutput estimators.
User guide: See the Multiclass and multilabel algorithms section for further details.
|
A multi-label model that arranges binary classifiers into a chain. |
|
Multi target regression |
|
Multi target classification |
|
A multi-label model that arranges regressions into a chain. |
sklearn.naive_bayes
: Naive Bayes¶
The sklearn.naive_bayes
module implements Naive Bayes algorithms. These
are supervised learning methods based on applying Bayes’ theorem with strong
(naive) feature independence assumptions.
User guide: See the Naive Bayes section for further details.
|
Naive Bayes classifier for multivariate Bernoulli models. |
|
Naive Bayes classifier for categorical features |
|
The Complement Naive Bayes classifier described in Rennie et al. |
|
Gaussian Naive Bayes (GaussianNB) |
|
Naive Bayes classifier for multinomial models |
sklearn.neighbors
: Nearest Neighbors¶
The sklearn.neighbors
module implements the k-nearest neighbors
algorithm.
User guide: See the Nearest Neighbors section for further details.
BallTree for fast generalized N-point problems |
|
DistanceMetric class |
|
KDTree for fast generalized N-point problems |
|
|
Kernel Density Estimation |
Classifier implementing the k-nearest neighbors vote. |
|
|
Regression based on k-nearest neighbors. |
|
Transform X into a (weighted) graph of k nearest neighbors |
|
Unsupervised Outlier Detection using Local Outlier Factor (LOF) |
Classifier implementing a vote among neighbors within a given radius |
|
|
Regression based on neighbors within a fixed radius. |
|
Transform X into a (weighted) graph of neighbors nearer than a radius |
|
Nearest centroid classifier. |
|
Unsupervised learner for implementing neighbor searches. |
Neighborhood Components Analysis |
|
Computes the (weighted) graph of k-Neighbors for points in X |
|
Computes the (weighted) graph of Neighbors for points in X |
sklearn.neural_network
: Neural network models¶
The sklearn.neural_network
module includes models based on neural
networks.
User guide: See the Neural network models (supervised) and Neural network models (unsupervised) sections for further details.
|
Bernoulli Restricted Boltzmann Machine (RBM). |
Multi-layer Perceptron classifier. |
|
Multi-layer Perceptron regressor. |
sklearn.pipeline
: Pipeline¶
The sklearn.pipeline
module implements utilities to build a composite
estimator, as a chain of transforms and estimators.
|
Concatenates results of multiple transformer objects. |
|
Pipeline of transforms with a final estimator. |
|
Construct a Pipeline from the given estimators. |
|
Construct a FeatureUnion from the given transformers. |
sklearn.preprocessing
: Preprocessing and Normalization¶
The sklearn.preprocessing
module includes scaling, centering,
normalization, binarization methods.
User guide: See the Preprocessing data section for further details.
|
Binarize data (set feature values to 0 or 1) according to a threshold |
|
Constructs a transformer from an arbitrary callable. |
|
Bin continuous data into intervals. |
Center a kernel matrix |
|
|
Binarize labels in a one-vs-all fashion |
Encode target labels with value between 0 and n_classes-1. |
|
|
Transform between iterable of iterables and a multilabel format |
|
Scale each feature by its maximum absolute value. |
|
Transforms features by scaling each feature to a given range. |
|
Normalize samples individually to unit norm. |
|
Encode categorical features as a one-hot numeric array. |
|
Encode categorical features as an integer array. |
|
Generate polynomial and interaction features. |
|
Apply a power transform featurewise to make data more Gaussian-like. |
Transform features using quantiles information. |
|
|
Scale features using statistics that are robust to outliers. |
|
Standardize features by removing the mean and scaling to unit variance |
|
Augment dataset with an additional dummy feature. |
|
Boolean thresholding of array-like or scipy.sparse matrix |
|
Binarize labels in a one-vs-all fashion |
|
Scale each feature to the [-1, 1] range without breaking the sparsity. |
|
Transforms features by scaling each feature to a given range. |
|
Scale input vectors individually to unit norm (vector length). |
|
Transform features using quantiles information. |
|
Standardize a dataset along any axis |
|
Standardize a dataset along any axis |
|
Power transforms are a family of parametric, monotonic transformations that are applied to make data more Gaussian-like. |
sklearn.random_projection
: Random projection¶
Random Projection transformers
Random Projections are a simple and computationally efficient way to reduce the dimensionality of the data by trading a controlled amount of accuracy (as additional variance) for faster processing times and smaller model sizes.
The dimensions and distribution of Random Projections matrices are controlled so as to preserve the pairwise distances between any two samples of the dataset.
The main theoretical result behind the efficiency of random projection is the Johnson-Lindenstrauss lemma (quoting Wikipedia):
In mathematics, the Johnson-Lindenstrauss lemma is a result concerning low-distortion embeddings of points from high-dimensional into low-dimensional Euclidean space. The lemma states that a small set of points in a high-dimensional space can be embedded into a space of much lower dimension in such a way that distances between the points are nearly preserved. The map used for the embedding is at least Lipschitz, and can even be taken to be an orthogonal projection.
User guide: See the Random Projection section for further details.
Reduce dimensionality through Gaussian random projection |
|
Reduce dimensionality through sparse random projection |
Find a ‘safe’ number of components to randomly project to |
sklearn.semi_supervised
Semi-Supervised Learning¶
The sklearn.semi_supervised
module implements semi-supervised learning
algorithms. These algorithms utilized small amounts of labeled data and large
amounts of unlabeled data for classification tasks. This module includes Label
Propagation.
User guide: See the Semi-Supervised section for further details.
|
Label Propagation classifier |
|
LabelSpreading model for semi-supervised learning |
sklearn.svm
: Support Vector Machines¶
The sklearn.svm
module includes Support Vector Machine algorithms.
User guide: See the Support Vector Machines section for further details.
Estimators¶
|
Linear Support Vector Classification. |
|
Linear Support Vector Regression. |
|
Nu-Support Vector Classification. |
|
Nu Support Vector Regression. |
|
Unsupervised Outlier Detection. |
|
C-Support Vector Classification. |
|
Epsilon-Support Vector Regression. |
|
Return the lowest bound for C such that for C in (l1_min_C, infinity) the model is guaranteed not to be empty. |
Low-level methods¶
Binding of the cross-validation routine (low-level routine) |
|
Predict margin (libsvm name for this is predict_values) |
|
Train the model using libsvm (low-level method) |
|
Predict target values of X given a model (low-level method) |
|
Predict probabilities |
sklearn.tree
: Decision Trees¶
The sklearn.tree
module includes decision tree-based models for
classification and regression.
User guide: See the Decision Trees section for further details.
|
A decision tree classifier. |
|
A decision tree regressor. |
|
An extremely randomized tree classifier. |
|
An extremely randomized tree regressor. |
|
Export a decision tree in DOT format. |
|
Build a text report showing the rules of a decision tree. |
Plotting¶
|
Plot a decision tree. |
sklearn.utils
: Utilities¶
The sklearn.utils
module includes various utilities.
Developer guide: See the Utilities for Developers page for further details.
|
|
Find the minimum value of an array over positive values |
|
|
Converts an array-like to an array of floats. |
|
Throw a ValueError if X contains NaN or infinity. |
|
Input validation for standard estimators. |
|
Input validation on an array, list, sparse matrix or similar. |
|
Validate scalar parameters type and value. |
|
Check that all arrays have consistent first dimensions. |
|
Turn seed into a np.random.RandomState instance |
Estimate class weights for unbalanced datasets. |
|
Estimate sample weights by class for unbalanced datasets. |
|
|
Decorator to mark a function or class as deprecated. |
|
Check if estimator adheres to scikit-learn conventions. |
Pytest specific decorator for parametrizing estimator checks. |
|
|
Dot product that handle the sparse matrix case correctly |
Computes an orthonormal matrix whose range approximates the range of A. |
|
|
Computes a truncated randomized SVD |
Compute log(det(A)) for A symmetric |
|
|
Compute density of a sparse vector |
|
Returns an array of the weighted modal (most common) value in a |
|
Generator to create n_packs slices going up to n. |
Return the shortest path length from source to all reachable nodes. |
|
Perform a shortest-path graph search on a positive directed or undirected graph. |
|
|
Make arrays indexable for cross-validation. |
Create a decorator for methods that are delegated to a sub-estimator |
|
Determine the type of data indicated by the target. |
|
Check if |
|
Extract an ordered array of unique labels |
|
Compute the 32bit murmurhash3 of key at seed. |
|
|
Resample arrays or sparse matrices in a consistent way |
|
Return rows, items or columns of X using indices. |
|
Return a mask which is safe to use on X. |
|
Element wise squaring of array-likes and sparse matrices. |
|
Shuffle arrays or sparse matrices in a consistent way |
Compute incremental mean and variance along an axix on a CSR or CSC matrix. |
|
|
Inplace column scaling of a CSC/CSR matrix. |
|
Inplace row scaling of a CSR or CSC matrix. |
|
Swaps two rows of a CSC/CSR matrix in-place. |
Swaps two columns of a CSC/CSR matrix in-place. |
|
|
Compute mean and variance along an axix on a CSR or CSC matrix |
Inplace column scaling of a CSR matrix. |
|
Inplace row normalize using the l1 norm |
|
Inplace row normalize using the l2 norm |
|
Sample integers without replacement. |
|
|
Perform is_fitted validation for estimator. |
|
Check that |
|
Make sure that array is 2D, square and symmetric. |
|
Ravel column or 1d numpy array, else raises an error |
Checks whether the estimator’s fit method supports the given parameter. |
|
|
DEPRECATED: This helper is deprecated in version 0.22 and will be removed in version 0.24. |
|
DEPRECATED: This helper is deprecated in version 0.22 and will be removed in version 0.24. |
Helper function to test the message raised in an exception. |
|
Get a list of all estimators from sklearn. |
Utilities from joblib:
|
Change the default backend used by Parallel inside a with block. |
|
Register a new Parallel backend factory. |
Recently deprecated¶
To be removed in 0.23¶
|
|
|
Methods |
DEPRECATED: deprecated in version 0.20.1 to be removed in version 0.23. |
|
|
DEPRECATED: deprecated in version 0.20.1 to be removed in version 0.23. |
|
DEPRECATED: Function ‘calinski_harabaz_score’ has been renamed to ‘calinski_harabasz_score’ and will be removed in version 0.23. |
|
Jaccard similarity coefficient score |
DEPRECATED: logistic_regression_path was deprecated in version 0.21 and will be removed in version 0.23.0 |
DEPRECATED: The function ensemble.partial_dependence has been deprecated in favour of inspection.partial_dependence in 0.21 and will be removed in 0.23. |
|
DEPRECATED: The function ensemble.plot_partial_dependence has been deprecated in favour of sklearn.inspection.plot_partial_dependence in 0.21 and will be removed in 0.23. |