@@ -181,16 +181,16 @@ def test_lasso_cv():
181
181
182
182
def test_lasso_cv_positive_constraint ():
183
183
X , y , X_test , y_test = build_dataset ()
184
- max_iter = 1000
184
+ max_iter = 500
185
185
186
186
# 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 )
188
188
clf_unconstrained .fit (X , y )
189
189
assert_true (min (clf_unconstrained .coef_ ) < 0 )
190
190
191
191
# 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 )
194
194
clf_constrained .fit (X , y )
195
195
assert_true (min (clf_constrained .coef_ ) >= 0 )
196
196
@@ -318,15 +318,17 @@ def test_enet_positive_constraint():
318
318
319
319
def test_enet_cv_positive_constraint ():
320
320
X , y , X_test , y_test = build_dataset ()
321
- max_iter = 1500
321
+ max_iter = 500
322
322
323
323
# 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 )
325
326
enetcv_unconstrained .fit (X , y )
326
327
assert_true (min (enetcv_unconstrained .coef_ ) < 0 )
327
328
328
329
# 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 )
330
332
enetcv_constrained .fit (X , y )
331
333
assert_true (min (enetcv_constrained .coef_ ) >= 0 )
332
334
0 commit comments