Multi-task L1/L2 ElasticNet with built-in cross-validation.
See glossary entry for cross-validation estimator.
The optimization objective for MultiTaskElasticNet is:
Where:
i.e. the sum of norm of each row.
Read more in the User Guide.
New in version 0.15.
The ElasticNet mixing parameter, with 0 < l1_ratio <= 1. For l1_ratio = 1 the penalty is an L1/L2 penalty. For l1_ratio = 0 it is an L2 penalty. For 0 < l1_ratio < 1, the penalty is a combination of L1/L2 and L2. This parameter can be a list, in which case the different values are tested by cross-validation and the one giving the best prediction score is used. Note that a good choice of list of values for l1_ratio is often to put more values close to 1 (i.e. Lasso) and less close to 0 (i.e. Ridge), as in [.1, .5, .7,
.9, .95, .99, 1]
Length of the path. eps=1e-3 means that alpha_min / alpha_max = 1e-3.
Number of alphas along the regularization path.
List of alphas where to compute the models. If not provided, set automatically.
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.
The maximum number of iterations.
The tolerance for the optimization: if the updates are smaller than tol, the optimization code checks the dual gap for optimality and continues until it is smaller than tol.
Determines the cross-validation splitting strategy. Possible inputs for cv are:
For int/None inputs, KFold is used.
Refer User Guide for the various cross-validation strategies that can be used here.
Changed in version 0.22: cv default value if None changed from 3-fold to 5-fold.
If True, X will be copied; else, it may be overwritten.
Amount of verbosity.
Number of CPUs to use during the cross validation. Note that this is used only if multiple values for l1_ratio are given. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors. See Glossary for more details.
The seed of the pseudo random number generator that selects a random feature to update. Used when selection == ‘random’. Pass an int for reproducible output across multiple function calls. See Glossary.
If set to ‘random’, a random coefficient is updated every iteration rather than looping over features sequentially by default. This (setting to ‘random’) often leads to significantly faster convergence especially when tol is higher than 1e-4.
Independent term in decision function.
Parameter vector (W in the cost function formula). Note that coef_ stores the transpose of W, W.T.
The amount of penalization chosen by cross validation.
Mean square error for the test set on each fold, varying alpha.
The grid of alphas used for fitting, for each l1_ratio.
Best l1_ratio obtained by cross-validation.
Number of iterations run by the coordinate descent solver to reach the specified tolerance for the optimal alpha.
The dual gap at the end of the optimization for the optimal alpha.
See also
The algorithm used to fit the model is coordinate descent.
To avoid unnecessary memory duplication the X and y arguments of the fit method should be directly passed as Fortran-contiguous numpy arrays.
fit(X, y)
Fit linear model with coordinate descent.
get_params([deep])
Get parameters for this estimator.
path(*args, **kwargs)
Compute elastic net path with coordinate descent.
predict(X)
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 linear model with coordinate descent.
Fit is on grid of alphas and best alpha estimated by cross-validation.
Training data. Pass directly as Fortran-contiguous data to avoid unnecessary memory duplication. If y is mono-output, X can be sparse.
Target values.
Get parameters for this estimator.
If True, will return the parameters for this estimator and contained subobjects that are estimators.
Parameter names mapped to their values.
Compute elastic net path with coordinate descent.
The elastic net optimization function varies for mono and multi-outputs.
For mono-output tasks it is:
For multi-output tasks it is:
Where:
i.e. the sum of norm of each row.
Read more in the User Guide.
Training data. Pass directly as Fortran-contiguous data to avoid unnecessary memory duplication. If y is mono-output then X can be sparse.
Target values.
Number between 0 and 1 passed to elastic net (scaling between l1 and l2 penalties). l1_ratio=1 corresponds to the Lasso.
Length of the path. eps=1e-3 means that alpha_min / alpha_max = 1e-3.
Number of alphas along the regularization path.
List of alphas where to compute the models. If None alphas are set automatically.
Whether to use a precomputed Gram matrix to speed up calculations. If set to 'auto' let us decide. The Gram matrix can also be passed as argument.
Xy = np.dot(X.T, y) that can be precomputed. It is useful only when the Gram matrix is precomputed.
If True, X will be copied; else, it may be overwritten.
The initial values of the coefficients.
Amount of verbosity.
Whether to return the number of iterations or not.
If set to True, forces coefficients to be positive. (Only allowed when y.ndim == 1).
If set to False, the input validation checks are skipped (including the Gram matrix when provided). It is assumed that they are handled by the caller.
Keyword arguments passed to the coordinate descent solver.
The alphas along the path where models are computed.
Coefficients along the path.
The dual gaps at the end of the optimization for each alpha.
The number of iterations taken by the coordinate descent optimizer to reach the specified tolerance for each alpha. (Is returned when return_n_iter is set to True).
See also
For an example, see examples/linear_model/plot_lasso_coordinate_descent_path.py.
Predict using the linear model.
Samples.
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.


Fit linear model with coordinate descent.
Fit is on grid of alphas and best alpha estimated by cross-validation.
Training data. Pass directly as Fortran-contiguous data to avoid unnecessary memory duplication. If y is mono-output, X can be sparse.
Target values.


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


Compute elastic net path with coordinate descent.
The elastic net optimization function varies for mono and multi-outputs.
For mono-output tasks it is:
For multi-output tasks it is:
Where:
i.e. the sum of norm of each row.
Read more in the User Guide.
Training data. Pass directly as Fortran-contiguous data to avoid unnecessary memory duplication. If y is mono-output then X can be sparse.
Target values.
Number between 0 and 1 passed to elastic net (scaling between l1 and l2 penalties). l1_ratio=1 corresponds to the Lasso.
Length of the path. eps=1e-3 means that alpha_min / alpha_max = 1e-3.
Number of alphas along the regularization path.
List of alphas where to compute the models. If None alphas are set automatically.
Whether to use a precomputed Gram matrix to speed up calculations. If set to 'auto' let us decide. The Gram matrix can also be passed as argument.
Xy = np.dot(X.T, y) that can be precomputed. It is useful only when the Gram matrix is precomputed.
If True, X will be copied; else, it may be overwritten.
The initial values of the coefficients.
Amount of verbosity.
Whether to return the number of iterations or not.
If set to True, forces coefficients to be positive. (Only allowed when y.ndim == 1).
If set to False, the input validation checks are skipped (including the Gram matrix when provided). It is assumed that they are handled by the caller.
Keyword arguments passed to the coordinate descent solver.
The alphas along the path where models are computed.
Coefficients along the path.
The dual gaps at the end of the optimization for each alpha.
The number of iterations taken by the coordinate descent optimizer to reach the specified tolerance for each alpha. (Is returned when return_n_iter is set to True).
See also
For an example, see examples/linear_model/plot_lasso_coordinate_descent_path.py.


Predict using the linear model.
Samples.
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.


