Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 34c2904

Browse files
committed
FIX testing: random state problem in forest testing.
1 parent caea207 commit 34c2904

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

sklearn/ensemble/tests/test_forest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def test_oob_score_classification():
188188
"""Check that oob prediction is as acurate as
189189
usual prediction on the training set.
190190
Not really a good test that prediction is independent."""
191-
clf = RandomForestClassifier(oob_score=True)
191+
clf = RandomForestClassifier(oob_score=True, random_state=rng)
192192
clf.fit(X, y)
193193
training_score = clf.score(X, y)
194194
assert_almost_equal(training_score, clf.oob_score_)
@@ -197,7 +197,8 @@ def test_oob_score_classification():
197197
def test_oob_score_regression():
198198
"""Check that oob prediction is pessimistic estimate.
199199
Not really a good test that prediction is independent."""
200-
clf = RandomForestRegressor(n_estimators=50, oob_score=True)
200+
clf = RandomForestRegressor(n_estimators=50, oob_score=True,
201+
random_state=rng)
201202
n_samples = boston.data.shape[0]
202203
clf.fit(boston.data[:n_samples / 2, :], boston.target[:n_samples / 2])
203204
test_score = clf.score(boston.data[n_samples / 2:, :],

0 commit comments

Comments
 (0)