celer.Lasso

class celer.Lasso(alpha=1.0, max_iter=100, gap_freq=10, max_epochs=50000, p0=10, verbose=0, tol=0.0001, prune=0, fit_intercept=True, normalize=False)

Lasso scikit-learn estimator based on Celer solver

The optimization objective for Lasso is:

(1 / (2 * n_samples)) * ||y - X w||^2_2 + alpha * ||w||_1
Parameters:
alpha : float, optional

Constant that multiplies the L1 term. Defaults to 1.0. alpha = 0 is equivalent to an ordinary least square. For numerical reasons, using alpha = 0 with the Lasso object is not advised.

max_iter : int, optional

The maximum number of iterations (subproblem definitions)

gap_freq : int

Number of coordinate descent epochs between each duality gap computations.

max_epochs : int

Maximum number of CD epochs on each subproblem.

p0 : int

First working set size.

verbose : bool or integer

Amount of verbosity.

tol : float, optional

The tolerance for the optimization: the solver runs until the duality gap is smaller than tol or the maximum number of iteration is reached.

prune : 0 | 1, optional

Whether or not to use pruning when growing working sets.

fit_intercept : bool, optional (default=True)

Whether or not to fit an intercept.

normalize : bool, optional (default=False)

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.

See also

celer_path, LassoCV

References

[1]
  1. Massias, A. Gramfort, J. Salmon
“Celer: a Fast Solver for the Lasso wit Dual Extrapolation”, ICML 2018,

http://proceedings.mlr.press/v80/massias18a.html

Examples

>>> from celer import Lasso
>>> clf = Lasso(alpha=0.1)
>>> clf.fit([[0, 0], [1, 1], [2, 2]], [0, 1, 2])
Lasso(alpha=0.1, gap_freq=10, max_epochs=50000, max_iter=100,
p0=10, prune=0, tol=1e-06, verbose=0)
>>> print(clf.coef_)
[0.85 0.  ]
>>> print(clf.intercept_)
0.15
Attributes:
coef_ : array, shape (n_features,)

parameter vector (w in the cost function formula)

sparse_coef_ : scipy.sparse matrix, shape (n_features, 1)

sparse representation of the fitted coef_

intercept_ : float

constant term in decision function.

n_iter_ : int

number of subproblems solved by celer to reach the specified tolerance.

__init__(alpha=1.0, max_iter=100, gap_freq=10, max_epochs=50000, p0=10, verbose=0, tol=0.0001, prune=0, fit_intercept=True, normalize=False)

Methods

__init__([alpha, max_iter, gap_freq, …])
fit(X, y[, check_input]) Fit model with coordinate descent.
get_params([deep]) Get parameters for this estimator.
path(X, y, alphas, **kwargs) Compute Lasso path with Celer.
predict(X) Predict using the linear model
score(X, y[, sample_weight]) Returns the coefficient of determination R^2 of the prediction.
set_params(**params) Set the parameters of this estimator.
Fork me on GitHub