Multi-task Lasso model trained with L1/L2 mixed-norm as regularizer.
The optimization objective for Lasso is:
Where:
i.e. the sum of norm of each row.
Read more in the User Guide.
Constant that multiplies the L1/L2 term. Defaults to 1.0.
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.
The maximum number of iterations.
The tolerance for the optimization: if the updates are smaller than tol, the optimization code checks the dual gap for optimality and continues until it is smaller than tol.
When set to True, reuse the solution of the previous call to fit as initialization, otherwise, just erase the previous solution. See the Glossary.
The seed of the pseudo random number generator that selects a random feature to update. Used when selection == ‘random’. Pass an int for reproducible output across multiple function calls. See Glossary.
If set to ‘random’, a random coefficient is updated every iteration rather than looping over features sequentially by default. This (setting to ‘random’) often leads to significantly faster convergence especially when tol is higher than 1e-4
Parameter vector (W in the cost function formula). Note that coef_ stores the transpose of W, W.T.
Independent term in decision function.
Number of iterations run by the coordinate descent solver to reach the specified tolerance.
The dual gaps at the end of the optimization for each alpha.
The tolerance scaled scaled by the variance of the target y.
Sparse representation of the fitted coef_.
See also
Multi-task L1/L2 Lasso with built-in cross-validation.
The algorithm used to fit the model is coordinate descent.
To avoid unnecessary memory duplication the X and y arguments of the fit method should be directly passed as Fortran-contiguous numpy arrays.
fit(X, y)
Fit MultiTaskElasticNet model with coordinate descent
get_params([deep])
Get parameters for this estimator.
path(*args, **kwargs)
Compute elastic net path with coordinate descent.
predict(X)
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 MultiTaskElasticNet model with coordinate descent
Data.
Target. Will be cast to X’s dtype if necessary.
Coordinate descent is an algorithm that considers each column of data at a time hence it will automatically convert the X input as a Fortran-contiguous numpy array if necessary.
To avoid memory re-allocation it is advised to allocate the initial data in memory directly using that format.
Get parameters for this estimator.
If True, will return the parameters for this estimator and contained subobjects that are estimators.
Parameter names mapped to their values.
Compute elastic net path with coordinate descent.
The elastic net optimization function varies for mono and multi-outputs.
For mono-output tasks it is:
For multi-output tasks it is:
Where:
i.e. the sum of norm of each row.
Read more in the User Guide.
Training data. Pass directly as Fortran-contiguous data to avoid unnecessary memory duplication. If y is mono-output then X can be sparse.
Target values.
Number between 0 and 1 passed to elastic net (scaling between l1 and l2 penalties). l1_ratio=1 corresponds to the Lasso.
Length of the path. eps=1e-3 means that alpha_min / alpha_max = 1e-3.
Number of alphas along the regularization path.
List of alphas where to compute the models. If None alphas are set automatically.
Whether to use a precomputed Gram matrix to speed up calculations. If set to 'auto' let us decide. The Gram matrix can also be passed as argument.
Xy = np.dot(X.T, y) that can be precomputed. It is useful only when the Gram matrix is precomputed.
If True, X will be copied; else, it may be overwritten.
The initial values of the coefficients.
Amount of verbosity.
Whether to return the number of iterations or not.
If set to True, forces coefficients to be positive. (Only allowed when y.ndim == 1).
If set to False, the input validation checks are skipped (including the Gram matrix when provided). It is assumed that they are handled by the caller.
Keyword arguments passed to the coordinate descent solver.
The alphas along the path where models are computed.
Coefficients along the path.
The dual gaps at the end of the optimization for each alpha.
The number of iterations taken by the coordinate descent optimizer to reach the specified tolerance for each alpha. (Is returned when return_n_iter is set to True).
See also
For an example, see examples/linear_model/plot_lasso_coordinate_descent_path.py.
Predict using the linear model.
Samples.
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.
Sparse representation of the fitted coef_.


Multi-task Lasso model trained with L1/L2 mixed-norm as regularizer.
The optimization objective for Lasso is:
Where:
i.e. the sum of norm of each row.
Read more in the User Guide.
Constant that multiplies the L1/L2 term. Defaults to 1.0.
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.
The maximum number of iterations.
The tolerance for the optimization: if the updates are smaller than tol, the optimization code checks the dual gap for optimality and continues until it is smaller than tol.
When set to True, reuse the solution of the previous call to fit as initialization, otherwise, just erase the previous solution. See the Glossary.
The seed of the pseudo random number generator that selects a random feature to update. Used when selection == ‘random’. Pass an int for reproducible output across multiple function calls. See Glossary.
If set to ‘random’, a random coefficient is updated every iteration rather than looping over features sequentially by default. This (setting to ‘random’) often leads to significantly faster convergence especially when tol is higher than 1e-4
Parameter vector (W in the cost function formula). Note that coef_ stores the transpose of W, W.T.
Independent term in decision function.
Number of iterations run by the coordinate descent solver to reach the specified tolerance.
The dual gaps at the end of the optimization for each alpha.
The tolerance scaled scaled by the variance of the target y.
Sparse representation of the fitted coef_.
See also
Multi-task L1/L2 Lasso with built-in cross-validation.
The algorithm used to fit the model is coordinate descent.
To avoid unnecessary memory duplication the X and y arguments of the fit method should be directly passed as Fortran-contiguous numpy arrays.
fit(X, y)
Fit MultiTaskElasticNet model with coordinate descent
get_params([deep])
Get parameters for this estimator.
path(*args, **kwargs)
Compute elastic net path with coordinate descent.
predict(X)
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 MultiTaskElasticNet model with coordinate descent
Data.
Target. Will be cast to X’s dtype if necessary.
Coordinate descent is an algorithm that considers each column of data at a time hence it will automatically convert the X input as a Fortran-contiguous numpy array if necessary.
To avoid memory re-allocation it is advised to allocate the initial data in memory directly using that format.
Get parameters for this estimator.
If True, will return the parameters for this estimator and contained subobjects that are estimators.
Parameter names mapped to their values.
Compute elastic net path with coordinate descent.
The elastic net optimization function varies for mono and multi-outputs.
For mono-output tasks it is:
For multi-output tasks it is:
Where:
i.e. the sum of norm of each row.
Read more in the User Guide.
Training data. Pass directly as Fortran-contiguous data to avoid unnecessary memory duplication. If y is mono-output then X can be sparse.
Target values.
Number between 0 and 1 passed to elastic net (scaling between l1 and l2 penalties). l1_ratio=1 corresponds to the Lasso.
Length of the path. eps=1e-3 means that alpha_min / alpha_max = 1e-3.
Number of alphas along the regularization path.
List of alphas where to compute the models. If None alphas are set automatically.
Whether to use a precomputed Gram matrix to speed up calculations. If set to 'auto' let us decide. The Gram matrix can also be passed as argument.
Xy = np.dot(X.T, y) that can be precomputed. It is useful only when the Gram matrix is precomputed.
If True, X will be copied; else, it may be overwritten.
The initial values of the coefficients.
Amount of verbosity.
Whether to return the number of iterations or not.
If set to True, forces coefficients to be positive. (Only allowed when y.ndim == 1).
If set to False, the input validation checks are skipped (including the Gram matrix when provided). It is assumed that they are handled by the caller.
Keyword arguments passed to the coordinate descent solver.
The alphas along the path where models are computed.
Coefficients along the path.
The dual gaps at the end of the optimization for each alpha.
The number of iterations taken by the coordinate descent optimizer to reach the specified tolerance for each alpha. (Is returned when return_n_iter is set to True).
See also
For an example, see examples/linear_model/plot_lasso_coordinate_descent_path.py.
Predict using the linear model.
Samples.
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.
Sparse representation of the fitted coef_.
Joint feature selection with multi-task Lasso


Fit MultiTaskElasticNet model with coordinate descent
Data.
Target. Will be cast to X’s dtype if necessary.
Coordinate descent is an algorithm that considers each column of data at a time hence it will automatically convert the X input as a Fortran-contiguous numpy array if necessary.
To avoid memory re-allocation it is advised to allocate the initial data in memory directly using that format.


Sparse representation of the fitted coef_.


Multi-task Lasso model trained with L1/L2 mixed-norm as regularizer.
See glossary entry for cross-validation estimator.
The optimization objective for MultiTaskLasso is:
Where:
i.e. the sum of norm of each row.
Read more in the User Guide.
New in version 0.15.
Length of the path. eps=1e-3 means that alpha_min / alpha_max = 1e-3.
Number of alphas along the regularization path.
List of alphas where to compute the models. If not provided, set automatically.
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.
The maximum number of iterations.
The tolerance for the optimization: if the updates are smaller than tol, the optimization code checks the dual gap for optimality and continues until it is smaller than tol.
If True, X will be copied; else, it may be overwritten.
Determines the cross-validation splitting strategy. Possible inputs for cv are:
For int/None inputs, KFold is used.
Refer User Guide for the various cross-validation strategies that can be used here.
Changed in version 0.22: cv default value if None changed from 3-fold to 5-fold.
Amount of verbosity.
Number of CPUs to use during the cross validation. Note that this is used only if multiple values for l1_ratio are given. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors. See Glossary for more details.
The seed of the pseudo random number generator that selects a random feature to update. Used when selection == ‘random’. Pass an int for reproducible output across multiple function calls. See Glossary.
If set to ‘random’, a random coefficient is updated every iteration rather than looping over features sequentially by default. This (setting to ‘random’) often leads to significantly faster convergence especially when tol is higher than 1e-4.
Independent term in decision function.
Parameter vector (W in the cost function formula). Note that coef_ stores the transpose of W, W.T.
The amount of penalization chosen by cross validation.
Mean square error for the test set on each fold, varying alpha.
The grid of alphas used for fitting.
Number of iterations run by the coordinate descent solver to reach the specified tolerance for the optimal alpha.
The dual gap at the end of the optimization for the optimal alpha.
See also
The algorithm used to fit the model is coordinate descent.
To avoid unnecessary memory duplication the X and y arguments of the fit method should be directly passed as Fortran-contiguous numpy arrays.
fit(X, y)
Fit linear model with coordinate descent.
get_params([deep])
Get parameters for this estimator.
path(*args, **kwargs)
Compute Lasso path with coordinate descent
predict(X)
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 linear model with coordinate descent.
Fit is on grid of alphas and best alpha estimated by cross-validation.
Training data. Pass directly as Fortran-contiguous data to avoid unnecessary memory duplication. If y is mono-output, X can be sparse.
Target values.
Get parameters for this estimator.
If True, will return the parameters for this estimator and contained subobjects that are estimators.
Parameter names mapped to their values.
Compute Lasso path with coordinate descent
The Lasso optimization function varies for mono and multi-outputs.
For mono-output tasks it is:
For multi-output tasks it is:
Where:
i.e. the sum of norm of each row.
Read more in the User Guide.
Training data. Pass directly as Fortran-contiguous data to avoid unnecessary memory duplication. If y is mono-output then X can be sparse.
Target values
Length of the path. eps=1e-3 means that alpha_min / alpha_max = 1e-3
Number of alphas along the regularization path
List of alphas where to compute the models. If None alphas are set automatically
Whether to use a precomputed Gram matrix to speed up calculations. If set to 'auto' let us decide. The Gram matrix can also be passed as argument.
Xy = np.dot(X.T, y) that can be precomputed. It is useful only when the Gram matrix is precomputed.
If True, X will be copied; else, it may be overwritten.
The initial values of the coefficients.
Amount of verbosity.
whether to return the number of iterations or not.
If set to True, forces coefficients to be positive. (Only allowed when y.ndim == 1).
keyword arguments passed to the coordinate descent solver.
The alphas along the path where models are computed.
Coefficients along the path.
The dual gaps at the end of the optimization for each alpha.
The number of iterations taken by the coordinate descent optimizer to reach the specified tolerance for each alpha.
See also
For an example, see examples/linear_model/plot_lasso_coordinate_descent_path.py.
To avoid unnecessary memory duplication the X argument of the fit method should be directly passed as a Fortran-contiguous numpy array.
Note that in certain cases, the Lars solver may be significantly faster to implement this functionality. In particular, linear interpolation can be used to retrieve model coefficients between the values output by lars_path
Comparing lasso_path and lars_path with interpolation:
Predict using the linear model.
Samples.
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.


Compute Lasso path with coordinate descent
The Lasso optimization function varies for mono and multi-outputs.
For mono-output tasks it is:
For multi-output tasks it is:
Where:
i.e. the sum of norm of each row.
Read more in the User Guide.
Training data. Pass directly as Fortran-contiguous data to avoid unnecessary memory duplication. If y is mono-output then X can be sparse.
Target values
Length of the path. eps=1e-3 means that alpha_min / alpha_max = 1e-3
Number of alphas along the regularization path
List of alphas where to compute the models. If None alphas are set automatically
Whether to use a precomputed Gram matrix to speed up calculations. If set to 'auto' let us decide. The Gram matrix can also be passed as argument.
Xy = np.dot(X.T, y) that can be precomputed. It is useful only when the Gram matrix is precomputed.
If True, X will be copied; else, it may be overwritten.
The initial values of the coefficients.
Amount of verbosity.
whether to return the number of iterations or not.
If set to True, forces coefficients to be positive. (Only allowed when y.ndim == 1).
keyword arguments passed to the coordinate descent solver.
The alphas along the path where models are computed.
Coefficients along the path.
The dual gaps at the end of the optimization for each alpha.
The number of iterations taken by the coordinate descent optimizer to reach the specified tolerance for each alpha.
See also
For an example, see examples/linear_model/plot_lasso_coordinate_descent_path.py.
To avoid unnecessary memory duplication the X argument of the fit method should be directly passed as a Fortran-contiguous numpy array.
Note that in certain cases, the Lars solver may be significantly faster to implement this functionality. In particular, linear interpolation can be used to retrieve model coefficients between the values output by lars_path
Comparing lasso_path and lars_path with interpolation:


