@@ -62,6 +62,7 @@ def test_iforest():
62
62
** params ).fit (X_train ).predict (X_test )
63
63
64
64
65
+ @pytest .mark .filterwarnings ('ignore:default contamination' )
65
66
def test_iforest_sparse ():
66
67
"""Check IForest for various parameter settings on sparse input."""
67
68
rng = check_random_state (0 )
@@ -89,6 +90,7 @@ def test_iforest_sparse():
89
90
assert_array_equal (sparse_results , dense_results )
90
91
91
92
93
+ @pytest .mark .filterwarnings ('ignore:default contamination' )
92
94
def test_iforest_error ():
93
95
"""Test that it gives proper exception on deficient input."""
94
96
X = iris .data
@@ -127,6 +129,7 @@ def test_iforest_error():
127
129
assert_raises (ValueError , IsolationForest ().fit (X ).predict , X [:, 1 :])
128
130
129
131
132
+ @pytest .mark .filterwarnings ('ignore:default contamination' )
130
133
def test_recalculate_max_depth ():
131
134
"""Check max_depth recalculation when max_samples is reset to n_samples"""
132
135
X = iris .data
@@ -135,6 +138,7 @@ def test_recalculate_max_depth():
135
138
assert_equal (est .max_depth , int (np .ceil (np .log2 (X .shape [0 ]))))
136
139
137
140
141
+ @pytest .mark .filterwarnings ('ignore:default contamination' )
138
142
def test_max_samples_attribute ():
139
143
X = iris .data
140
144
clf = IsolationForest ().fit (X )
@@ -150,6 +154,7 @@ def test_max_samples_attribute():
150
154
assert_equal (clf .max_samples_ , 0.4 * X .shape [0 ])
151
155
152
156
157
+ @pytest .mark .filterwarnings ('ignore:default contamination' )
153
158
def test_iforest_parallel_regression ():
154
159
"""Check parallel regression."""
155
160
rng = check_random_state (0 )
@@ -174,6 +179,7 @@ def test_iforest_parallel_regression():
174
179
assert_array_almost_equal (y1 , y3 )
175
180
176
181
182
+ @pytest .mark .filterwarnings ('ignore:default contamination' )
177
183
def test_iforest_performance ():
178
184
"""Test Isolation Forest performs well"""
179
185
@@ -213,13 +219,15 @@ def test_iforest_works():
213
219
assert_array_equal (pred , 6 * [1 ] + 2 * [- 1 ])
214
220
215
221
222
+ @pytest .mark .filterwarnings ('ignore:default contamination' )
216
223
def test_max_samples_consistency ():
217
224
# Make sure validated max_samples in iforest and BaseBagging are identical
218
225
X = iris .data
219
226
clf = IsolationForest ().fit (X )
220
227
assert_equal (clf .max_samples_ , clf ._max_samples )
221
228
222
229
230
+ @pytest .mark .filterwarnings ('ignore:default contamination' )
223
231
def test_iforest_subsampled_features ():
224
232
# It tests non-regression for #5732 which failed at predict.
225
233
rng = check_random_state (0 )
@@ -244,6 +252,7 @@ def test_iforest_average_path_length():
244
252
[1. , result_one , result_two ], decimal = 10 )
245
253
246
254
255
+ @pytest .mark .filterwarnings ('ignore:default contamination' )
247
256
def test_score_samples ():
248
257
X_train = [[1 , 1 ], [1 , 2 ], [2 , 1 ]]
249
258
clf1 = IsolationForest (contamination = 0.1 ).fit (X_train )
@@ -257,12 +266,15 @@ def test_score_samples():
257
266
258
267
259
268
def test_deprecation ():
260
- assert_warns_message (DeprecationWarning ,
269
+ X = [[0.0 ], [1.0 ]]
270
+ clf = IsolationForest ()
271
+
272
+ assert_warns_message (FutureWarning ,
261
273
'default contamination parameter 0.1 will change '
262
274
'in version 0.22 to "auto"' ,
263
- IsolationForest , )
264
- X = [[ 0.0 ], [ 1.0 ]]
265
- clf = IsolationForest ().fit (X )
275
+ clf . fit , X )
276
+
277
+ clf = IsolationForest (contamination = 'auto' ).fit (X )
266
278
assert_warns_message (DeprecationWarning ,
267
279
"threshold_ attribute is deprecated in 0.20 and will"
268
280
" be removed in 0.22." ,
0 commit comments