This documentation is for scikit-learn version 0.11-gitOther versions

Citing

If you use the software, please consider citing scikit-learn.

This page

8.15.2.1. sklearn.linear_model.sparse.Lasso

class sklearn.linear_model.sparse.Lasso(alpha=1.0, fit_intercept=False, normalize=False, max_iter=1000, tol=0.0001)

Linear Model trained with L1 prior as regularizer

This implementation works on scipy.sparse X and dense coef_. Technically this is the same as Elastic Net with the L2 penalty set to zero.

Parameters :

alpha : float

Constant that multiplies the L1 term. Defaults to 1.0

`coef_` : ndarray of shape n_features

The initial coeffients to warm-start the optimization

fit_intercept: bool :

Whether the intercept should be estimated or not. If False, the data is assumed to be already centered.

Methods

decision_function(X) Decision function of the linear model
fit(X, y) Fit current model with coordinate descent
get_params([deep]) Get parameters for the estimator
predict(X) Predict using the linear model
score(X, y) Returns the coefficient of determination R^2 of the prediction.
set_params(**params) Set the parameters of the estimator.
__init__(alpha=1.0, fit_intercept=False, normalize=False, max_iter=1000, tol=0.0001)
decision_function(X)

Decision function of the linear model

Parameters :X : scipy.sparse matrix of shape [n_samples, n_features]
Returns :array, shape = [n_samples] with the predicted real values :
fit(X, y)

Fit current model with coordinate descent

X is expected to be a sparse matrix. For maximum efficiency, use a sparse matrix in CSC format (scipy.sparse.csc_matrix)

get_params(deep=True)

Get parameters for the estimator

Parameters :

deep: boolean, optional :

If True, will return the parameters for this estimator and contained subobjects that are estimators.

predict(X)

Predict using the linear model

Parameters :

X : numpy array of shape [n_samples, n_features]

Returns :

C : array, shape = [n_samples]

Returns predicted values.

score(X, y)

Returns the coefficient of determination R^2 of the prediction.

The coefficient R^2 is defined as (1 - u/v), where u is the regression sum of squares ((y - y_pred) ** 2).sum() and v is the residual sum of squares ((y_true - y_true.mean()) ** 2).sum(). Best possible score is 1.0, lower values are worse.

Parameters :

X : array-like, shape = [n_samples, n_features]

Training set.

y : array-like, shape = [n_samples]

Returns :

z : float

set_params(**params)

Set the parameters of the estimator.

The method works on simple estimators as well as on nested objects (such as pipelines). The former have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Returns :self :