sklearn provides the LASSO method for estimating regression. However, when I try to install LassoCV (X, y) with a y matrix, it throws an error. See the screenshot below and the link for their documentation. The sklearn version I'm using is 0.15.2.
http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LassoCV.html#sklearn.linear_model.LassoCV
His doc says y can be ndarray:
y : array-like, shape (n_samples,) or (n_samples, n_targets)
When I use only Lasso () to match the same X, and y, it works fine. So I wonder if LassoCV () is broken, or do I need to do something else?
In [2]: import numpy as np im In [3]: import sklearn.linear_model In [4]: from sklearn import linear_model In [5]: X = np.random.random((10,100)) In [6]: y = np.random.random((50, 100)) In [7]: linear_model.Lasso().fit(X,y) Out[7]: Lasso(alpha=1.0, copy_X=True, fit_intercept=True, max_iter=1000, normalize=False, positive=False, precompute='auto', tol=0.0001, warm_start=False) In [8]: linear_model.LassoCV().fit(X,y) --------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-8-9c8ad3459ac8> in <module>() ----> 1 linear_model.LassoCV().fit(X,y) /chimerahomes/wenhoujx/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/sklearn/linear_model/coordinate_descent.pyc in fit(self, X, y) 1006 if y.ndim > 1: 1007 raise ValueError("For multi-task outputs, use " -> 1008 "MultiTask%sCV" % (model_str)) 1009 else: 1010 if sparse.isspmatrix(X): ValueError: For multi-task outputs, use MultiTaskLassoCV In [9]:
It seems that a couple of ElasticCV () and Elastic () have the same situation, the first () suggests using multitask-ElasticCV (), and the latter works fine for a 2d matrix.