|
12 | 12 | from sklearn.utils.testing import assert_raises_regex
|
13 | 13 | from sklearn.utils.testing import assert_allclose
|
14 | 14 | from sklearn.utils.testing import ignore_warnings
|
| 15 | +from sklearn.utils.testing import assert_warns_message |
15 | 16 |
|
16 |
| -import warnings |
17 | 17 | from sklearn.linear_model.randomized_l1 import(lasso_stability_path,
|
18 | 18 | RandomizedLasso,
|
19 | 19 | RandomizedLogisticRegression)
|
|
32 | 32 | # test that the feature score of the best features
|
33 | 33 | F, _ = f_regression(X, y)
|
34 | 34 |
|
| 35 | + |
35 | 36 | @ignore_warnings(category=DeprecationWarning)
|
36 | 37 | def test_lasso_stability_path():
|
37 | 38 | # Check lasso stability path
|
@@ -186,3 +187,31 @@ def test_randomized_logistic_sparse():
|
186 | 187 | tol=1e-3)
|
187 | 188 | feature_scores_sp = clf.fit(X_sp, y).scores_
|
188 | 189 | assert_array_equal(feature_scores, feature_scores_sp)
|
| 190 | + |
| 191 | + |
| 192 | +def test_warning_raised(): |
| 193 | + |
| 194 | + scaling = 0.3 |
| 195 | + selection_threshold = 0.5 |
| 196 | + tempdir = 5 |
| 197 | + assert_warns_message(DeprecationWarning, "The function" |
| 198 | + " lasso_stability_path is " |
| 199 | + "deprecated in 0.19 and will be removed in 0.21.", |
| 200 | + lasso_stability_path, X, y, scaling=scaling, |
| 201 | + random_state=42, n_resampling=30) |
| 202 | + |
| 203 | + assert_warns_message(DeprecationWarning, "The class" |
| 204 | + " RandomizedLasso is " |
| 205 | + "deprecated in 0.19 and will be removed in 0.21.", |
| 206 | + RandomizedLasso, verbose=False, alpha=[1, 0.8], |
| 207 | + random_state=42, scaling=scaling, |
| 208 | + selection_threshold=selection_threshold, |
| 209 | + memory=tempdir) |
| 210 | + |
| 211 | + assert_warns_message(DeprecationWarning, "The function" |
| 212 | + " log_multivariate_normal_density is " |
| 213 | + "deprecated in 0.19 and will be removed in 0.21.", |
| 214 | + RandomizedLogisticRegression, |
| 215 | + verbose=False, C=1., random_state=42, |
| 216 | + scaling=scaling, n_resampling=50, |
| 217 | + tol=1e-3) |
0 commit comments