This page

scikits.learn.linear_model.LassoLARS

class scikits.learn.linear_model.LassoLARS(alpha=1.0, fit_intercept=True, verbose=False)

Lasso model fit with Least Angle Regression a.k.a. LARS

It is a Linear Model trained with an L1 prior as regularizer. lasso).

Parameters :

alpha : float, optional

Constant that multiplies the L1 term. Defaults to 1.0

fit_intercept : boolean

whether to calculate the intercept for this model. If set to false, no intercept will be used in calculations (e.g. data is expected to be already centered).

See also

lars_path, Lasso

References

http://en.wikipedia.org/wiki/Least_angle_regression

Examples

>>> from scikits.learn import linear_model
>>> clf = linear_model.LassoLARS(alpha=0.01)
>>> clf.fit([[-1,1], [0, 0], [1, 1]], [-1, 0, -1])
LassoLARS(alpha=0.01, verbose=False, fit_intercept=True)
>>> print clf.coef_
[ 0.         -0.72649658]

Attributes

coef_ array, shape = [n_features] parameter vector (w in the fomulation formula)
intercept_ float independent term in decision function.

Methods

__init__(alpha=1.0, fit_intercept=True, verbose=False)
fit(X, y, normalize=True, max_features=None, precompute='auto', overwrite_X=False, **params)

Fit the model using X, y as training data.

Parameters :

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

Training data.

y : array-like, shape = [n_samples]

Target values.

precompute : True | False | ‘auto’ | array-like

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.

Returns :

self : object

returns an instance of self.

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 of the prediction

Parameters :

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

Training set.

y : array-like, shape = [n_samples]

Returns :

z : float