diff --git a/sklearn/linear_model/coordinate_descent.py b/sklearn/linear_model/coordinate_descent.py index 0ad9a8f6dc53f..c8907574121a0 100644 --- a/sklearn/linear_model/coordinate_descent.py +++ b/sklearn/linear_model/coordinate_descent.py @@ -1796,7 +1796,7 @@ def fit(self, X, y): X, y, X_offset, y_offset, X_scale = _preprocess_data( X, y, self.fit_intercept, self.normalize, copy=False) - if not self.warm_start or self.coef_ is None: + if not self.warm_start or not hasattr(self, "coef_"): self.coef_ = np.zeros((n_tasks, n_features), dtype=X.dtype.type, order='F') diff --git a/sklearn/linear_model/tests/test_coordinate_descent.py b/sklearn/linear_model/tests/test_coordinate_descent.py index ee152cc8d209d..51199dba8ea74 100644 --- a/sklearn/linear_model/tests/test_coordinate_descent.py +++ b/sklearn/linear_model/tests/test_coordinate_descent.py @@ -818,3 +818,11 @@ def test_coef_shape_not_zero(): est_no_intercept = Lasso(fit_intercept=False) est_no_intercept.fit(np.c_[np.ones(3)], np.ones(3)) assert est_no_intercept.coef_.shape == (1,) + + +def test_multi_task_lasso_warm_start(): + X = np.array([[1, 2, 4, 5, 8], [3, 5, 7, 7, 8]]).T + y = np.array([12, 10, 11, 21, 5])[:, np.newaxis] + + est = MultiTaskLasso(warm_start=True) + est.fit(X, y)