10000 TST : speed up tests + cosmit · mohitsingh1007/scikit-learn@a64ec51 · GitHub
[go: up one dir, main page]

Skip to content

Commit a64ec51

Browse files
committed
TST : speed up tests + cosmit
1 parent d6e7e51 commit a64ec51

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

sklearn/linear_model/coordinate_descent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ class ElasticNetCV(LinearModelCV, RegressorMixin):
11711171
all the CPUs. Note that this is used only if multiple values for
11721172
l1_ratio are given.
11731173
1174-
positive: bool, optional
1174+
positive: bool, optional
11751175
When set to ``True``, forces the coefficients to be positive.
11761176
11771177
Attributes

sklearn/linear_model/tests/test_coordinate_descent.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,16 @@ def test_lasso_cv():
181181

182182
def test_lasso_cv_positive_constraint():
183183
X, y, X_test, y_test = build_dataset()
184-
max_iter = 1000
184+
max_iter = 500
185185

186186
# Ensure the unconstrained fit has a negative coefficient
187-
clf_unconstrained = LassoCV(n_alphas=10, eps=1e-3, max_iter=max_iter)
187+
clf_unconstrained = LassoCV(n_alphas=3, eps=1e-1, max_iter=max_iter, cv=2)
188188
clf_unconstrained.fit(X, y)
189189
assert_true(min(clf_unconstrained.coef_) < 0)
190190

191191
# On same data, constrained fit has non-negative coefficients
192-
clf_constrained = LassoCV(n_alphas=10, eps=1e-3, max_iter=max_iter,
193-
positive=True)
192+
clf_constrained = LassoCV(n_alphas=3, eps=1e-1, max_iter=max_iter,
193+
positive=True, cv=2)
194194
clf_constrained.fit(X, y)
195195
assert_true(min(clf_constrained.coef_) >= 0)
196196

@@ -318,15 +318,17 @@ def test_enet_positive_constraint():
318318

319319
def test_enet_cv_positive_constraint():
320320
X, y, X_test, y_test = build_dataset()
321-
max_iter = 1500
321+
max_iter = 500
322322

323323
# Ensure the unconstrained fit has a negative coefficient
324-
enetcv_unconstrained = ElasticNetCV(max_iter=max_iter)
324+
enetcv_unconstrained = ElasticNetCV(n_alphas=3, eps=1e-1, max_iter=max_iter,
325+
cv=2)
325326
enetcv_unconstrained.fit(X, y)
326327
assert_true(min(enetcv_unconstrained.coef_) < 0)
327328

328329
# On same data, constrained fit has non-negative coefficients
329-
enetcv_constrained = ElasticNetCV(max_iter=max_iter, positive=True)
330+
enetcv_constrained = ElasticNetCV(n_alphas=3, eps=1e-1, max_iter=max_iter,
331+
cv=2, positive=True)
330332
enetcv_constrained.fit(X, y)
331333
assert_true(min(enetcv_constrained.coef_) >= 0)
332334

0 commit comments

Comments
 (0)
0