skglm.Lasso¶
- class skglm.Lasso(alpha=1.0, max_iter=50, max_epochs=50000, p0=10, verbose=0, tol=0.0001, positive=False, fit_intercept=True, warm_start=False, ws_strategy='subdiff')[source]¶
Lasso estimator based on Celer solver and primal extrapolation.
The optimization objective for Lasso is:
`1 / (2 xx n_"samples") ||y - Xw||_2 ^ 2 + alpha ||w||_1`- Parameters:
- alphafloat, optional
Penalty strength.
- max_iterint, optional
The maximum number of iterations (subproblem definitions).
- max_epochsint
Maximum number of CD epochs on each subproblem.
- p0int
First working set size.
- verbosebool or int
Amount of verbosity.
- tolfloat, optional
Stopping criterion for the optimization.
- positivebool, optional
When set to
True
, forces the coefficient vector to be positive.- fit_interceptbool, optional (default=True)
Whether or not to fit an intercept.
- warm_startbool, optional (default=False)
When set to
True
, reuse the solution of the previous call to fit as initialization, otherwise, just erase the previous solution.- ws_strategystr
The score used to build the working set. Can be
"fixpoint"
or"subdiff"
.
See also
WeightedLasso
Weighted Lasso regularization.
MCPRegression
Sparser regularization than L1 norm.
- Attributes:
- coef_array, shape (n_features,)
parameter vector (`w` in the cost function formula)
- sparse_coef_scipy.sparse matrix, shape (n_features, 1)
sparse_coef_
is a readonly property derived fromcoef_
- intercept_float
constant term in decision function.
- n_iter_int
Number of subproblems solved to reach the specified tolerance.
- __init__(alpha=1.0, max_iter=50, max_epochs=50000, p0=10, verbose=0, tol=0.0001, positive=False, fit_intercept=True, warm_start=False, ws_strategy='subdiff')[source]¶
Methods
__init__
([alpha, max_iter, max_epochs, p0, ...])fit
(X, y)Fit the model according to the given training data.
get_metadata_routing
()Get metadata routing of this object.
get_params
([deep])Get parameters for this estimator.
path
(X, y, alphas[, coef_init, return_n_iter])Compute Lasso path.
predict
(X)Predict using the linear model.
score
(X, y[, sample_weight])Return the coefficient of determination of the prediction.
set_params
(**params)Set the parameters of this estimator.
set_score_request
(*[, sample_weight])Request metadata passed to the
score
method.