Skip to content

Commit 7b75ebb

Browse files
committed
FIX: Raise ValueError for invalid precompute
1 parent 37c65e5 commit 7b75ebb

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

sklearn/linear_model/coordinate_descent.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,9 +474,12 @@ def enet_path(X, y, l1_ratio=0.5, eps=1e-3, n_alphas=100, alphas=None,
474474
model = cd_fast.enet_coordinate_descent_gram(
475475
coef_, l1_reg, l2_reg, precompute, Xy, y, max_iter,
476476
tol, positive)
477-
else:
477+
elif precompute is False:
478478
model = cd_fast.enet_coordinate_descent(
479479
coef_, l1_reg, l2_reg, X, y, max_iter, tol, positive)
480+
else:
481+
raise ValueError("Precompute should be one of True, False, "
482+
"'auto' or array-like")
480483
coef_, dual_gap_, eps_ = model
481484
coefs[..., i] = coef_
482485
dual_gaps[i] = dual_gap_

sklearn/linear_model/tests/test_coordinate_descent.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,13 @@ def test_sparse_input_dtype_enet_and_lassocv():
460460
assert_almost_equal(clf.coef_, clf1.coef_, decimal=6)
461461

462462

463+
def test_precompute_invalid_argument():
464+
X, y, _, _ = build_dataset()
465+
for clf in [ElasticNetCV(precompute="invalid"),
466+
LassoCV(precompute="invalid")]:
467+
assert_raises(ValueError, clf.fit, X, y)
468+
469+
463470
if __name__ == '__main__':
464471
import nose
465472
nose.runmodule()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy