-
-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Closed
Closed
Copy link
Labels
Description
Description
LassoLarsIC delivers wrong coef_
when the model can fit the data with variance 0
Steps/Code to Reproduce
Example:
import numpy as np
from sklearn.linear_model import LassoLarsIC
def check_lassoIC_positive_trivial(add_noise=True):
est = LassoLarsIC(fit_intercept=False, positive=True)
y = np.array([0., 1, 2, 3, 4, 5, 6, 7])
x = y.copy()
X = np.c_[x, x*x]
if add_noise:
y += np.random.uniform(len(y)) * 0.01
est.fit(X.copy(), y)
preds = est.predict(X)
print(est.coef_)
return est.coef_
coef = check_lassoIC_positive_trivial(add_noise=True)
assert np.allclose(coef[1], 0.)
# This one fails
coef = check_lassoIC_positive_trivial(add_noise=False)
assert np.allclose(coef[1], 0.)
Expected Results
For both tests should run.
Actual Results
second test fails
Versions
Linux-3.2.0-4-amd64-x86_64-with-debian-7.11
('Python', '2.7.3 (default, Mar 13 2014, 11:03:55) \n[GCC 4.7.2]')
('NumPy', '1.14.0')
('SciPy', '0.19.1')
('Scikit-Learn', '0.19.1')