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

Skip to content

Commit 7e2453a

Browse files
committed
Merge pull request #5242 from arjoly/stable-test-2
FIX unstable test due to bootstrap and unset random state
2 parents cda140e + 994cbe1 commit 7e2453a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

sklearn/ensemble/tests/test_forest.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -980,11 +980,12 @@ def test_warm_start_oob():
980980
yield check_warm_start_oob, name
981981

982982

983-
def test_dtype_convert():
984-
classifier = RandomForestClassifier()
985-
CLASSES = 15
986-
X = np.eye(CLASSES)
987-
y = [ch for ch in 'ABCDEFGHIJKLMNOPQRSTU'[:CLASSES]]
983+
def test_dtype_convert(n_classes=15):
984+
classifier = RandomForestClassifier(random_state=0, bootstrap=False)
985+
986+
X = np.eye(n_classes)
987+
y = [ch for ch in 'ABCDEFGHIJKLMNOPQRSTU'[:n_classes]]
988988

989989
result = classifier.fit(X, y).predict(X)
990+
assert_array_equal(classifier.classes_, y)
990991
assert_array_equal(result, y)

0 commit comments

Comments
 (0)