@@ -174,7 +174,7 @@ def test_lasso_cv():
174
174
def test_lasso_cv_with_some_model_selection ():
175
175
from sklearn .pipeline import make_pipeline
176
176
from sklearn .preprocessing import StandardScaler
177
- from sklearn .model_selection import StratifiedKFold
177
+ from sklearn .model_selection import ShuffleSplit
178
178
from sklearn import datasets
179
179
from sklearn .linear_model import LassoCV
180
180
@@ -184,7 +184,7 @@ def test_lasso_cv_with_some_model_selection():
184
184
185
185
pipe = make_pipeline (
186
186
StandardScaler (),
187
- LassoCV (cv = StratifiedKFold ( ))
187
+ LassoCV (cv = ShuffleSplit ( random_state = 0 ))
188
188
)
189
189
pipe .fit (X , y )
190
190
@@ -973,3 +973,13 @@ def test_enet_sample_weight_consistency(fit_intercept, alpha, normalize,
973
973
X2 , y2 , sample_weight = None
974
974
)
975
975
assert_allclose (reg1 .coef_ , reg2 .coef_ )
976
+
977
+
978
+ def test_enet_sample_weight_sparse ():
979
+ reg = ElasticNet ()
980
+ X = sparse .csc_matrix (np .zeros ((3 , 2 )))
981
+ y = np .array ([- 1 , 0 , 1 ])
982
+ sw = np .array ([1 , 2 , 3 ])
983
+ with pytest .raises (ValueError , match = "Sample weights do not.*support "
984
+ "sparse matrices" ):
985
+ reg .fit (X , y , sample_weight = sw , check_input = True )
0 commit comments