-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
Closed
Closed
Copy link
Labels
BugEasyWell-defined and straightforward way to resolveWell-defined and straightforward way to resolve
Description
Description
'MultiTaskLasso' object has no attribute 'coef_' with warm_start = True. The code is reproduced from the scikit-learn MultiTaskLasso example notebook with warm_start set to true.
Steps/Code to Reproduce
import matplotlib.pyplot as plt
import numpy as np
from sklearn.linear_model import MultiTaskLasso
rng = np.random.RandomState(42)
# Generate some 2D coefficients with sine waves with random frequency and phase
n_samples, n_features, n_tasks = 100, 30, 40
n_relevant_features = 5
coef = np.zeros((n_tasks, n_features))
times = np.linspace(0, 2 * np.pi, n_tasks)
for k in range(n_relevant_features):
coef[:, k] = np.sin((1. + rng.randn(1)) * times + 3 * rng.randn(1))
X = rng.randn(n_samples, n_features)
Y = np.dot(X, coef.T) + rng.randn(n_samples, n_tasks)
coef_multi_task_lasso_ = MultiTaskLasso(alpha=1., warm_start = True).fit(X, Y).coef_Expected Results
No error is thrown.
Actual Results
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-2-445bda46f02e> in <module>()
22 Y = np.dot(X, coef.T) + rng.randn(n_samples, n_tasks)
23
---> 24 coef_multi_task_lasso_ = MultiTaskLasso(alpha=1., warm_start = True).fit(X, Y).coef_
/anaconda3/lib/python3.6/site-packages/sklearn/linear_model/coordinate_descent.py in fit(self, X, y)
1794 X, y, self.fit_intercept, self.normalize, copy=False)
1795
-> 1796 if not self.warm_start or self.coef_ is None:
1797 self.coef_ = np.zeros((n_tasks, n_features), dtype=X.dtype.type,
1798 order='F')
AttributeError: 'MultiTaskLasso' object has no attribute 'coef_'
Versions
System
------
python: 3.6.3 |Anaconda custom (64-bit)| (default, Oct 6 2017, 12:04:38) [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]
executable: /anaconda3/bin/python
machine: Darwin-17.2.0-x86_64-i386-64bit
BLAS
----
macros: SCIPY_MKL_H=None, HAVE_CBLAS=None
lib_dirs: /anaconda3/lib
cblas_libs: mkl_rt, pthread
Python deps
-----------
pip: 9.0.1
setuptools: 36.5.0.post20170921
sklearn: 0.20.0
numpy: 1.13.3
scipy: 1.0.0
Cython: 0.28.5
pandas: 0.20.3
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugEasyWell-defined and straightforward way to resolveWell-defined and straightforward way to resolve