Skip to content
vene edited this page Jun 20, 2012 · 3 revisions

Speed improvments in linear models.

Multiple targets

This makes linear models accept 2d arrays for y intelligently, by moving redundant computation out of the loop. This does NOT mean multitask learning, the correlation between the targets is not taken into account, it's the same as y.shape[1] different copies of the estimator.

Lars

In [8]: from sklearn.datasets import make_regression In [9]: from sklearn.linear_model import LassoLars In [10]: X, y = make_regression(1000, 1000, 10, n_targets=50) In [11]: def fit_iter(X, Y): ....: for y in Y.T: ....: LassoLars(1.0, precompute=True).fit(X, y) ....: In [12]: def fit_once(X, y): ....: LassoLars(1.0, precompute=True).fit(X, y) ....: In [13]: %timeit fit_once(X, y) 1 loops, best of 3: 824 ms per loop In [14]: %timeit fit_iter(X, y) 1 loops, best of 3: 10.1 s per loop

Clone this wiki locally