Multivariate imputer that estimates each feature from all the others.
A strategy for imputing missing values by modeling each feature with missing values as a function of other features in a round-robin fashion.
Read more in the User Guide.
New in version 0.21.
Note
This estimator is still experimental for now: the predictions and the API might change without any deprecation cycle. To use it, you need to explicitly import enable_iterative_imputer:
The estimator to use at each step of the round-robin imputation. If sample_posterior is True, the estimator must support return_std in its predict method.
The placeholder for the missing values. All occurrences of missing_values will be imputed. For pandas’ dataframes with nullable integer dtypes with missing values, missing_values should be set to np.nan, since pd.NA will be converted to np.nan.
Whether to sample from the (Gaussian) predictive posterior of the fitted estimator for each imputation. Estimator must support return_std in its predict method if set to True. Set to True if using IterativeImputer for multiple imputations.
Maximum number of imputation rounds to perform before returning the imputations computed during the final round. A round is a single imputation of each feature with missing values. The stopping criterion is met once max(abs(X_t - X_{t-1}))/max(abs(X[known_vals])) < tol, where X_t is X at iteration t. Note that early stopping is only
applied if ``sample_posterior=False`.
Tolerance of the stopping condition.
Number of other features to use to estimate the missing values of each feature column. Nearness between features is measured using the absolute correlation coefficient between each feature pair (after initial imputation). To ensure coverage of features throughout the imputation process, the neighbor features are not necessarily nearest, but are drawn with probability proportional to correlation for each imputed target feature. Can provide significant speed-up when the number of features is huge. If None, all features will be used.
Which strategy to use to initialize the missing values. Same as the strategy parameter in SimpleImputer Valid values: {“mean”, “median”, “most_frequent”, or “constant”}.
The order in which the features will be imputed. Possible values:
From features with fewest missing values to most.
From features with most missing values to fewest.
Left to right.
Right to left.
A random order for each round.
If True then features with missing values during transform which did not have any missing values during fit will be imputed with the initial imputation method only. Set to True if you have many features with no missing values at both fit and transform time to save compute.
Minimum possible imputed value. Broadcast to shape (n_features,) if scalar. If array-like, expects shape (n_features,), one min value for each feature. The default is -np.inf.
Changed in version 0.23: Added support for array-like.
Maximum possible imputed value. Broadcast to shape (n_features,) if scalar. If array-like, expects shape (n_features,), one max value for each feature. The default is np.inf.
Changed in version 0.23: Added support for array-like.
Verbosity flag, controls the debug messages that are issued as functions are evaluated. The higher, the more verbose. Can be 0, 1, or 2.
The seed of the pseudo random number generator to use. Randomizes selection of estimator features if n_nearest_features is not None, the imputation_order if random, and the sampling from posterior if sample_posterior is True. Use an integer for determinism. See the Glossary.
If True, a MissingIndicator transform will stack onto output of the imputer’s transform. This allows a predictive estimator to account for missingness despite imputation. If a feature has no missing values at fit/train time, the feature won’t appear on the missing indicator even if there are missing values at transform/test time.
Imputer used to initialize the missing values.
Each tuple has (feat_idx, neighbor_feat_idx, estimator), where feat_idx is the current feature to be imputed, neighbor_feat_idx is the array of other features used to impute the current feature, and estimator is the trained estimator used for the imputation. Length is self.n_features_with_missing_ *
self.n_iter_.
Number of iteration rounds that occurred. Will be less than self.max_iter if early stopping criterion was reached.
Number of features with missing values.
Indicator used to add binary indicators for missing values. None if add_indicator is False.
RandomState instance that is generated either from a seed, the random number generator or by np.random.
See also
Univariate imputation of missing values.
To support imputation in inductive mode we store each feature’s estimator during the fit phase, and predict without refitting (in order) during the transform phase.
Features which contain all missing values at fit are discarded upon transform.
Stef van Buuren, Karin Groothuis-Oudshoorn (2011). “mice: Multivariate Imputation by Chained Equations in R”. Journal of Statistical Software 45: 1-67.
S. F. Buck, (1960). “A Method of Estimation of Missing Values in Multivariate Data Suitable for use with an Electronic Computer”. Journal of the Royal Statistical Society 22(2): 302-306.
fit(X[, y])
Fits the imputer on X and return self.
fit_transform(X[, y])
Fits the imputer on X and return the transformed X.
get_params([deep])
Get parameters for this estimator.
set_params(**params)
Set the parameters of this estimator.
transform(X)
Imputes all missing values in X.
Fits the imputer on X and return self.
Input data, where “n_samples” is the number of samples and “n_features” is the number of features.
Returns self.
Fits the imputer on X and return the transformed X.
Input data, where “n_samples” is the number of samples and “n_features” is the number of features.
The imputed input 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.
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.
Imputes all missing values in X.
Note that this is stochastic, and that if random_state is not fixed, repeated calls, or permuted input, will yield different results.
The input data to complete.
The imputed input data.
Imputing missing values with variants of IterativeImputer
Imputing missing values before building an estimator


Fits the imputer on X and return self.
Input data, where “n_samples” is the number of samples and “n_features” is the number of features.
Returns self.


Fits the imputer on X and return the transformed X.
Input data, where “n_samples” is the number of samples and “n_features” is the number of features.
The imputed input 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.


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.


Imputes all missing values in X.
Note that this is stochastic, and that if random_state is not fixed, repeated calls, or permuted input, will yield different results.
The input data to complete.
The imputed input data.


Imputation for completing missing values using k-Nearest Neighbors.
Each sample’s missing values are imputed using the mean value from n_neighbors nearest neighbors found in the training set. Two samples are close if the features that neither is missing are close.
Read more in the User Guide.
New in version 0.22.
The placeholder for the missing values. All occurrences of missing_values will be imputed. For pandas’ dataframes with nullable integer dtypes with missing values, missing_values should be set to np.nan, since pd.NA will be converted to np.nan.
Number of neighboring samples to use for imputation.
Weight function used in prediction. Possible values:
Distance metric for searching neighbors. Possible values:
If True, a copy of X will be created. If False, imputation will be done in-place whenever possible.
If True, a MissingIndicator transform will stack onto the output of the imputer’s transform. This allows a predictive estimator to account for missingness despite imputation. If a feature has no missing values at fit/train time, the feature won’t appear on the missing indicator even if there are missing values at transform/test time.
Indicator used to add binary indicators for missing values. None if add_indicator is False.
fit(X[, y])
Fit the imputer on 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)
Impute all missing values in X.
Fit the imputer on X.
Input data, where n_samples is the number of samples and n_features is the number of features.
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.
Impute all missing values in X.
The input data to complete.
The imputed dataset. n_output_features is the number of features that is not always missing during fit.


Imputation for completing missing values using k-Nearest Neighbors.
Each sample’s missing values are imputed using the mean value from n_neighbors nearest neighbors found in the training set. Two samples are close if the features that neither is missing are close.
Read more in the User Guide.
New in version 0.22.
The placeholder for the missing values. All occurrences of missing_values will be imputed. For pandas’ dataframes with nullable integer dtypes with missing values, missing_values should be set to np.nan, since pd.NA will be converted to np.nan.
Number of neighboring samples to use for imputation.
Weight function used in prediction. Possible values:
Distance metric for searching neighbors. Possible values:
If True, a copy of X will be created. If False, imputation will be done in-place whenever possible.
If True, a MissingIndicator transform will stack onto the output of the imputer’s transform. This allows a predictive estimator to account for missingness despite imputation. If a feature has no missing values at fit/train time, the feature won’t appear on the missing indicator even if there are missing values at transform/test time.
Indicator used to add binary indicators for missing values. None if add_indicator is False.
fit(X[, y])
Fit the imputer on 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)
Impute all missing values in X.
Fit the imputer on X.
Input data, where n_samples is the number of samples and n_features is the number of features.
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.
Impute all missing values in X.
The input data to complete.
The imputed dataset. n_output_features is the number of features that is not always missing during fit.
Release Highlights for scikit-learn 0.22
Imputing missing values before building an estimator


Fit the imputer on X.
Input data, where n_samples is the number of samples and n_features is the number of features.


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.


Impute all missing values in X.
The input data to complete.
The imputed dataset. n_output_features is the number of features that is not always missing during fit.


Binary indicators for missing values.
Note that this component typically should not be used in a vanilla Pipeline consisting of transformers and a classifier, but rather could be added using a FeatureUnion or ColumnTransformer.
Read more in the User Guide.
New in version 0.20.
The placeholder for the missing values. All occurrences of missing_values will be imputed. For pandas’ dataframes with nullable integer dtypes with missing values, missing_values should be set to np.nan, since pd.NA will be converted to np.nan.
Whether the imputer mask should represent all or a subset of features.
Whether the imputer mask format should be sparse or dense.
If True, transform will raise an error when there are features with missing values in transform that have no missing values in fit. This is applicable only when features='missing-only'.
The features indices which will be returned when calling transform. They are computed during fit. For features='all', it is to range(n_features).
fit(X[, y])
Fit the transformer on X.
fit_transform(X[, y])
Generate missing values indicator for X.
get_params([deep])
Get parameters for this estimator.
set_params(**params)
Set the parameters of this estimator.
transform(X)
Generate missing values indicator for X.
Fit the transformer on X.
Input data, where n_samples is the number of samples and n_features is the number of features.
Returns self.
Generate missing values indicator for X.
The input data to complete.
The missing indicator for input data. The data type of Xt will be boolean.
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.
Generate missing values indicator for X.
The input data to complete.
The missing indicator for input data. The data type of Xt will be boolean.


Fit the transformer on X.
Input data, where n_samples is the number of samples and n_features is the number of features.
Returns self.


Generate missing values indicator for X.
The input data to complete.
The missing indicator for input data. The data type of Xt will be boolean.


Imputation transformer for completing missing values.
Read more in the User Guide.
New in version 0.20: SimpleImputer replaces the previous sklearn.preprocessing.Imputer estimator which is now removed.
The placeholder for the missing values. All occurrences of missing_values will be imputed. For pandas’ dataframes with nullable integer dtypes with missing values, missing_values should be set to np.nan, since pd.NA will be converted to np.nan.
The imputation strategy.
New in version 0.20: strategy=”constant” for fixed value imputation.
When strategy == “constant”, fill_value is used to replace all occurrences of missing_values. If left to the default, fill_value will be 0 when imputing numerical data and “missing_value” for strings or object data types.
Controls the verbosity of the imputer.
If True, a copy of X will be created. If False, imputation will be done in-place whenever possible. Note that, in the following cases, a new copy will always be made, even if copy=False:
If True, a MissingIndicator transform will stack onto output of the imputer’s transform. This allows a predictive estimator to account for missingness despite imputation. If a feature has no missing values at fit/train time, the feature won’t appear on the missing indicator even if there are missing values at transform/test time.
The imputation fill value for each feature. Computing statistics can result in np.nan values. During transform, features corresponding to np.nan statistics will be discarded.
Indicator used to add binary indicators for missing values. None if add_indicator is False.
See also
Multivariate imputation of missing values.
Columns which only contained missing values at fit are discarded upon transform if strategy is not “constant”.
fit(X[, y])
Fit the imputer on X.
fit_transform(X[, y])
Fit to data, then transform it.
get_params([deep])
Get parameters for this estimator.
inverse_transform(X)
Convert the data back to the original representation.
set_params(**params)
Set the parameters of this estimator.
transform(X)
Impute all missing values in X.
Fit the imputer on X.
Input data, where n_samples is the number of samples and n_features is the number of features.
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.
Convert the data back to the original representation.
Inverts the transform operation performed on an array. This operation can only be performed after SimpleImputer is instantiated with add_indicator=True.
Note that inverse_transform can only invert the transform in features that have binary indicators for missing values. If a feature has no missing values at fit time, the feature won’t have a binary indicator, and the imputation done at transform time won’t be inverted.
New in version 0.24.
The imputed data to be reverted to original data. It has to be an augmented array of imputed data and the missing indicator mask.
The original X with missing values as it was prior to imputation.
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.
Impute all missing values in X.
The input data to complete.


Imputation transformer for completing missing values.
Read more in the User Guide.
New in version 0.20: SimpleImputer replaces the previous sklearn.preprocessing.Imputer estimator which is now removed.
The placeholder for the missing values. All occurrences of missing_values will be imputed. For pandas’ dataframes with nullable integer dtypes with missing values, missing_values should be set to np.nan, since pd.NA will be converted to np.nan.
The imputation strategy.
New in version 0.20: strategy=”constant” for fixed value imputation.
When strategy == “constant”, fill_value is used to replace all occurrences of missing_values. If left to the default, fill_value will be 0 when imputing numerical data and “missing_value” for strings or object data types.
Controls the verbosity of the imputer.
If True, a copy of X will be created. If False, imputation will be done in-place whenever possible. Note that, in the following cases, a new copy will always be made, even if copy=False:
If True, a MissingIndicator transform will stack onto output of the imputer’s transform. This allows a predictive estimator to account for missingness despite imputation. If a feature has no missing values at fit/train time, the feature won’t appear on the missing indicator even if there are missing values at transform/test time.
The imputation fill value for each feature. Computing statistics can result in np.nan values. During transform, features corresponding to np.nan statistics will be discarded.
Indicator used to add binary indicators for missing values. None if add_indicator is False.
See also
Multivariate imputation of missing values.
Columns which only contained missing values at fit are discarded upon transform if strategy is not “constant”.
fit(X[, y])
Fit the imputer on X.
fit_transform(X[, y])
Fit to data, then transform it.
get_params([deep])
Get parameters for this estimator.
inverse_transform(X)
Convert the data back to the original representation.
set_params(**params)
Set the parameters of this estimator.
transform(X)
Impute all missing values in X.
Fit the imputer on X.
Input data, where n_samples is the number of samples and n_features is the number of features.
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.
Convert the data back to the original representation.
Inverts the transform operation performed on an array. This operation can only be performed after SimpleImputer is instantiated with add_indicator=True.
Note that inverse_transform can only invert the transform in features that have binary indicators for missing values. If a feature has no missing values at fit time, the feature won’t have a binary indicator, and the imputation done at transform time won’t be inverted.
New in version 0.24.
The imputed data to be reverted to original data. It has to be an augmented array of imputed data and the missing indicator mask.
The original X with missing values as it was prior to imputation.
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.
Impute all missing values in X.
The input data to complete.
Release Highlights for scikit-learn 0.23
Combine predictors using stacking
Permutation Importance vs Random Forest Feature Importance (MDI)
Imputing missing values with variants of IterativeImputer
Imputing missing values before building an estimator
Column Transformer with Mixed Types


Convert the data back to the original representation.
Inverts the transform operation performed on an array. This operation can only be performed after SimpleImputer is instantiated with add_indicator=True.
Note that inverse_transform can only invert the transform in features that have binary indicators for missing values. If a feature has no missing values at fit time, the feature won’t have a binary indicator, and the imputation done at transform time won’t be inverted.
New in version 0.24.
The imputed data to be reverted to original data. It has to be an augmented array of imputed data and the missing indicator mask.
The original X with missing values as it was prior to imputation.


Impute all missing values in X.
The input data to complete.


Partial Dependence Plot (PDP).
This can also display individual partial dependencies which are often referred to as: Individual Condition Expectation (ICE).
It is recommended to use plot_partial_dependence to create a PartialDependenceDisplay. All parameters are stored as attributes.
Read more in Advanced Plotting With Partial Dependence and the User Guide.
New in version 0.22.
Results of partial_dependence for features.
Indices of features for a given plot. A tuple of one integer will plot a partial dependence curve of one feature. A tuple of two integers will plot a two-way partial dependence curve as a contour plot.
Feature names corresponding to the indices in features.
Ignored in binary classification or classical regression settings.
Global min and max average predictions, such that all plots will have the same scale and y limits. pdp_lim[1] is the global min and max for single partial dependence curves. pdp_lim[2] is the global min and max for two-way partial dependence curves.
Deciles for feature indices in features.
Whether to plot the partial dependence averaged across all the samples in the dataset or one line per sample or both.
Note that the fast method='recursion' option is only available for kind='average'. Plotting individual dependencies requires using the slower method='brute' option.
New in version 0.24.
Sampling for ICE curves when kind is ‘individual’ or ‘both’. If float, should be between 0.0 and 1.0 and represent the proportion of the dataset to be used to plot ICE curves. If int, represents the maximum absolute number of samples to use.
Note that the full dataset is still used to calculate partial dependence when kind='both'.
New in version 0.24.
Controls the randomness of the selected samples when subsamples is not None. See Glossary for details.
New in version 0.24.
If ax is an axes or None, the bounding_ax_ is the axes where the grid of partial dependence plots are drawn. If ax is a list of axes or a numpy array of axes, bounding_ax_ is None.
If ax is an axes or None, axes_[i, j] is the axes on the i-th row and j-th column. If ax is a list of axes, axes_[i] is the i-th item in ax. Elements that are None correspond to a nonexisting axes in that position.
If ax is an axes or None, lines_[i, j] is the partial dependence curve on the i-th row and j-th column. If ax is a list of axes, lines_[i] is the partial dependence curve corresponding to the i-th item in ax. Elements that are None correspond to a nonexisting axes or an axes that does not include a line plot.
If ax is an axes or None, vlines_[i, j] is the line collection representing the x axis deciles of the i-th row and j-th column. If ax is a list of axes, vlines_[i] corresponds to the i-th item in ax. Elements that are None correspond to a nonexisting axes or an axes that does not include a PDP plot.
New in version 0.23.
If ax is an axes or None, vlines_[i, j] is the line collection representing the y axis deciles of the i-th row and j-th column. If ax is a list of axes, vlines_[i] corresponds to the i-th item in ax. Elements that are None correspond to a nonexisting axes or an axes that does not include a 2-way plot.
New in version 0.23.
If ax is an axes or None, contours_[i, j] is the partial dependence plot on the i-th row and j-th column. If ax is a list of axes, contours_[i] is the partial dependence plot corresponding to the i-th item in ax. Elements that are None correspond to a nonexisting axes or an axes that does not include a contour plot.
Figure containing partial dependence plots.
See also
Compute Partial Dependence values.
Plot Partial Dependence.
plot(*[, ax, n_cols, line_kw, contour_kw])
Plot partial dependence plots.
Plot partial dependence plots.
and a grid of partial dependence plots will be drawn within these bounds. The n_cols parameter controls the number of columns in the grid.
plots will be drawn directly into these axes.
as the single axes case.
The maximum number of columns in the grid plot. Only active when ax is a single axes or None.
Dict with keywords passed to the matplotlib.pyplot.plot call. For one-way partial dependence plots.
Dict with keywords passed to the matplotlib.pyplot.contourf call for two-way partial dependence plots.


Partial Dependence Plot (PDP).
This can also display individual partial dependencies which are often referred to as: Individual Condition Expectation (ICE).
It is recommended to use plot_partial_dependence to create a PartialDependenceDisplay. All parameters are stored as attributes.
Read more in Advanced Plotting With Partial Dependence and the User Guide.
New in version 0.22.
Results of partial_dependence for features.
Indices of features for a given plot. A tuple of one integer will plot a partial dependence curve of one feature. A tuple of two integers will plot a two-way partial dependence curve as a contour plot.
Feature names corresponding to the indices in features.
Ignored in binary classification or classical regression settings.
Global min and max average predictions, such that all plots will have the same scale and y limits. pdp_lim[1] is the global min and max for single partial dependence curves. pdp_lim[2] is the global min and max for two-way partial dependence curves.
Deciles for feature indices in features.
Whether to plot the partial dependence averaged across all the samples in the dataset or one line per sample or both.
Note that the fast method='recursion' option is only available for kind='average'. Plotting individual dependencies requires using the slower method='brute' option.
New in version 0.24.
Sampling for ICE curves when kind is ‘individual’ or ‘both’. If float, should be between 0.0 and 1.0 and represent the proportion of the dataset to be used to plot ICE curves. If int, represents the maximum absolute number of samples to use.
Note that the full dataset is still used to calculate partial dependence when kind='both'.
New in version 0.24.
Controls the randomness of the selected samples when subsamples is not None. See Glossary for details.
New in version 0.24.
If ax is an axes or None, the bounding_ax_ is the axes where the grid of partial dependence plots are drawn. If ax is a list of axes or a numpy array of axes, bounding_ax_ is None.
If ax is an axes or None, axes_[i, j] is the axes on the i-th row and j-th column. If ax is a list of axes, axes_[i] is the i-th item in ax. Elements that are None correspond to a nonexisting axes in that position.
If ax is an axes or None, lines_[i, j] is the partial dependence curve on the i-th row and j-th column. If ax is a list of axes, lines_[i] is the partial dependence curve corresponding to the i-th item in ax. Elements that are None correspond to a nonexisting axes or an axes that does not include a line plot.
If ax is an axes or None, vlines_[i, j] is the line collection representing the x axis deciles of the i-th row and j-th column. If ax is a list of axes, vlines_[i] corresponds to the i-th item in ax. Elements that are None correspond to a nonexisting axes or an axes that does not include a PDP plot.
New in version 0.23.
If ax is an axes or None, vlines_[i, j] is the line collection representing the y axis deciles of the i-th row and j-th column. If ax is a list of axes, vlines_[i] corresponds to the i-th item in ax. Elements that are None correspond to a nonexisting axes or an axes that does not include a 2-way plot.
New in version 0.23.
If ax is an axes or None, contours_[i, j] is the partial dependence plot on the i-th row and j-th column. If ax is a list of axes, contours_[i] is the partial dependence plot corresponding to the i-th item in ax. Elements that are None correspond to a nonexisting axes or an axes that does not include a contour plot.
Figure containing partial dependence plots.
See also
Compute Partial Dependence values.
Plot Partial Dependence.
plot(*[, ax, n_cols, line_kw, contour_kw])
Plot partial dependence plots.
Plot partial dependence plots.
and a grid of partial dependence plots will be drawn within these bounds. The n_cols parameter controls the number of columns in the grid.
plots will be drawn directly into these axes.
as the single axes case.
The maximum number of columns in the grid plot. Only active when ax is a single axes or None.
Dict with keywords passed to the matplotlib.pyplot.plot call. For one-way partial dependence plots.
Dict with keywords passed to the matplotlib.pyplot.contourf call for two-way partial dependence plots.
Advanced Plotting With Partial Dependence


Plot partial dependence plots.
and a grid of partial dependence plots will be drawn within these bounds. The n_cols parameter controls the number of columns in the grid.
plots will be drawn directly into these axes.
as the single axes case.
The maximum number of columns in the grid plot. Only active when ax is a single axes or None.
Dict with keywords passed to the matplotlib.pyplot.plot call. For one-way partial dependence plots.
Dict with keywords passed to the matplotlib.pyplot.contourf call for two-way partial dependence plots.


Partial dependence of features.
Partial dependence of a feature (or a set of features) corresponds to the average response of an estimator for each possible value of the feature.
Read more in the User Guide.
Warning
For GradientBoostingClassifier and GradientBoostingRegressor, the 'recursion' method (used by default) will not account for the init predictor of the boosting process. In practice, this will produce the same values as 'brute' up to a constant offset in the target response, provided that init is a constant estimator (which is the default). However, if init is not a constant estimator, the partial dependence values are incorrect for 'recursion' because the offset will be sample-dependent. It is preferable to use the 'brute' method. Note that this only applies to GradientBoostingClassifier and GradientBoostingRegressor, not to HistGradientBoostingClassifier and HistGradientBoostingRegressor.
A fitted estimator object implementing predict, predict_proba, or decision_function. Multioutput-multiclass classifiers are not supported.
X is used to generate a grid of values for the target features (where the partial dependence will be evaluated), and also to generate values for the complement features when the method is ‘brute’.
The feature (e.g. [0]) or pair of interacting features (e.g. [(0, 1)]) for which the partial dependency should be computed.
Specifies whether to use predict_proba or decision_function as the target response. For regressors this parameter is ignored and the response is always the output of predict. By default, predict_proba is tried first and we revert to decision_function if it doesn’t exist. If method is ‘recursion’, the response is always the output of decision_function.
The lower and upper percentile used to create the extreme values for the grid. Must be in [0, 1].
The number of equally spaced points on the grid, for each target feature.
The method used to calculate the averaged predictions:
Please see this note for differences between the 'brute' and 'recursion' method.
Whether to return the partial dependence averaged across all the samples in the dataset or one line per sample or both. See Returns below.
Note that the fast method='recursion' option is only available for kind='average'. Plotting individual dependencies requires using the slower method='brute' option.
New in version 0.24.
Deprecated since version 0.24: kind='legacy' is deprecated and will be removed in version 1.1. kind='average' will be the new default. It is intended to migrate from the ndarray output to Bunch output.
The predictions for all the points in the grid, averaged over all samples in X (or over the training data if method is ‘recursion’).
Dictionary-like object, with the following attributes.
The predictions for all the points in the grid for all samples in X. This is also known as Individual Conditional Expectation (ICE)
The predictions for all the points in the grid, averaged over all samples in X (or over the training data if method is ‘recursion’). Only available when kind=’both’.
The values with which the grid has been created. The generated grid is a cartesian product of the arrays in values. len(values) == len(features). The size of each array values[j] is either grid_resolution, or the number of unique values in X[:, j], whichever is smaller.
n_outputs corresponds to the number of classes in a multi-class setting, or to the number of tasks for multi-output regression. For classical regression and binary classification n_outputs==1. n_values_feature_j corresponds to the size values[j].
The values with which the grid has been created. The generated grid is a cartesian product of the arrays in values. len(values) ==
len(features). The size of each array values[j] is either grid_resolution, or the number of unique values in X[:, j], whichever is smaller. Only available when kind="legacy".
See also
Plot Partial Dependence.
Partial Dependence visualization.


Permutation importance for feature evaluation [BRE].
The estimator is required to be a fitted estimator. X can be the data set used to train the estimator or a hold-out set. The permutation importance of a feature is calculated as follows. First, a baseline metric, defined by scoring, is evaluated on a (potentially different) dataset defined by the X. Next, a feature column from the validation set is permuted and the metric is evaluated again. The permutation importance is defined to be the difference between the baseline metric and metric from permutating the feature column.
Read more in the User Guide.
An estimator that has already been fitted and is compatible with scorer.
Data on which permutation importance will be computed.
Targets for supervised or None for unsupervised.
Scorer to use. It can be a single string (see The scoring parameter: defining model evaluation rules) or a callable (see Defining your scoring strategy from metric functions). If None, the estimator’s default scorer is used.
Number of times to permute a feature.
Number of jobs to run in parallel. The computation is done by computing permutation score for each columns and parallelized over the columns. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors. See Glossary for more details.
Pseudo-random number generator to control the permutations of each feature. Pass an int to get reproducible results across function calls. See :term: Glossary <random_state>.
Sample weights used in scoring.
New in version 0.24.
Dictionary-like object, with the following attributes.
Mean of feature importance over n_repeats.
Standard deviation over n_repeats.
Raw permutation importance scores.
L. Breiman, “Random Forests”, Machine Learning, 45(1), 5-32, 2001. https://doi.org/10.1023/A:1010933404324


Partial dependence (PD) and individual conditional expectation (ICE) plots.
Partial dependence plots, individual conditional expectation plots or an overlay of both of them can be plotted by setting the kind parameter. The len(features) plots are arranged in a grid with n_cols columns. Two-way partial dependence plots are plotted as contour plots. The deciles of the feature values will be shown with tick marks on the x-axes for one-way plots, and on both axes for two-way plots.
Read more in the User Guide.
Note
plot_partial_dependence does not support using the same axes with multiple calls. To plot the the partial dependence for multiple estimators, please pass the axes created by the first call to the second call:
Warning
For GradientBoostingClassifier and GradientBoostingRegressor, the 'recursion' method (used by default) will not account for the init predictor of the boosting process. In practice, this will produce the same values as 'brute' up to a constant offset in the target response, provided that init is a constant estimator (which is the default). However, if init is not a constant estimator, the partial dependence values are incorrect for 'recursion' because the offset will be sample-dependent. It is preferable to use the 'brute' method. Note that this only applies to GradientBoostingClassifier and GradientBoostingRegressor, not to HistGradientBoostingClassifier and HistGradientBoostingRegressor.
A fitted estimator object implementing predict, predict_proba, or decision_function. Multioutput-multiclass classifiers are not supported.
X is used to generate a grid of values for the target features (where the partial dependence will be evaluated), and also to generate values for the complement features when the method is 'brute'.
The target features for which to create the PDPs. If features[i] is an integer or a string, a one-way PDP is created; if features[i] is a tuple, a two-way PDP is created (only supported with kind='average'). Each tuple must be of size 2. if any entry is a string, then it must be in feature_names.
Name of each feature; feature_names[i] holds the name of the feature with index i. By default, the name of the feature corresponds to their numerical index for NumPy array and their column name for pandas dataframe.
Ignored in binary classification or classical regression settings.
Specifies whether to use predict_proba or decision_function as the target response. For regressors this parameter is ignored and the response is always the output of predict. By default, predict_proba is tried first and we revert to decision_function if it doesn’t exist. If method is 'recursion', the response is always the output of decision_function.
The maximum number of columns in the grid plot. Only active when ax is a single axis or None.
The number of equally spaced points on the axes of the plots, for each target feature.
The lower and upper percentile used to create the extreme values for the PDP axes. Must be in [0, 1].
The method used to calculate the averaged predictions:
Please see this note for differences between the 'brute' and 'recursion' method.
The number of CPUs to use to compute the partial dependences. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors. See Glossary for more details.
Verbose output during PD computations.
Dict with keywords passed to the matplotlib.pyplot.plot call. For one-way partial dependence plots.
Dict with keywords passed to the matplotlib.pyplot.contourf call. For two-way partial dependence plots.
New in version 0.22.
Whether to plot the partial dependence averaged across all the samples in the dataset or one line per sample or both.
Note that the fast method='recursion' option is only available for kind='average'. Plotting individual dependencies requires using the slower method='brute' option.
New in version 0.24.
Sampling for ICE curves when kind is ‘individual’ or ‘both’. If float, should be between 0.0 and 1.0 and represent the proportion of the dataset to be used to plot ICE curves. If int, represents the absolute number samples to use.
Note that the full dataset is still used to calculate averaged partial dependence when kind='both'.
New in version 0.24.
Controls the randomness of the selected samples when subsamples is not None and kind is either 'both' or 'individual'. See Glossary for details.
New in version 0.24.
See also
Compute Partial Dependence values.
Partial Dependence visualization.


Determine whether y is monotonically correlated with x.
y is found increasing or decreasing with respect to x based on a Spearman correlation test.
Training data.
Training target.
Whether the relationship is increasing or decreasing.
The Spearman correlation coefficient is estimated from the data, and the sign of the resulting estimate is used as the result.
In the event that the 95% confidence interval based on Fisher transform spans zero, a warning is raised.
Fisher transformation. Wikipedia. https://en.wikipedia.org/wiki/Fisher_transformation


Isotonic regression model.
Read more in the User Guide.
New in version 0.13.
Lower bound on the lowest predicted value (the minimum value may still be higher). If not set, defaults to -inf.
Upper bound on the highest predicted value (the maximum may still be lower). If not set, defaults to +inf.
Determines whether the predictions should be constrained to increase or decrease with X. ‘auto’ will decide based on the Spearman correlation estimate’s sign.
Handles how X values outside of the training domain are handled during prediction.
Minimum value of input array X_ for left bound.
Maximum value of input array X_ for right bound.
Unique ascending X values used to interpolate the y = f(X) monotonic function.
New in version 0.24.
De-duplicated y values suitable to interpolate the y = f(X) monotonic function.
New in version 0.24.
The stepwise interpolating function that covers the input domain X.
Inferred value for increasing.
Ties are broken using the secondary method from de Leeuw, 1977.
Isotonic Median Regression: A Linear Programming Approach Nilotpal Chakravarti Mathematics of Operations Research Vol. 14, No. 2 (May, 1989), pp. 303-308
Isotone Optimization in R : Pool-Adjacent-Violators Algorithm (PAVA) and Active Set Methods de Leeuw, Hornik, Mair Journal of Statistical Software 2009
Correctness of Kruskal’s algorithms for monotone regression with ties de Leeuw, Psychometrica, 1977
fit(X, y[, sample_weight])
Fit the model using X, y as training data.
fit_transform(X[, y])
Fit to data, then transform it.
get_params([deep])
Get parameters for this estimator.
predict(T)
Predict new data by linear interpolation.
score(X, y[, sample_weight])
Return the coefficient of determination \(R^2\) of the prediction.
set_params(**params)
Set the parameters of this estimator.
transform(T)
Transform new data by linear interpolation
Fit the model using X, y as training data.
Training data.
Changed in version 0.24: Also accepts 2d array with 1 feature.
Training target.
Weights. If set to None, all weights will be set to 1 (equal weights).
Returns an instance of self.
X is stored for future use, as transform needs X to interpolate new input 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.
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.
Predict new data by linear interpolation.
Data to transform.
Transformed data.
Return the coefficient of determination \(R^2\) of the prediction.
The coefficient \(R^2\) is defined as \((1 - \frac{u}{v})\), where \(u\) is the residual sum of squares ((y_true - y_pred)
** 2).sum() and \(v\) is the total sum of squares ((y_true -
y_true.mean()) ** 2).sum(). The best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). A constant model that always predicts the expected value of y, disregarding the input features, would get a \(R^2\) score of 0.0.
Test samples. For some estimators this may be a precomputed kernel matrix or a list of generic objects instead with shape (n_samples, n_samples_fitted), where n_samples_fitted is the number of samples used in the fitting for the estimator.
True values for X.
Sample weights.
\(R^2\) of self.predict(X) wrt. y.
The \(R^2\) score used when calling score on a regressor uses multioutput='uniform_average' from version 0.23 to keep consistent with default value of r2_score. This influences the score method of all the multioutput regressors (except for MultiOutputRegressor).
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.
Transform new data by linear interpolation
Data to transform.
Changed in version 0.24: Also accepts 2d array with 1 feature.
The transformed data


Isotonic regression model.
Read more in the User Guide.
New in version 0.13.
Lower bound on the lowest predicted value (the minimum value may still be higher). If not set, defaults to -inf.
Upper bound on the highest predicted value (the maximum may still be lower). If not set, defaults to +inf.
Determines whether the predictions should be constrained to increase or decrease with X. ‘auto’ will decide based on the Spearman correlation estimate’s sign.
Handles how X values outside of the training domain are handled during prediction.
Minimum value of input array X_ for left bound.
Maximum value of input array X_ for right bound.
Unique ascending X values used to interpolate the y = f(X) monotonic function.
New in version 0.24.
De-duplicated y values suitable to interpolate the y = f(X) monotonic function.
New in version 0.24.
The stepwise interpolating function that covers the input domain X.
Inferred value for increasing.
Ties are broken using the secondary method from de Leeuw, 1977.
Isotonic Median Regression: A Linear Programming Approach Nilotpal Chakravarti Mathematics of Operations Research Vol. 14, No. 2 (May, 1989), pp. 303-308
Isotone Optimization in R : Pool-Adjacent-Violators Algorithm (PAVA) and Active Set Methods de Leeuw, Hornik, Mair Journal of Statistical Software 2009
Correctness of Kruskal’s algorithms for monotone regression with ties de Leeuw, Psychometrica, 1977
fit(X, y[, sample_weight])
Fit the model using X, y as training data.
fit_transform(X[, y])
Fit to data, then transform it.
get_params([deep])
Get parameters for this estimator.
predict(T)
Predict new data by linear interpolation.
score(X, y[, sample_weight])
Return the coefficient of determination \(R^2\) of the prediction.
set_params(**params)
Set the parameters of this estimator.
transform(T)
Transform new data by linear interpolation
Fit the model using X, y as training data.
Training data.
Changed in version 0.24: Also accepts 2d array with 1 feature.
Training target.
Weights. If set to None, all weights will be set to 1 (equal weights).
Returns an instance of self.
X is stored for future use, as transform needs X to interpolate new input 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.
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.
Predict new data by linear interpolation.
Data to transform.
Transformed data.
Return the coefficient of determination \(R^2\) of the prediction.
The coefficient \(R^2\) is defined as \((1 - \frac{u}{v})\), where \(u\) is the residual sum of squares ((y_true - y_pred)
** 2).sum() and \(v\) is the total sum of squares ((y_true -
y_true.mean()) ** 2).sum(). The best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). A constant model that always predicts the expected value of y, disregarding the input features, would get a \(R^2\) score of 0.0.
Test samples. For some estimators this may be a precomputed kernel matrix or a list of generic objects instead with shape (n_samples, n_samples_fitted), where n_samples_fitted is the number of samples used in the fitting for the estimator.
True values for X.
Sample weights.
\(R^2\) of self.predict(X) wrt. y.
The \(R^2\) score used when calling score on a regressor uses multioutput='uniform_average' from version 0.23 to keep consistent with default value of r2_score. This influences the score method of all the multioutput regressors (except for MultiOutputRegressor).
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.
Transform new data by linear interpolation
Data to transform.
Changed in version 0.24: Also accepts 2d array with 1 feature.
The transformed data
Isotonic Regression


Fit the model using X, y as training data.
Training data.
Changed in version 0.24: Also accepts 2d array with 1 feature.
Training target.
Weights. If set to None, all weights will be set to 1 (equal weights).
Returns an instance of self.
X is stored for future use, as transform needs X to interpolate new input 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.


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.


Predict new data by linear interpolation.
Data to transform.
Transformed data.


Return the coefficient of determination \(R^2\) of the prediction.
The coefficient \(R^2\) is defined as \((1 - \frac{u}{v})\), where \(u\) is the residual sum of squares ((y_true - y_pred)
** 2).sum() and \(v\) is the total sum of squares ((y_true -
y_true.mean()) ** 2).sum(). The best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). A constant model that always predicts the expected value of y, disregarding the input features, would get a \(R^2\) score of 0.0.
Test samples. For some estimators this may be a precomputed kernel matrix or a list of generic objects instead with shape (n_samples, n_samples_fitted), where n_samples_fitted is the number of samples used in the fitting for the estimator.
True values for X.
Sample weights.
\(R^2\) of self.predict(X) wrt. y.
The \(R^2\) score used when calling score on a regressor uses multioutput='uniform_average' from version 0.23 to keep consistent with default value of r2_score. This influences the score method of all the multioutput regressors (except for MultiOutputRegressor).


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.


Transform new data by linear interpolation
Data to transform.
Changed in version 0.24: Also accepts 2d array with 1 feature.
The transformed data


Solve the isotonic regression model.
Read more in the User Guide.
The data.
Weights on each point of the regression. If None, weight is set to 1 (equal weights).
Lower bound on the lowest predicted value (the minimum value may still be higher). If not set, defaults to -inf.
Upper bound on the highest predicted value (the maximum may still be lower). If not set, defaults to +inf.
Whether to compute y_ is increasing (if set to True) or decreasing (if set to False)
Isotonic fit of y.
“Active set algorithms for isotonic regression; A unifying framework” by Michael J. Best and Nilotpal Chakravarti, section 3.


Approximate feature map for additive chi2 kernel.
Uses sampling the fourier transform of the kernel characteristic at regular intervals.
Since the kernel that is to be approximated is additive, the components of the input vectors can be treated separately. Each entry in the original space is transformed into 2*sample_steps+1 features, where sample_steps is a parameter of the method. Typical values of sample_steps include 1, 2 and 3.
Optimal choices for the sampling interval for certain data ranges can be computed (see the reference). The default values should be reasonable.
Read more in the User Guide.
Gives the number of (complex) sampling points.
Sampling interval. Must be specified when sample_steps not in {1,2,3}.
Stored sampling interval. Specified as a parameter if sample_steps not in {1,2,3}.
See also
A Fourier-approximation to a non-additive variant of the chi squared kernel.
The exact chi squared kernel.
The exact additive chi squared kernel.
This estimator approximates a slightly different version of the additive chi squared kernel then metric.additive_chi2 computes.
See “Efficient additive kernels via explicit feature maps” A. Vedaldi and A. Zisserman, Pattern Analysis and Machine Intelligence, 2011
fit(X[, y])
Set the parameters
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)
Apply approximate feature map to X.
Set the parameters
Training data, where n_samples in the number of samples and n_features is the number of features.
Returns the transformer.
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.
Apply approximate feature map to X.
Whether the return value is an array of sparse matrix depends on the type of the input X.


Set the parameters
Training data, where n_samples in the number of samples and n_features is the number of features.
Returns the transformer.


Apply approximate feature map to X.
Whether the return value is an array of sparse matrix depends on the type of the input X.


Approximate a kernel map using a subset of the training data.
Constructs an approximate feature map for an arbitrary kernel using a subset of the data as basis.
Read more in the User Guide.
New in version 0.13.
Kernel map to be approximated. A callable should accept two arguments and the keyword arguments passed to this object as kernel_params, and should return a floating point number.
Gamma parameter for the RBF, laplacian, polynomial, exponential chi2 and sigmoid kernels. Interpretation of the default value is left to the kernel; see the documentation for sklearn.metrics.pairwise. Ignored by other kernels.
Zero coefficient for polynomial and sigmoid kernels. Ignored by other kernels.
Degree of the polynomial kernel. Ignored by other kernels.
Additional parameters (keyword arguments) for kernel function passed as callable object.
Number of features to construct. How many data points will be used to construct the mapping.
Pseudo-random number generator to control the uniform sampling without replacement of n_components of the training data to construct the basis kernel. Pass an int for reproducible output across multiple function calls. See Glossary.
The number of jobs to use for the computation. This works by breaking down the kernel matrix into n_jobs even slices and computing them in parallel.
None means 1 unless in a joblib.parallel_backend context. -1 means using all processors. See Glossary for more details.
New in version 0.24.
Subset of training points used to construct the feature map.
Indices of components_ in the training set.
Normalization matrix needed for embedding. Square root of the kernel matrix on components_.
See also
An approximation to the RBF kernel using random Fourier features.
List of built-in kernels.
fit(X[, y])
Fit estimator to data.
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)
Apply feature map to X.
Fit estimator to data.
Samples a subset of training points, computes kernel on these and computes normalization matrix.
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.
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.
Apply feature map to X.
Computes an approximate feature map using the kernel between some training points and X.
Data to transform.
Transformed data.


Approximate a kernel map using a subset of the training data.
Constructs an approximate feature map for an arbitrary kernel using a subset of the data as basis.
Read more in the User Guide.
New in version 0.13.
Kernel map to be approximated. A callable should accept two arguments and the keyword arguments passed to this object as kernel_params, and should return a floating point number.
Gamma parameter for the RBF, laplacian, polynomial, exponential chi2 and sigmoid kernels. Interpretation of the default value is left to the kernel; see the documentation for sklearn.metrics.pairwise. Ignored by other kernels.
Zero coefficient for polynomial and sigmoid kernels. Ignored by other kernels.
Degree of the polynomial kernel. Ignored by other kernels.
Additional parameters (keyword arguments) for kernel function passed as callable object.
Number of features to construct. How many data points will be used to construct the mapping.
Pseudo-random number generator to control the uniform sampling without replacement of n_components of the training data to construct the basis kernel. Pass an int for reproducible output across multiple function calls. See Glossary.
The number of jobs to use for the computation. This works by breaking down the kernel matrix into n_jobs even slices and computing them in parallel.
None means 1 unless in a joblib.parallel_backend context. -1 means using all processors. See Glossary for more details.
New in version 0.24.
Subset of training points used to construct the feature map.
Indices of components_ in the training set.
Normalization matrix needed for embedding. Square root of the kernel matrix on components_.
See also
An approximation to the RBF kernel using random Fourier features.
List of built-in kernels.
fit(X[, y])
Fit estimator to data.
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)
Apply feature map to X.
Fit estimator to data.
Samples a subset of training points, computes kernel on these and computes normalization matrix.
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.
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.
Apply feature map to X.
Computes an approximate feature map using the kernel between some training points and X.
Data to transform.
Transformed data.
Explicit feature map approximation for RBF kernels


Fit estimator to data.
Samples a subset of training points, computes kernel on these and computes normalization matrix.
Training data.


Apply feature map to X.
Computes an approximate feature map using the kernel between some training points and X.
Data to transform.
Transformed data.


Polynomial kernel approximation via Tensor Sketch.
Implements Tensor Sketch, which approximates the feature map of the polynomial kernel:
by efficiently computing a Count Sketch of the outer product of a vector with itself using Fast Fourier Transforms (FFT). Read more in the User Guide.
New in version 0.24.
Parameter of the polynomial kernel whose feature map will be approximated.
Degree of the polynomial kernel whose feature map will be approximated.
Constant term of the polynomial kernel whose feature map will be approximated.
Dimensionality of the output feature space. Usually, n_components should be greater than the number of features in input samples in order to achieve good performance. The optimal score / run time balance is typically achieved around n_components = 10 * n_features, but this depends on the specific dataset being used.
Determines random number generation for indexHash and bitHash initialization. Pass an int for reproducible results across multiple function calls. See Glossary.
Array of indexes in range [0, n_components) used to represent the 2-wise independent hash functions for Count Sketch computation.
Array with random entries in {+1, -1}, used to represent the 2-wise independent hash functions for Count Sketch computation.
fit(X[, y])
Fit the model with 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)
Generate the feature map approximation for X.
Fit the model with X.
Initializes the internal variables. The method needs no information about the distribution of data, so we only care about n_features in X.
Training data, where n_samples in the number of samples and n_features is the number of features.
Returns the transformer.
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.
Generate the feature map approximation for X.
New data, where n_samples in the number of samples and n_features is the number of features.


Polynomial kernel approximation via Tensor Sketch.
Implements Tensor Sketch, which approximates the feature map of the polynomial kernel:
by efficiently computing a Count Sketch of the outer product of a vector with itself using Fast Fourier Transforms (FFT). Read more in the User Guide.
New in version 0.24.
Parameter of the polynomial kernel whose feature map will be approximated.
Degree of the polynomial kernel whose feature map will be approximated.
Constant term of the polynomial kernel whose feature map will be approximated.
Dimensionality of the output feature space. Usually, n_components should be greater than the number of features in input samples in order to achieve good performance. The optimal score / run time balance is typically achieved around n_components = 10 * n_features, but this depends on the specific dataset being used.
Determines random number generation for indexHash and bitHash initialization. Pass an int for reproducible results across multiple function calls. See Glossary.
Array of indexes in range [0, n_components) used to represent the 2-wise independent hash functions for Count Sketch computation.
Array with random entries in {+1, -1}, used to represent the 2-wise independent hash functions for Count Sketch computation.
fit(X[, y])
Fit the model with 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)
Generate the feature map approximation for X.
Fit the model with X.
Initializes the internal variables. The method needs no information about the distribution of data, so we only care about n_features in X.
Training data, where n_samples in the number of samples and n_features is the number of features.
Returns the transformer.
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.
Generate the feature map approximation for X.
New data, where n_samples in the number of samples and n_features is the number of features.
Release Highlights for scikit-learn 0.24
Scalable learning with polynomial kernel aproximation


Fit the model with X.
Initializes the internal variables. The method needs no information about the distribution of data, so we only care about n_features in X.
Training data, where n_samples in the number of samples and n_features is the number of features.
Returns the transformer.


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.


Generate the feature map approximation for X.
New data, where n_samples in the number of samples and n_features is the number of features.


Approximates feature map of an RBF kernel by Monte Carlo approximation of its Fourier transform.
It implements a variant of Random Kitchen Sinks.[1]
Read more in the User Guide.
Parameter of RBF kernel: exp(-gamma * x^2)
Number of Monte Carlo samples per original feature. Equals the dimensionality of the computed feature space.
Pseudo-random number generator to control the generation of the random weights and random offset when fitting the training data. Pass an int for reproducible output across multiple function calls. See Glossary.
Random offset used to compute the projection in the n_components dimensions of the feature space.
Random projection directions drawn from the Fourier transform of the RBF kernel.
See “Random Features for Large-Scale Kernel Machines” by A. Rahimi and Benjamin Recht.
[1] “Weighted Sums of Random Kitchen Sinks: Replacing minimization with randomization in learning” by A. Rahimi and Benjamin Recht. (https://people.eecs.berkeley.edu/~brecht/papers/08.rah.rec.nips.pdf)
fit(X[, y])
Fit the model with 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)
Apply the approximate feature map to X.
Fit the model with X.
Samples random projection according to n_features.
Training data, where n_samples in the number of samples and n_features is the number of features.
Returns the transformer.
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.
Apply the approximate feature map to X.
New data, where n_samples in the number of samples and n_features is the number of features.


Approximates feature map of an RBF kernel by Monte Carlo approximation of its Fourier transform.
It implements a variant of Random Kitchen Sinks.[1]
Read more in the User Guide.
Parameter of RBF kernel: exp(-gamma * x^2)
Number of Monte Carlo samples per original feature. Equals the dimensionality of the computed feature space.
Pseudo-random number generator to control the generation of the random weights and random offset when fitting the training data. Pass an int for reproducible output across multiple function calls. See Glossary.
Random offset used to compute the projection in the n_components dimensions of the feature space.
Random projection directions drawn from the Fourier transform of the RBF kernel.
See “Random Features for Large-Scale Kernel Machines” by A. Rahimi and Benjamin Recht.
[1] “Weighted Sums of Random Kitchen Sinks: Replacing minimization with randomization in learning” by A. Rahimi and Benjamin Recht. (https://people.eecs.berkeley.edu/~brecht/papers/08.rah.rec.nips.pdf)
fit(X[, y])
Fit the model with 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)
Apply the approximate feature map to X.
Fit the model with X.
Samples random projection according to n_features.
Training data, where n_samples in the number of samples and n_features is the number of features.
Returns the transformer.
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.
Apply the approximate feature map to X.
New data, where n_samples in the number of samples and n_features is the number of features.
Explicit feature map approximation for RBF kernels


Fit the model with X.
Samples random projection according to n_features.
Training data, where n_samples in the number of samples and n_features is the number of features.
Returns the transformer.


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 the approximate feature map to X.
New data, where n_samples in the number of samples and n_features is the number of features.


Approximates feature map of the “skewed chi-squared” kernel by Monte Carlo approximation of its Fourier transform.
Read more in the User Guide.
“skewedness” parameter of the kernel. Needs to be cross-validated.
number of Monte Carlo samples per original feature. Equals the dimensionality of the computed feature space.
Pseudo-random number generator to control the generation of the random weights and random offset when fitting the training data. Pass an int for reproducible output across multiple function calls. See Glossary.
Weight array, sampled from a secant hyperbolic distribution, which will be used to linearly transform the log of the data.
Bias term, which will be added to the data. It is uniformly distributed between 0 and 2*pi.
See also
A different approach for approximating an additive variant of the chi squared kernel.
The exact chi squared kernel.
See “Random Fourier Approximations for Skewed Multiplicative Histogram Kernels” by Fuxin Li, Catalin Ionescu and Cristian Sminchisescu.
fit(X[, y])
Fit the model with 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)
Apply the approximate feature map to X.
Fit the model with X.
Samples random projection according to n_features.
Training data, where n_samples in the number of samples and n_features is the number of features.
Returns the transformer.
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.
Apply the approximate feature map to X.
New data, where n_samples in the number of samples and n_features is the number of features. All values of X must be strictly greater than “-skewedness”.


Apply the approximate feature map to X.
New data, where n_samples in the number of samples and n_features is the number of features. All values of X must be strictly greater than “-skewedness”.


Kernel ridge regression.
Kernel ridge regression (KRR) combines ridge regression (linear least squares with l2-norm regularization) with the kernel trick. It thus learns a linear function in the space induced by the respective kernel and the data. For non-linear kernels, this corresponds to a non-linear function in the original space.
The form of the model learned by KRR is identical to support vector regression (SVR). However, different loss functions are used: KRR uses squared error loss while support vector regression uses epsilon-insensitive loss, both combined with l2 regularization. In contrast to SVR, fitting a KRR model can be done in closed-form and is typically faster for medium-sized datasets. On the other hand, the learned model is non-sparse and thus slower than SVR, which learns a sparse model for epsilon > 0, at prediction-time.
This estimator has built-in support for multi-variate regression (i.e., when y is a 2d-array of shape [n_samples, n_targets]).
Read more in the User Guide.
Regularization strength; must be a positive float. Regularization improves the conditioning of the problem and reduces the variance of the estimates. Larger values specify stronger regularization. Alpha corresponds to 1 / (2C) in other linear models such as LogisticRegression or LinearSVC. If an array is passed, penalties are assumed to be specific to the targets. Hence they must correspond in number. See Ridge regression and classification for formula.
Kernel mapping used internally. This parameter is directly passed to pairwise_kernel. If kernel is a string, it must be one of the metrics in pairwise.PAIRWISE_KERNEL_FUNCTIONS. If kernel is “precomputed”, X is assumed to be a kernel matrix. Alternatively, if kernel is a callable function, it is called on each pair of instances (rows) and the resulting value recorded. The callable should take two rows from X as input and return the corresponding kernel value as a single number. This means that callables from sklearn.metrics.pairwise are not allowed, as they operate on matrices, not single samples. Use the string identifying the kernel instead.
Gamma parameter for the RBF, laplacian, polynomial, exponential chi2 and sigmoid kernels. Interpretation of the default value is left to the kernel; see the documentation for sklearn.metrics.pairwise. Ignored by other kernels.
Degree of the polynomial kernel. Ignored by other kernels.
Zero coefficient for polynomial and sigmoid kernels. Ignored by other kernels.
Additional parameters (keyword arguments) for kernel function passed as callable object.
Representation of weight vector(s) in kernel space
Training data, which is also required for prediction. If kernel == “precomputed” this is instead the precomputed training matrix, of shape (n_samples, n_samples).
See also
Linear ridge regression.
Support Vector Regression implemented using libsvm.
fit(X, y[, sample_weight])
Fit Kernel Ridge regression model
get_params([deep])
Get parameters for this estimator.
predict(X)
Predict using the kernel ridge model
score(X, y[, sample_weight])
Return the coefficient of determination \(R^2\) of the prediction.
set_params(**params)
Set the parameters of this estimator.
Fit Kernel Ridge regression model
Training data. If kernel == “precomputed” this is instead a precomputed kernel matrix, of shape (n_samples, n_samples).
Target values
Individual weights for each sample, ignored if None is passed.
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.
Predict using the kernel ridge model
Samples. If kernel == “precomputed” this is instead a precomputed kernel matrix, shape = [n_samples, n_samples_fitted], where n_samples_fitted is the number of samples used in the fitting for this estimator.
Returns predicted values.
Return the coefficient of determination \(R^2\) of the prediction.
The coefficient \(R^2\) is defined as \((1 - \frac{u}{v})\), where \(u\) is the residual sum of squares ((y_true - y_pred)
** 2).sum() and \(v\) is the total sum of squares ((y_true -
y_true.mean()) ** 2).sum(). The best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). A constant model that always predicts the expected value of y, disregarding the input features, would get a \(R^2\) score of 0.0.
Test samples. For some estimators this may be a precomputed kernel matrix or a list of generic objects instead with shape (n_samples, n_samples_fitted), where n_samples_fitted is the number of samples used in the fitting for the estimator.
True values for X.
Sample weights.
\(R^2\) of self.predict(X) wrt. y.
The \(R^2\) score used when calling score on a regressor uses multioutput='uniform_average' from version 0.23 to keep consistent with default value of r2_score. This influences the score method of all the multioutput regressors (except for MultiOutputRegressor).
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.


Kernel ridge regression.
Kernel ridge regression (KRR) combines ridge regression (linear least squares with l2-norm regularization) with the kernel trick. It thus learns a linear function in the space induced by the respective kernel and the data. For non-linear kernels, this corresponds to a non-linear function in the original space.
The form of the model learned by KRR is identical to support vector regression (SVR). However, different loss functions are used: KRR uses squared error loss while support vector regression uses epsilon-insensitive loss, both combined with l2 regularization. In contrast to SVR, fitting a KRR model can be done in closed-form and is typically faster for medium-sized datasets. On the other hand, the learned model is non-sparse and thus slower than SVR, which learns a sparse model for epsilon > 0, at prediction-time.
This estimator has built-in support for multi-variate regression (i.e., when y is a 2d-array of shape [n_samples, n_targets]).
Read more in the User Guide.
Regularization strength; must be a positive float. Regularization improves the conditioning of the problem and reduces the variance of the estimates. Larger values specify stronger regularization. Alpha corresponds to 1 / (2C) in other linear models such as LogisticRegression or LinearSVC. If an array is passed, penalties are assumed to be specific to the targets. Hence they must correspond in number. See Ridge regression and classification for formula.
Kernel mapping used internally. This parameter is directly passed to pairwise_kernel. If kernel is a string, it must be one of the metrics in pairwise.PAIRWISE_KERNEL_FUNCTIONS. If kernel is “precomputed”, X is assumed to be a kernel matrix. Alternatively, if kernel is a callable function, it is called on each pair of instances (rows) and the resulting value recorded. The callable should take two rows from X as input and return the corresponding kernel value as a single number. This means that callables from sklearn.metrics.pairwise are not allowed, as they operate on matrices, not single samples. Use the string identifying the kernel instead.
Gamma parameter for the RBF, laplacian, polynomial, exponential chi2 and sigmoid kernels. Interpretation of the default value is left to the kernel; see the documentation for sklearn.metrics.pairwise. Ignored by other kernels.
Degree of the polynomial kernel. Ignored by other kernels.
Zero coefficient for polynomial and sigmoid kernels. Ignored by other kernels.
Additional parameters (keyword arguments) for kernel function passed as callable object.
Representation of weight vector(s) in kernel space
Training data, which is also required for prediction. If kernel == “precomputed” this is instead the precomputed training matrix, of shape (n_samples, n_samples).
See also
Linear ridge regression.
Support Vector Regression implemented using libsvm.
fit(X, y[, sample_weight])
Fit Kernel Ridge regression model
get_params([deep])
Get parameters for this estimator.
predict(X)
Predict using the kernel ridge model
score(X, y[, sample_weight])
Return the coefficient of determination \(R^2\) of the prediction.
set_params(**params)
Set the parameters of this estimator.
Fit Kernel Ridge regression model
Training data. If kernel == “precomputed” this is instead a precomputed kernel matrix, of shape (n_samples, n_samples).
Target values
Individual weights for each sample, ignored if None is passed.
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.
Predict using the kernel ridge model
Samples. If kernel == “precomputed” this is instead a precomputed kernel matrix, shape = [n_samples, n_samples_fitted], where n_samples_fitted is the number of samples used in the fitting for this estimator.
Returns predicted values.
Return the coefficient of determination \(R^2\) of the prediction.
The coefficient \(R^2\) is defined as \((1 - \frac{u}{v})\), where \(u\) is the residual sum of squares ((y_true - y_pred)
** 2).sum() and \(v\) is the total sum of squares ((y_true -
y_true.mean()) ** 2).sum(). The best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). A constant model that always predicts the expected value of y, disregarding the input features, would get a \(R^2\) score of 0.0.
Test samples. For some estimators this may be a precomputed kernel matrix or a list of generic objects instead with shape (n_samples, n_samples_fitted), where n_samples_fitted is the number of samples used in the fitting for the estimator.
True values for X.
Sample weights.
\(R^2\) of self.predict(X) wrt. y.
The \(R^2\) score used when calling score on a regressor uses multioutput='uniform_average' from version 0.23 to keep consistent with default value of r2_score. This influences the score method of all the multioutput regressors (except for MultiOutputRegressor).
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.
Comparison of kernel ridge and Gaussian process regression
Comparison of kernel ridge regression and SVR


Fit Kernel Ridge regression model
Training data. If kernel == “precomputed” this is instead a precomputed kernel matrix, of shape (n_samples, n_samples).
Target values
Individual weights for each sample, ignored if None is passed.


Predict using the kernel ridge model
Samples. If kernel == “precomputed” this is instead a precomputed kernel matrix, shape = [n_samples, n_samples_fitted], where n_samples_fitted is the number of samples used in the fitting for this estimator.
Returns predicted values.


Return the coefficient of determination \(R^2\) of the prediction.
The coefficient \(R^2\) is defined as \((1 - \frac{u}{v})\), where \(u\) is the residual sum of squares ((y_true - y_pred)
** 2).sum() and \(v\) is the total sum of squares ((y_true -
y_true.mean()) ** 2).sum(). The best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). A constant model that always predicts the expected value of y, disregarding the input features, would get a \(R^2\) score of 0.0.
Test samples. For some estimators this may be a precomputed kernel matrix or a list of generic objects instead with shape (n_samples, n_samples_fitted), where n_samples_fitted is the number of samples used in the fitting for the estimator.
True values for X.
Sample weights.
\(R^2\) of self.predict(X) wrt. y.
The \(R^2\) score used when calling score on a regressor uses multioutput='uniform_average' from version 0.23 to keep consistent with default value of r2_score. This influences the score method of all the multioutput regressors (except for MultiOutputRegressor).


Bayesian ARD regression.
Fit the weights of a regression model, using an ARD prior. The weights of the regression model are assumed to be in Gaussian distributions. Also estimate the parameters lambda (precisions of the distributions of the weights) and alpha (precision of the distribution of the noise). The estimation is done by an iterative procedures (Evidence Maximization)
Read more in the User Guide.
Maximum number of iterations.
Stop the algorithm if w has converged.
Hyper-parameter : shape parameter for the Gamma distribution prior over the alpha parameter.
Hyper-parameter : inverse scale parameter (rate parameter) for the Gamma distribution prior over the alpha parameter.
Hyper-parameter : shape parameter for the Gamma distribution prior over the lambda parameter.
Hyper-parameter : inverse scale parameter (rate parameter) for the Gamma distribution prior over the lambda parameter.
If True, compute the objective function at each step of the model.
threshold for removing (pruning) weights with high precision from the computation.
whether to calculate the intercept for this model. If set to false, no intercept will be used in calculations (i.e. data is expected to be centered).
This parameter is ignored when fit_intercept is set to False. If True, the regressors X will be normalized before regression by subtracting the mean and dividing by the l2-norm. If you wish to standardize, please use StandardScaler before calling fit on an estimator with normalize=False.
If True, X will be copied; else, it may be overwritten.
Verbose mode when fitting the model.
Coefficients of the regression model (mean of distribution)
estimated precision of the noise.
estimated precisions of the weights.
estimated variance-covariance matrix of the weights
if computed, value of the objective function (to be maximized)
Independent term in decision function. Set to 0.0 if fit_intercept = False.
If normalize=True, offset subtracted for centering data to a zero mean.
If normalize=True, parameter used to scale data to a unit standard deviation.
For an example, see examples/linear_model/plot_ard.py.
D. J. C. MacKay, Bayesian nonlinear modeling for the prediction competition, ASHRAE Transactions, 1994.
R. Salakhutdinov, Lecture notes on Statistical Machine Learning, http://www.utstat.toronto.edu/~rsalakhu/sta4273/notes/Lecture2.pdf#page=15 Their beta is our self.alpha_ Their alpha is our self.lambda_ ARD is a little different than the slide: only dimensions/features for which self.lambda_ < self.threshold_lambda are kept and the rest are discarded.
fit(X, y)
Fit the ARDRegression model according to the given training data and parameters.
get_params([deep])
Get parameters for this estimator.
predict(X[, return_std])
Predict using the linear model.
score(X, y[, sample_weight])
Return the coefficient of determination \(R^2\) of the prediction.
set_params(**params)
Set the parameters of this estimator.
Fit the ARDRegression model according to the given training data and parameters.
Iterative procedure to maximize the evidence
Training vector, where n_samples in the number of samples and n_features is the number of features.
Target values (integers). Will be cast to X’s dtype if necessary
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.
Predict using the linear model.
In addition to the mean of the predictive distribution, also its standard deviation can be returned.
Samples.
Whether to return the standard deviation of posterior prediction.
Mean of predictive distribution of query points.
Standard deviation of predictive distribution of query points.
Return the coefficient of determination \(R^2\) of the prediction.
The coefficient \(R^2\) is defined as \((1 - \frac{u}{v})\), where \(u\) is the residual sum of squares ((y_true - y_pred)
** 2).sum() and \(v\) is the total sum of squares ((y_true -
y_true.mean()) ** 2).sum(). The best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). A constant model that always predicts the expected value of y, disregarding the input features, would get a \(R^2\) score of 0.0.
Test samples. For some estimators this may be a precomputed kernel matrix or a list of generic objects instead with shape (n_samples, n_samples_fitted), where n_samples_fitted is the number of samples used in the fitting for the estimator.
True values for X.
Sample weights.
\(R^2\) of self.predict(X) wrt. y.
The \(R^2\) score used when calling score on a regressor uses multioutput='uniform_average' from version 0.23 to keep consistent with default value of r2_score. This influences the score method of all the multioutput regressors (except for MultiOutputRegressor).
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.