The Lasso
is a linear model that estimates sparse coefficients.
It is useful in some contexts due to its tendency to prefer solution with fewer parameter values, effectively reducing the number of variables upon which the given solution is dependent.
The Lasso
and its variants are fundamental to the field of compressed sensing.
The Lasso
consists of a linear model trained with l1
prior as regularizer. The objective function to minimize is
$ min_{w}\frac{1}{2n_{samples}} || Xw - y||_2^2 + \alpha ||w||_1$
In [1]:
from sklearn import linear_model
clf = linear_model.Lasso(alpha=0.1)
clf.fit([[0,0],[1,1]], [0,1])
Out[1]:
In [2]:
clf.predict([[1,1]])
Out[2]:
In [3]:
clf.coef_
Out[3]:
In [4]:
clf.intercept_
Out[4]:
In [ ]:
In [ ]: