-
-
Notifications
You must be signed in to change notification settings - Fork 26.2k
Closed
Labels
Description
__________________________ test_rank_deficient_design __________________________
[gw0] linux -- Python 3.7.10 /opt/conda/envs/testvenv/bin/python
@filterwarnings_normalize
def test_rank_deficient_design():
# consistency test that checks that LARS Lasso is handling rank
# deficient input data (with n_features < rank) in the same way
# as coordinate descent Lasso
y = [5, 0, 5]
for X in ([[5, 0], [0, 5], [10, 10]], [[10, 10, 0], [1e-32, 0, 0], [0, 0, 1]]):
# To be able to use the coefs to compute the objective function,
# we need to turn off normalization
lars = linear_model.LassoLars(0.1, normalize=False)
coef_lars_ = lars.fit(X, y).coef_
obj_lars = 1.0 / (2.0 * 3.0) * linalg.norm(
y - np.dot(X, coef_lars_)
) ** 2 + 0.1 * linalg.norm(coef_lars_, 1)
coord_descent = linear_model.Lasso(0.1, tol=1e-6)
coef_cd_ = coord_descent.fit(X, y).coef_
obj_cd = (1.0 / (2.0 * 3.0)) * linalg.norm(
y - np.dot(X, coef_cd_)
) ** 2 + 0.1 * linalg.norm(coef_cd_, 1)
> assert obj_lars < obj_cd * (1.0 + 1e-8)
E assert 5.233333333333334 < (0.5711500859559147 * (1.0 + 1e-08))
X = [[10, 10, 0], [1e-32, 0, 0], [0, 0, 1]]
coef_cd_ = array([0.46399995, 0. , 4.36999974])
coef_lars_ = array([0.23139881, 0.01860119, 0. ])
coord_descent = Lasso(alpha=0.1, tol=1e-06)
lars = LassoLars(alpha=0.1, normalize=False)
obj_cd = 0.5711500859559147
obj_lars = 5.233333333333334
y = [5, 0, 5]
/io/sklearn/linear_model/tests/test_least_angle.py:275: AssertionError
I observed it on the PyPy job of this run https://dev.azure.com/scikit-learn/scikit-learn/_build/results?buildId=33620&view=logs&j=4bf7db7d-871b-58a8-7a17-6422cd8cd95c&t=a83e08b8-0f82-57e0-bc8b-2673a297e284 but @lesteve saw the same failure elsewhere and can reproduce it locally with regular CPython.