Contents

scikits.learn.glm.LassoLARS

class scikits.learn.glm.LassoLARS(alpha=1.0, max_features=None, normalize=True, fit_intercept=True)

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).

Notes

See examples/glm/plot_lasso_lars.py for an example.

See also scikits.learn.glm.Lasso that fits the same model using an alternative optimization strategy called ‘coordinate descent.’

Examples

>>> from scikits.learn import glm
>>> clf = glm.LassoLARS(alpha=0.1)
>>> clf.fit([[-1,1], [0, 0], [1, 1]], [-1, 0, -1])
LassoLARS(max_features=None, alpha=0.1, normalize=True, fit_intercept=True)
>>> print clf.coef_
[ 0.         -0.51649658]

Attributes

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

Methods

fit
predict
score
__init__(alpha=1.0, max_features=None, normalize=True, fit_intercept=True)

XXX : add doc # will only normalize non-zero columns

fit(X, y, Gram=None, **params)

XXX : add doc

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

Parameters :

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

Training set.

y : array-like, shape = [n_samples]

Returns :

z : float