Orthogonal Matching Pursuit model (OMP).
Read more in the User Guide.
Desired number of non-zero entries in the solution. If None (by default) this value is set to 10% of n_features.
Maximum norm of the residual. If not None, overrides n_nonzero_coefs.
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.
Whether to use a precomputed Gram and Xy matrix to speed up calculations. Improves performance when n_targets or n_samples is very large. Note that if you already have such matrices, you can pass them directly to the fit method.
Parameter vector (w in the formula).
Independent term in decision function.
Number of active features across every target.
The number of non-zero coefficients in the solution. If n_nonzero_coefs is None and tol is None this value is either set to 10% of n_features or 1, whichever is greater.
See also
Orthogonal matching pursuit was introduced in G. Mallat, Z. Zhang, Matching pursuits with time-frequency dictionaries, IEEE Transactions on Signal Processing, Vol. 41, No. 12. (December 1993), pp. 3397-3415. (http://blanche.polytechnique.fr/~mallat/papiers/MallatPursuit93.pdf)
This implementation is based on Rubinstein, R., Zibulevsky, M. and Elad, M., Efficient Implementation of the K-SVD Algorithm using Batch Orthogonal Matching Pursuit Technical Report - CS Technion, April 2008. https://www.cs.technion.ac.il/~ronrubin/Publications/KSVD-OMP-v2.pdf
fit(X, y)
Fit the model using X, y as training data.
get_params([deep])
Get parameters for this estimator.
predict(X)
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 model using X, y as training data.
Training data.
Target values. Will be cast to X’s dtype if necessary
returns an instance of self.
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.
Samples.
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.


Orthogonal Matching Pursuit model (OMP).
Read more in the User Guide.
Desired number of non-zero entries in the solution. If None (by default) this value is set to 10% of n_features.
Maximum norm of the residual. If not None, overrides n_nonzero_coefs.
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.
Whether to use a precomputed Gram and Xy matrix to speed up calculations. Improves performance when n_targets or n_samples is very large. Note that if you already have such matrices, you can pass them directly to the fit method.
Parameter vector (w in the formula).
Independent term in decision function.
Number of active features across every target.
The number of non-zero coefficients in the solution. If n_nonzero_coefs is None and tol is None this value is either set to 10% of n_features or 1, whichever is greater.
See also
Orthogonal matching pursuit was introduced in G. Mallat, Z. Zhang, Matching pursuits with time-frequency dictionaries, IEEE Transactions on Signal Processing, Vol. 41, No. 12. (December 1993), pp. 3397-3415. (http://blanche.polytechnique.fr/~mallat/papiers/MallatPursuit93.pdf)
This implementation is based on Rubinstein, R., Zibulevsky, M. and Elad, M., Efficient Implementation of the K-SVD Algorithm using Batch Orthogonal Matching Pursuit Technical Report - CS Technion, April 2008. https://www.cs.technion.ac.il/~ronrubin/Publications/KSVD-OMP-v2.pdf
fit(X, y)
Fit the model using X, y as training data.
get_params([deep])
Get parameters for this estimator.
predict(X)
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 model using X, y as training data.
Training data.
Target values. Will be cast to X’s dtype if necessary
returns an instance of self.
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.
Samples.
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.
Orthogonal Matching Pursuit


Fit the model using X, y as training data.
Training data.
Target values. Will be cast to X’s dtype if necessary
returns an instance of self.


Cross-validated Orthogonal Matching Pursuit model (OMP).
See glossary entry for cross-validation estimator.
Read more in the User Guide.
Whether the design matrix X must be copied by the algorithm. A false value is only helpful if X is already Fortran-ordered, otherwise a copy is made anyway.
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.
Maximum numbers of iterations to perform, therefore maximum features to include. 10% of n_features but at least 5 if available.
Determines the cross-validation splitting strategy. Possible inputs for cv are:
For integer/None inputs, KFold is used.
Refer User Guide for the various cross-validation strategies that can be used here.
Changed in version 0.22: cv default value if None changed from 3-fold to 5-fold.
Number of CPUs to use during the cross validation. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors. See Glossary for more details.
Sets the verbosity amount.
Independent term in decision function.
Parameter vector (w in the problem formulation).
Estimated number of non-zero coefficients giving the best mean squared error over the cross-validation folds.
Number of active features across every target for the model refit with the best hyperparameters got by cross-validating across all folds.
See also
fit(X, y)
Fit the model using X, y as training data.
get_params([deep])
Get parameters for this estimator.
predict(X)
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 model using X, y as training data.
Training data.
Target values. Will be cast to X’s dtype if necessary.
returns an instance of self.
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.
Samples.
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.


Cross-validated Orthogonal Matching Pursuit model (OMP).
See glossary entry for cross-validation estimator.
Read more in the User Guide.
Whether the design matrix X must be copied by the algorithm. A false value is only helpful if X is already Fortran-ordered, otherwise a copy is made anyway.
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.
Maximum numbers of iterations to perform, therefore maximum features to include. 10% of n_features but at least 5 if available.
Determines the cross-validation splitting strategy. Possible inputs for cv are:
For integer/None inputs, KFold is used.
Refer User Guide for the various cross-validation strategies that can be used here.
Changed in version 0.22: cv default value if None changed from 3-fold to 5-fold.
Number of CPUs to use during the cross validation. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors. See Glossary for more details.
Sets the verbosity amount.
Independent term in decision function.
Parameter vector (w in the problem formulation).
Estimated number of non-zero coefficients giving the best mean squared error over the cross-validation folds.
Number of active features across every target for the model refit with the best hyperparameters got by cross-validating across all folds.
See also
fit(X, y)
Fit the model using X, y as training data.
get_params([deep])
Get parameters for this estimator.
predict(X)
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 model using X, y as training data.
Training data.
Target values. Will be cast to X’s dtype if necessary.
returns an instance of self.
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.
Samples.
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.
Orthogonal Matching Pursuit


Fit the model using X, y as training data.
Training data.
Target values. Will be cast to X’s dtype if necessary.
returns an instance of self.


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.


Orthogonal Matching Pursuit (OMP).
Solves n_targets Orthogonal Matching Pursuit problems. An instance of the problem has the form:
When parametrized by the number of non-zero coefficients using n_nonzero_coefs: argmin ||y - Xgamma||^2 subject to ||gamma||_0 <= n_{nonzero coefs}
When parametrized by error using the parameter tol: argmin ||gamma||_0 subject to ||y - Xgamma||^2 <= tol
Read more in the User Guide.
Input data. Columns are assumed to have unit norm.
Input targets.
Desired number of non-zero entries in the solution. If None (by default) this value is set to 10% of n_features.
Maximum norm of the residual. If not None, overrides n_nonzero_coefs.
Whether to perform precomputations. Improves performance when n_targets or n_samples is very large.
Whether the design matrix X must be copied by the algorithm. A false value is only helpful if X is already Fortran-ordered, otherwise a copy is made anyway.
Whether to return every value of the nonzero coefficients along the forward path. Useful for cross-validation.
Whether or not to return the number of iterations.
Coefficients of the OMP solution. If return_path=True, this contains the whole coefficient path. In this case its shape is (n_features, n_features) or (n_features, n_targets, n_features) and iterating over the last axis yields coefficients in increasing order of active features.
Number of active features across every target. Returned only if return_n_iter is set to True.
See also
Orthogonal matching pursuit was introduced in S. Mallat, Z. Zhang, Matching pursuits with time-frequency dictionaries, IEEE Transactions on Signal Processing, Vol. 41, No. 12. (December 1993), pp. 3397-3415. (http://blanche.polytechnique.fr/~mallat/papiers/MallatPursuit93.pdf)
This implementation is based on Rubinstein, R., Zibulevsky, M. and Elad, M., Efficient Implementation of the K-SVD Algorithm using Batch Orthogonal Matching Pursuit Technical Report - CS Technion, April 2008. https://www.cs.technion.ac.il/~ronrubin/Publications/KSVD-OMP-v2.pdf


Gram Orthogonal Matching Pursuit (OMP).
Solves n_targets Orthogonal Matching Pursuit problems using only the Gram matrix X.T * X and the product X.T * y.
Read more in the User Guide.
Gram matrix of the input data: X.T * X.
Input targets multiplied by X: X.T * y.
Desired number of non-zero entries in the solution. If None (by default) this value is set to 10% of n_features.
Maximum norm of the residual. If not None, overrides n_nonzero_coefs.
Squared L2 norms of the lines of y. Required if tol is not None.
Whether the gram matrix must be copied by the algorithm. A false value is only helpful if it is already Fortran-ordered, otherwise a copy is made anyway.
Whether the covariance vector Xy must be copied by the algorithm. If False, it may be overwritten.
Whether to return every value of the nonzero coefficients along the forward path. Useful for cross-validation.
Whether or not to return the number of iterations.
Coefficients of the OMP solution. If return_path=True, this contains the whole coefficient path. In this case its shape is (n_features, n_features) or (n_features, n_targets, n_features) and iterating over the last axis yields coefficients in increasing order of active features.
Number of active features across every target. Returned only if return_n_iter is set to True.
See also
Orthogonal matching pursuit was introduced in G. Mallat, Z. Zhang, Matching pursuits with time-frequency dictionaries, IEEE Transactions on Signal Processing, Vol. 41, No. 12. (December 1993), pp. 3397-3415. (http://blanche.polytechnique.fr/~mallat/papiers/MallatPursuit93.pdf)
This implementation is based on Rubinstein, R., Zibulevsky, M. and Elad, M., Efficient Implementation of the K-SVD Algorithm using Batch Orthogonal Matching Pursuit Technical Report - CS Technion, April 2008. https://www.cs.technion.ac.il/~ronrubin/Publications/KSVD-OMP-v2.pdf


Passive Aggressive Classifier
Read more in the User Guide.
Maximum step size (regularization). Defaults to 1.0.
Whether the intercept should be estimated or not. If False, the data is assumed to be already centered.
The maximum number of passes over the training data (aka epochs). It only impacts the behavior in the fit method, and not the partial_fit method.
New in version 0.19.
The stopping criterion. If it is not None, the iterations will stop when (loss > previous_loss - tol).
New in version 0.19.
Whether to use early stopping to terminate training when validation. score is not improving. If set to True, it will automatically set aside a stratified fraction of training data as validation and terminate training when validation score is not improving by at least tol for n_iter_no_change consecutive epochs.
New in version 0.20.
The proportion of training data to set aside as validation set for early stopping. Must be between 0 and 1. Only used if early_stopping is True.
New in version 0.20.
Number of iterations with no improvement to wait before early stopping.
New in version 0.20.
Whether or not the training data should be shuffled after each epoch.
The verbosity level
The loss function to be used: hinge: equivalent to PA-I in the reference paper. squared_hinge: equivalent to PA-II in the reference paper.
The number of CPUs to use to do the OVA (One Versus All, for multi-class problems) computation. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors. See Glossary for more details.
Used to shuffle the training data, when shuffle is set to True. Pass an int for reproducible output across multiple function calls. See Glossary.
When set to True, reuse the solution of the previous call to fit as initialization, otherwise, just erase the previous solution. See the Glossary.
Repeatedly calling fit or partial_fit when warm_start is True can result in a different solution than when calling fit a single time because of the way the data is shuffled.
Preset for the class_weight fit parameter.
Weights associated with classes. If not given, all classes are supposed to have weight one.
The “balanced” mode uses the values of y to automatically adjust weights inversely proportional to class frequencies in the input data as n_samples / (n_classes * np.bincount(y))
New in version 0.17: parameter class_weight to automatically weight samples.
When set to True, computes the averaged SGD weights and stores the result in the coef_ attribute. If set to an int greater than 1, averaging will begin once the total number of samples seen reaches average. So average=10 will begin averaging after seeing 10 samples.
New in version 0.19: parameter average to use weights averaging in SGD
Weights assigned to the features.
Constants in decision function.
The actual number of iterations to reach the stopping criterion. For multiclass fits, it is the maximum over every binary fit.
The unique classes labels.
Number of weight updates performed during training. Same as (n_iter_ * n_samples).
Loss function used by the algorithm.
See also
Online Passive-Aggressive Algorithms <http://jmlr.csail.mit.edu/papers/volume7/crammer06a/crammer06a.pdf> K. Crammer, O. Dekel, J. Keshat, S. Shalev-Shwartz, Y. Singer - JMLR (2006)
decision_function(X)
Predict confidence scores for samples.
densify()
Convert coefficient matrix to dense array format.
fit(X, y[, coef_init, intercept_init])
Fit linear model with Passive Aggressive algorithm.
get_params([deep])
Get parameters for this estimator.
partial_fit(X, y[, classes])
Fit linear model with Passive Aggressive algorithm.
predict(X)
Predict class labels for samples in X.
score(X, y[, sample_weight])
Return the mean accuracy on the given test data and labels.
set_params(**kwargs)
Set and validate the parameters of estimator.
sparsify()
Convert coefficient matrix to sparse format.
Predict confidence scores for samples.
The confidence score for a sample is proportional to the signed distance of that sample to the hyperplane.
Samples.
Confidence scores per (sample, class) combination. In the binary case, confidence score for self.classes_[1] where >0 means this class would be predicted.
Convert coefficient matrix to dense array format.
Converts the coef_ member (back) to a numpy.ndarray. This is the default format of coef_ and is required for fitting, so calling this method is only required on models that have previously been sparsified; otherwise, it is a no-op.
Fitted estimator.
Fit linear model with Passive Aggressive algorithm.
Training data
Target values
The initial coefficients to warm-start the optimization.
The initial intercept to warm-start the optimization.
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.
Fit linear model with Passive Aggressive algorithm.
Subset of the training data
Subset of the target values
Classes across all calls to partial_fit. Can be obtained by via np.unique(y_all), where y_all is the target vector of the entire dataset. This argument is required for the first call to partial_fit and can be omitted in the subsequent calls. Note that y doesn’t need to contain all labels in classes.
Predict class labels for samples in X.
Samples.
Predicted class label per sample.
Return the mean accuracy on the given test data and labels.
In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.
Test samples.
True labels for X.
Sample weights.
Mean accuracy of self.predict(X) wrt. y.
Set and validate the parameters of estimator.
Estimator parameters.
Estimator instance.
Convert coefficient matrix to sparse format.
Converts the coef_ member to a scipy.sparse matrix, which for L1-regularized models can be much more memory- and storage-efficient than the usual numpy.ndarray representation.
The intercept_ member is not converted.
Fitted estimator.
For non-sparse models, i.e. when there are not many zeros in coef_, this may actually increase memory usage, so use this method with care. A rule of thumb is that the number of zero elements, which can be computed with (coef_ == 0).sum(), must be more than 50% for this to provide significant benefits.
After calling this method, further fitting with the partial_fit method (if any) will not work until you call densify.


Passive Aggressive Classifier
Read more in the User Guide.
Maximum step size (regularization). Defaults to 1.0.
Whether the intercept should be estimated or not. If False, the data is assumed to be already centered.
The maximum number of passes over the training data (aka epochs). It only impacts the behavior in the fit method, and not the partial_fit method.
New in version 0.19.
The stopping criterion. If it is not None, the iterations will stop when (loss > previous_loss - tol).
New in version 0.19.
Whether to use early stopping to terminate training when validation. score is not improving. If set to True, it will automatically set aside a stratified fraction of training data as validation and terminate training when validation score is not improving by at least tol for n_iter_no_change consecutive epochs.
New in version 0.20.
The proportion of training data to set aside as validation set for early stopping. Must be between 0 and 1. Only used if early_stopping is True.
New in version 0.20.
Number of iterations with no improvement to wait before early stopping.
New in version 0.20.
Whether or not the training data should be shuffled after each epoch.
The verbosity level
The loss function to be used: hinge: equivalent to PA-I in the reference paper. squared_hinge: equivalent to PA-II in the reference paper.
The number of CPUs to use to do the OVA (One Versus All, for multi-class problems) computation. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors. See Glossary for more details.
Used to shuffle the training data, when shuffle is set to True. Pass an int for reproducible output across multiple function calls. See Glossary.
When set to True, reuse the solution of the previous call to fit as initialization, otherwise, just erase the previous solution. See the Glossary.
Repeatedly calling fit or partial_fit when warm_start is True can result in a different solution than when calling fit a single time because of the way the data is shuffled.
Preset for the class_weight fit parameter.
Weights associated with classes. If not given, all classes are supposed to have weight one.
The “balanced” mode uses the values of y to automatically adjust weights inversely proportional to class frequencies in the input data as n_samples / (n_classes * np.bincount(y))
New in version 0.17: parameter class_weight to automatically weight samples.
When set to True, computes the averaged SGD weights and stores the result in the coef_ attribute. If set to an int greater than 1, averaging will begin once the total number of samples seen reaches average. So average=10 will begin averaging after seeing 10 samples.
New in version 0.19: parameter average to use weights averaging in SGD
Weights assigned to the features.
Constants in decision function.
The actual number of iterations to reach the stopping criterion. For multiclass fits, it is the maximum over every binary fit.
The unique classes labels.
Number of weight updates performed during training. Same as (n_iter_ * n_samples).
Loss function used by the algorithm.
See also
Online Passive-Aggressive Algorithms <http://jmlr.csail.mit.edu/papers/volume7/crammer06a/crammer06a.pdf> K. Crammer, O. Dekel, J. Keshat, S. Shalev-Shwartz, Y. Singer - JMLR (2006)
decision_function(X)
Predict confidence scores for samples.
densify()
Convert coefficient matrix to dense array format.
fit(X, y[, coef_init, intercept_init])
Fit linear model with Passive Aggressive algorithm.
get_params([deep])
Get parameters for this estimator.
partial_fit(X, y[, classes])
Fit linear model with Passive Aggressive algorithm.
predict(X)
Predict class labels for samples in X.
score(X, y[, sample_weight])
Return the mean accuracy on the given test data and labels.
set_params(**kwargs)
Set and validate the parameters of estimator.
sparsify()
Convert coefficient matrix to sparse format.
Predict confidence scores for samples.
The confidence score for a sample is proportional to the signed distance of that sample to the hyperplane.
Samples.
Confidence scores per (sample, class) combination. In the binary case, confidence score for self.classes_[1] where >0 means this class would be predicted.
Convert coefficient matrix to dense array format.
Converts the coef_ member (back) to a numpy.ndarray. This is the default format of coef_ and is required for fitting, so calling this method is only required on models that have previously been sparsified; otherwise, it is a no-op.
Fitted estimator.
Fit linear model with Passive Aggressive algorithm.
Training data
Target values
The initial coefficients to warm-start the optimization.
The initial intercept to warm-start the optimization.
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.
Fit linear model with Passive Aggressive algorithm.
Subset of the training data
Subset of the target values
Classes across all calls to partial_fit. Can be obtained by via np.unique(y_all), where y_all is the target vector of the entire dataset. This argument is required for the first call to partial_fit and can be omitted in the subsequent calls. Note that y doesn’t need to contain all labels in classes.
Predict class labels for samples in X.
Samples.
Predicted class label per sample.
Return the mean accuracy on the given test data and labels.
In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.
Test samples.
True labels for X.
Sample weights.
Mean accuracy of self.predict(X) wrt. y.
Set and validate the parameters of estimator.
Estimator parameters.
Estimator instance.
Convert coefficient matrix to sparse format.
Converts the coef_ member to a scipy.sparse matrix, which for L1-regularized models can be much more memory- and storage-efficient than the usual numpy.ndarray representation.
The intercept_ member is not converted.
Fitted estimator.
For non-sparse models, i.e. when there are not many zeros in coef_, this may actually increase memory usage, so use this method with care. A rule of thumb is that the number of zero elements, which can be computed with (coef_ == 0).sum(), must be more than 50% for this to provide significant benefits.
After calling this method, further fitting with the partial_fit method (if any) will not work until you call densify.
Out-of-core classification of text documents
Comparing various online solvers
Classification of text documents using sparse features


Predict confidence scores for samples.
The confidence score for a sample is proportional to the signed distance of that sample to the hyperplane.
Samples.
Confidence scores per (sample, class) combination. In the binary case, confidence score for self.classes_[1] where >0 means this class would be predicted.


Convert coefficient matrix to dense array format.
Converts the coef_ member (back) to a numpy.ndarray. This is the default format of coef_ and is required for fitting, so calling this method is only required on models that have previously been sparsified; otherwise, it is a no-op.
Fitted estimator.


Fit linear model with Passive Aggressive algorithm.
Training data
Target values
The initial coefficients to warm-start the optimization.
The initial intercept to warm-start the optimization.


Fit linear model with Passive Aggressive algorithm.
Subset of the training data
Subset of the target values
Classes across all calls to partial_fit. Can be obtained by via np.unique(y_all), where y_all is the target vector of the entire dataset. This argument is required for the first call to partial_fit and can be omitted in the subsequent calls. Note that y doesn’t need to contain all labels in classes.


Predict class labels for samples in X.
Samples.
Predicted class label per sample.


Return the mean accuracy on the given test data and labels.
In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.
Test samples.
True labels for X.
Sample weights.
Mean accuracy of self.predict(X) wrt. y.


Set and validate the parameters of estimator.
Estimator parameters.
Estimator instance.


Convert coefficient matrix to sparse format.
Converts the coef_ member to a scipy.sparse matrix, which for L1-regularized models can be much more memory- and storage-efficient than the usual numpy.ndarray representation.
The intercept_ member is not converted.
Fitted estimator.
For non-sparse models, i.e. when there are not many zeros in coef_, this may actually increase memory usage, so use this method with care. A rule of thumb is that the number of zero elements, which can be computed with (coef_ == 0).sum(), must be more than 50% for this to provide significant benefits.
After calling this method, further fitting with the partial_fit method (if any) will not work until you call densify.


Passive Aggressive Regressor
Read more in the User Guide.
Maximum step size (regularization). Defaults to 1.0.
Whether the intercept should be estimated or not. If False, the data is assumed to be already centered. Defaults to True.
The maximum number of passes over the training data (aka epochs). It only impacts the behavior in the fit method, and not the partial_fit method.
New in version 0.19.
The stopping criterion. If it is not None, the iterations will stop when (loss > previous_loss - tol).
New in version 0.19.
Whether to use early stopping to terminate training when validation. score is not improving. If set to True, it will automatically set aside a fraction of training data as validation and terminate training when validation score is not improving by at least tol for n_iter_no_change consecutive epochs.
New in version 0.20.
The proportion of training data to set aside as validation set for early stopping. Must be between 0 and 1. Only used if early_stopping is True.
New in version 0.20.
Number of iterations with no improvement to wait before early stopping.
New in version 0.20.
Whether or not the training data should be shuffled after each epoch.
The verbosity level
The loss function to be used: epsilon_insensitive: equivalent to PA-I in the reference paper. squared_epsilon_insensitive: equivalent to PA-II in the reference paper.
If the difference between the current prediction and the correct label is below this threshold, the model is not updated.
Used to shuffle the training data, when shuffle is set to True. Pass an int for reproducible output across multiple function calls. See Glossary.
When set to True, reuse the solution of the previous call to fit as initialization, otherwise, just erase the previous solution. See the Glossary.
Repeatedly calling fit or partial_fit when warm_start is True can result in a different solution than when calling fit a single time because of the way the data is shuffled.
When set to True, computes the averaged SGD weights and stores the result in the coef_ attribute. If set to an int greater than 1, averaging will begin once the total number of samples seen reaches average. So average=10 will begin averaging after seeing 10 samples.
New in version 0.19: parameter average to use weights averaging in SGD
Weights assigned to the features.
Constants in decision function.
The actual number of iterations to reach the stopping criterion.
Number of weight updates performed during training. Same as (n_iter_ * n_samples).
See also
Online Passive-Aggressive Algorithms <http://jmlr.csail.mit.edu/papers/volume7/crammer06a/crammer06a.pdf> K. Crammer, O. Dekel, J. Keshat, S. Shalev-Shwartz, Y. Singer - JMLR (2006)


Read more in the User Guide.
The penalty (aka regularization term) to be used.
Constant that multiplies the regularization term if regularization is used.
The Elastic Net mixing parameter, with 0 <= l1_ratio <= 1. l1_ratio=0 corresponds to L2 penalty, l1_ratio=1 to L1. Only used if penalty='elasticnet'.
New in version 0.24.
Whether the intercept should be estimated or not. If False, the data is assumed to be already centered.
The maximum number of passes over the training data (aka epochs). It only impacts the behavior in the fit method, and not the partial_fit method.
New in version 0.19.
The stopping criterion. If it is not None, the iterations will stop when (loss > previous_loss - tol).
New in version 0.19.
Whether or not the training data should be shuffled after each epoch.
The verbosity level
Constant by which the updates are multiplied.
The number of CPUs to use to do the OVA (One Versus All, for multi-class problems) computation. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors. See Glossary for more details.
Used to shuffle the training data, when shuffle is set to True. Pass an int for reproducible output across multiple function calls. See Glossary.
Whether to use early stopping to terminate training when validation. score is not improving. If set to True, it will automatically set aside a stratified fraction of training data as validation and terminate training when validation score is not improving by at least tol for n_iter_no_change consecutive epochs.
New in version 0.20.
The proportion of training data to set aside as validation set for early stopping. Must be between 0 and 1. Only used if early_stopping is True.
New in version 0.20.
Number of iterations with no improvement to wait before early stopping.
New in version 0.20.
Preset for the class_weight fit parameter.
Weights associated with classes. If not given, all classes are supposed to have weight one.
The “balanced” mode uses the values of y to automatically adjust weights inversely proportional to class frequencies in the input data as n_samples / (n_classes * np.bincount(y))
When set to True, reuse the solution of the previous call to fit as initialization, otherwise, just erase the previous solution. See the Glossary.
The unique classes labels.
Weights assigned to the features.
Constants in decision function.
The function that determines the loss, or difference between the output of the algorithm and the target values.
The actual number of iterations to reach the stopping criterion. For multiclass fits, it is the maximum over every binary fit.
Number of weight updates performed during training. Same as (n_iter_ * n_samples).
See also
Perceptron is a classification algorithm which shares the same underlying implementation with SGDClassifier. In fact, Perceptron() is equivalent to SGDClassifier(loss="perceptron",
eta0=1, learning_rate="constant", penalty=None).
https://en.wikipedia.org/wiki/Perceptron and references therein.
decision_function(X)
Predict confidence scores for samples.
densify()
Convert coefficient matrix to dense array format.
fit(X, y[, coef_init, intercept_init, …])
Fit linear model with Stochastic Gradient Descent.
get_params([deep])
Get parameters for this estimator.
partial_fit(X, y[, classes, sample_weight])
Perform one epoch of stochastic gradient descent on given samples.
predict(X)
Predict class labels for samples in X.
score(X, y[, sample_weight])
Return the mean accuracy on the given test data and labels.
set_params(**kwargs)
Set and validate the parameters of estimator.
sparsify()
Convert coefficient matrix to sparse format.
Predict confidence scores for samples.
The confidence score for a sample is proportional to the signed distance of that sample to the hyperplane.
Samples.
Confidence scores per (sample, class) combination. In the binary case, confidence score for self.classes_[1] where >0 means this class would be predicted.
Convert coefficient matrix to dense array format.
Converts the coef_ member (back) to a numpy.ndarray. This is the default format of coef_ and is required for fitting, so calling this method is only required on models that have previously been sparsified; otherwise, it is a no-op.
Fitted estimator.
Fit linear model with Stochastic Gradient Descent.
Training data.
Target values.
The initial coefficients to warm-start the optimization.
The initial intercept to warm-start the optimization.
Weights applied to individual samples. If not provided, uniform weights are assumed. These weights will be multiplied with class_weight (passed through the constructor) if class_weight is specified.
Returns an instance of self.
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.
Perform one epoch of stochastic gradient descent on given samples.
Internally, this method uses max_iter = 1. Therefore, it is not guaranteed that a minimum of the cost function is reached after calling it once. Matters such as objective convergence and early stopping should be handled by the user.
Subset of the training data.
Subset of the target values.
Classes across all calls to partial_fit. Can be obtained by via np.unique(y_all), where y_all is the target vector of the entire dataset. This argument is required for the first call to partial_fit and can be omitted in the subsequent calls. Note that y doesn’t need to contain all labels in classes.
Weights applied to individual samples. If not provided, uniform weights are assumed.
Returns an instance of self.
Predict class labels for samples in X.
Samples.
Predicted class label per sample.
Return the mean accuracy on the given test data and labels.
In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.
Test samples.
True labels for X.
Sample weights.
Mean accuracy of self.predict(X) wrt. y.
Set and validate the parameters of estimator.
Estimator parameters.
Estimator instance.
Convert coefficient matrix to sparse format.
Converts the coef_ member to a scipy.sparse matrix, which for L1-regularized models can be much more memory- and storage-efficient than the usual numpy.ndarray representation.
The intercept_ member is not converted.
Fitted estimator.
For non-sparse models, i.e. when there are not many zeros in coef_, this may actually increase memory usage, so use this method with care. A rule of thumb is that the number of zero elements, which can be computed with (coef_ == 0).sum(), must be more than 50% for this to provide significant benefits.
After calling this method, further fitting with the partial_fit method (if any) will not work until you call densify.


Read more in the User Guide.
The penalty (aka regularization term) to be used.
Constant that multiplies the regularization term if regularization is used.
The Elastic Net mixing parameter, with 0 <= l1_ratio <= 1. l1_ratio=0 corresponds to L2 penalty, l1_ratio=1 to L1. Only used if penalty='elasticnet'.
New in version 0.24.
Whether the intercept should be estimated or not. If False, the data is assumed to be already centered.
The maximum number of passes over the training data (aka epochs). It only impacts the behavior in the fit method, and not the partial_fit method.
New in version 0.19.
The stopping criterion. If it is not None, the iterations will stop when (loss > previous_loss - tol).
New in version 0.19.
Whether or not the training data should be shuffled after each epoch.
The verbosity level
Constant by which the updates are multiplied.
The number of CPUs to use to do the OVA (One Versus All, for multi-class problems) computation. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors. See Glossary for more details.
Used to shuffle the training data, when shuffle is set to True. Pass an int for reproducible output across multiple function calls. See Glossary.
Whether to use early stopping to terminate training when validation. score is not improving. If set to True, it will automatically set aside a stratified fraction of training data as validation and terminate training when validation score is not improving by at least tol for n_iter_no_change consecutive epochs.
New in version 0.20.
The proportion of training data to set aside as validation set for early stopping. Must be between 0 and 1. Only used if early_stopping is True.
New in version 0.20.
Number of iterations with no improvement to wait before early stopping.
New in version 0.20.
Preset for the class_weight fit parameter.
Weights associated with classes. If not given, all classes are supposed to have weight one.
The “balanced” mode uses the values of y to automatically adjust weights inversely proportional to class frequencies in the input data as n_samples / (n_classes * np.bincount(y))
When set to True, reuse the solution of the previous call to fit as initialization, otherwise, just erase the previous solution. See the Glossary.
The unique classes labels.
Weights assigned to the features.
Constants in decision function.
The function that determines the loss, or difference between the output of the algorithm and the target values.
The actual number of iterations to reach the stopping criterion. For multiclass fits, it is the maximum over every binary fit.
Number of weight updates performed during training. Same as (n_iter_ * n_samples).
See also
Perceptron is a classification algorithm which shares the same underlying implementation with SGDClassifier. In fact, Perceptron() is equivalent to SGDClassifier(loss="perceptron",
eta0=1, learning_rate="constant", penalty=None).
https://en.wikipedia.org/wiki/Perceptron and references therein.
decision_function(X)
Predict confidence scores for samples.
densify()
Convert coefficient matrix to dense array format.
fit(X, y[, coef_init, intercept_init, …])
Fit linear model with Stochastic Gradient Descent.
get_params([deep])
Get parameters for this estimator.
partial_fit(X, y[, classes, sample_weight])
Perform one epoch of stochastic gradient descent on given samples.
predict(X)
Predict class labels for samples in X.
score(X, y[, sample_weight])
Return the mean accuracy on the given test data and labels.
set_params(**kwargs)
Set and validate the parameters of estimator.
sparsify()
Convert coefficient matrix to sparse format.
Predict confidence scores for samples.
The confidence score for a sample is proportional to the signed distance of that sample to the hyperplane.
Samples.
Confidence scores per (sample, class) combination. In the binary case, confidence score for self.classes_[1] where >0 means this class would be predicted.
Convert coefficient matrix to dense array format.
Converts the coef_ member (back) to a numpy.ndarray. This is the default format of coef_ and is required for fitting, so calling this method is only required on models that have previously been sparsified; otherwise, it is a no-op.
Fitted estimator.
Fit linear model with Stochastic Gradient Descent.
Training data.
Target values.
The initial coefficients to warm-start the optimization.
The initial intercept to warm-start the optimization.
Weights applied to individual samples. If not provided, uniform weights are assumed. These weights will be multiplied with class_weight (passed through the constructor) if class_weight is specified.
Returns an instance of self.
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.
Perform one epoch of stochastic gradient descent on given samples.
Internally, this method uses max_iter = 1. Therefore, it is not guaranteed that a minimum of the cost function is reached after calling it once. Matters such as objective convergence and early stopping should be handled by the user.
Subset of the training data.
Subset of the target values.
Classes across all calls to partial_fit. Can be obtained by via np.unique(y_all), where y_all is the target vector of the entire dataset. This argument is required for the first call to partial_fit and can be omitted in the subsequent calls. Note that y doesn’t need to contain all labels in classes.
Weights applied to individual samples. If not provided, uniform weights are assumed.
Returns an instance of self.
Predict class labels for samples in X.
Samples.
Predicted class label per sample.
Return the mean accuracy on the given test data and labels.
In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.
Test samples.
True labels for X.
Sample weights.
Mean accuracy of self.predict(X) wrt. y.
Set and validate the parameters of estimator.
Estimator parameters.
Estimator instance.
Convert coefficient matrix to sparse format.
Converts the coef_ member to a scipy.sparse matrix, which for L1-regularized models can be much more memory- and storage-efficient than the usual numpy.ndarray representation.
The intercept_ member is not converted.
Fitted estimator.
For non-sparse models, i.e. when there are not many zeros in coef_, this may actually increase memory usage, so use this method with care. A rule of thumb is that the number of zero elements, which can be computed with (coef_ == 0).sum(), must be more than 50% for this to provide significant benefits.
After calling this method, further fitting with the partial_fit method (if any) will not work until you call densify.
Out-of-core classification of text documents
Comparing various online solvers
Classification of text documents using sparse features


Fit linear model with Stochastic Gradient Descent.
Training data.
Target values.
The initial coefficients to warm-start the optimization.
The initial intercept to warm-start the optimization.
Weights applied to individual samples. If not provided, uniform weights are assumed. These weights will be multiplied with class_weight (passed through the constructor) if class_weight is specified.
Returns an instance of self.


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.


Perform one epoch of stochastic gradient descent on given samples.
Internally, this method uses max_iter = 1. Therefore, it is not guaranteed that a minimum of the cost function is reached after calling it once. Matters such as objective convergence and early stopping should be handled by the user.
Subset of the training data.
Subset of the target values.
Classes across all calls to partial_fit. Can be obtained by via np.unique(y_all), where y_all is the target vector of the entire dataset. This argument is required for the first call to partial_fit and can be omitted in the subsequent calls. Note that y doesn’t need to contain all labels in classes.
Weights applied to individual samples. If not provided, uniform weights are assumed.
Returns an instance of self.


Generalized Linear Model with a Poisson distribution.
Read more in the User Guide.
New in version 0.23.
Constant that multiplies the penalty term and thus determines the regularization strength. alpha = 0 is equivalent to unpenalized GLMs. In this case, the design matrix X must have full column rank (no collinearities).
Specifies if a constant (a.k.a. bias or intercept) should be added to the linear predictor (X @ coef + intercept).
The maximal number of iterations for the solver.
Stopping criterion. For the lbfgs solver, the iteration will stop when max{|g_j|, j = 1, ..., d} <= tol where g_j is the j-th component of the gradient (derivative) of the objective function.
If set to True, reuse the solution of the previous call to fit as initialization for coef_ and intercept_ .
For the lbfgs solver set verbose to any positive number for verbosity.
Estimated coefficients for the linear predictor (X @ coef_ +
intercept_) in the GLM.
Intercept (a.k.a. bias) added to linear predictor.
Actual number of iterations used in the solver.
fit(X, y[, sample_weight])
Fit a Generalized Linear Model.
get_params([deep])
Get parameters for this estimator.
predict(X)
Predict using GLM with feature matrix X.
score(X, y[, sample_weight])
Compute D^2, the percentage of deviance explained.
set_params(**params)
Set the parameters of this estimator.
Fit a Generalized Linear Model.
Training data.
Target values.
Sample weights.
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 GLM with feature matrix X.
Samples.
Returns predicted values.
Compute D^2, the percentage of deviance explained.
D^2 is a generalization of the coefficient of determination R^2. R^2 uses squared error and D^2 deviance. Note that those two are equal for family='normal'.
D^2 is defined as \(D^2 = 1-\frac{D(y_{true},y_{pred})}{D_{null}}\), \(D_{null}\) is the null deviance, i.e. the deviance of a model with intercept alone, which corresponds to \(y_{pred} = \bar{y}\). The mean \(\bar{y}\) is averaged by sample_weight. Best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse).
Test samples.
True values of target.
Sample weights.
D^2 of self.predict(X) w.r.t. y.
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.


Generalized Linear Model with a Poisson distribution.
Read more in the User Guide.
New in version 0.23.
Constant that multiplies the penalty term and thus determines the regularization strength. alpha = 0 is equivalent to unpenalized GLMs. In this case, the design matrix X must have full column rank (no collinearities).
Specifies if a constant (a.k.a. bias or intercept) should be added to the linear predictor (X @ coef + intercept).
The maximal number of iterations for the solver.
Stopping criterion. For the lbfgs solver, the iteration will stop when max{|g_j|, j = 1, ..., d} <= tol where g_j is the j-th component of the gradient (derivative) of the objective function.
If set to True, reuse the solution of the previous call to fit as initialization for coef_ and intercept_ .
For the lbfgs solver set verbose to any positive number for verbosity.
Estimated coefficients for the linear predictor (X @ coef_ +
intercept_) in the GLM.
Intercept (a.k.a. bias) added to linear predictor.
Actual number of iterations used in the solver.
fit(X, y[, sample_weight])
Fit a Generalized Linear Model.
get_params([deep])
Get parameters for this estimator.
predict(X)
Predict using GLM with feature matrix X.
score(X, y[, sample_weight])
Compute D^2, the percentage of deviance explained.
set_params(**params)
Set the parameters of this estimator.
Fit a Generalized Linear Model.
Training data.
Target values.
Sample weights.
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 GLM with feature matrix X.
Samples.
Returns predicted values.
Compute D^2, the percentage of deviance explained.
D^2 is a generalization of the coefficient of determination R^2. R^2 uses squared error and D^2 deviance. Note that those two are equal for family='normal'.
D^2 is defined as \(D^2 = 1-\frac{D(y_{true},y_{pred})}{D_{null}}\), \(D_{null}\) is the null deviance, i.e. the deviance of a model with intercept alone, which corresponds to \(y_{pred} = \bar{y}\). The mean \(\bar{y}\) is averaged by sample_weight. Best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse).
Test samples.
True values of target.
Sample weights.
D^2 of self.predict(X) w.r.t. y.
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.
Release Highlights for scikit-learn 0.23
Poisson regression and non-normal loss
Tweedie regression on insurance claims


Fit a Generalized Linear Model.
Training data.
Target values.
Sample weights.


Predict using GLM with feature matrix X.
Samples.
Returns predicted values.


Compute D^2, the percentage of deviance explained.
D^2 is a generalization of the coefficient of determination R^2. R^2 uses squared error and D^2 deviance. Note that those two are equal for family='normal'.
D^2 is defined as \(D^2 = 1-\frac{D(y_{true},y_{pred})}{D_{null}}\), \(D_{null}\) is the null deviance, i.e. the deviance of a model with intercept alone, which corresponds to \(y_{pred} = \bar{y}\). The mean \(\bar{y}\) is averaged by sample_weight. Best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse).
Test samples.
True values of target.
Sample weights.
D^2 of self.predict(X) w.r.t. y.


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.


RANSAC (RANdom SAmple Consensus) algorithm.
RANSAC is an iterative algorithm for the robust estimation of parameters from a subset of inliers from the complete data set.
Read more in the User Guide.
Base estimator object which implements the following methods:
If base_estimator is None, then LinearRegression is used for target values of dtype float.
Note that the current implementation only supports regression estimators.
Minimum number of samples chosen randomly from original data. Treated as an absolute number of samples for min_samples >= 1, treated as a relative number ceil(min_samples * X.shape[0]) for min_samples < 1. This is typically chosen as the minimal number of samples necessary to estimate the given base_estimator. By default a sklearn.linear_model.LinearRegression() estimator is assumed and min_samples is chosen as X.shape[1] + 1.
Maximum residual for a data sample to be classified as an inlier. By default the threshold is chosen as the MAD (median absolute deviation) of the target values y.
This function is called with the randomly selected data before the model is fitted to it: is_data_valid(X, y). If its return value is False the current randomly chosen sub-sample is skipped.
This function is called with the estimated model and the randomly selected data: is_model_valid(model, X, y). If its return value is False the current randomly chosen sub-sample is skipped. Rejecting samples with this function is computationally costlier than with is_data_valid. is_model_valid should therefore only be used if the estimated model is needed for making the rejection decision.
Maximum number of iterations for random sample selection.
Maximum number of iterations that can be skipped due to finding zero inliers or invalid data defined by is_data_valid or invalid models defined by is_model_valid.
New in version 0.19.
Stop iteration if at least this number of inliers are found.
Stop iteration if score is greater equal than this threshold.
RANSAC iteration stops if at least one outlier-free set of the training data is sampled in RANSAC. This requires to generate at least N samples (iterations):
where the probability (confidence) is typically set to high value such as 0.99 (the default) and e is the current fraction of inliers w.r.t. the total number of samples.
String inputs, “absolute_loss” and “squared_loss” are supported which find the absolute loss and squared loss per sample respectively.
If loss is a callable, then it should be a function that takes two arrays as inputs, the true and predicted value and returns a 1-D array with the i-th value of the array corresponding to the loss on X[i].
If the loss on a sample is greater than the residual_threshold, then this sample is classified as an outlier.
New in version 0.18.
The generator used to initialize the centers. Pass an int for reproducible output across multiple function calls. See Glossary.
Best fitted model (copy of the base_estimator object).
Number of random selection trials until one of the stop criteria is met. It is always <= max_trials.
Boolean mask of inliers classified as True.
Number of iterations skipped due to finding zero inliers.
New in version 0.19.
Number of iterations skipped due to invalid data defined by is_data_valid.
New in version 0.19.
Number of iterations skipped due to an invalid model defined by is_model_valid.
New in version 0.19.
https://en.wikipedia.org/wiki/RANSAC
https://www.sri.com/sites/default/files/publications/ransac-publication.pdf
http://www.bmva.org/bmvc/2009/Papers/Paper355/Paper355.pdf
fit(X, y[, sample_weight])
Fit estimator using RANSAC algorithm.
get_params([deep])
Get parameters for this estimator.
predict(X)
Predict using the estimated model.
score(X, y)
Returns the score of the prediction.
set_params(**params)
Set the parameters of this estimator.
Fit estimator using RANSAC algorithm.
Training data.
Target values.
Individual weights for each sample raises error if sample_weight is passed and base_estimator fit method does not support it.
New in version 0.18.
If no valid consensus set could be found. This occurs if is_data_valid and is_model_valid return False for all max_trials randomly chosen sub-samples.
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 estimated model.
This is a wrapper for estimator_.predict(X).
Returns predicted values.
Returns the score of the prediction.
This is a wrapper for estimator_.score(X, y).
Training data.
Target values.
Score of the prediction.
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.