def check_classification_toy(name):
 ForestClassifier = FOREST_CLASSIFIERS[name]
 clf = ForestClassifier(n_estimators=10, random_state=1)
 clf.fit(X, y)
 assert_array_equal(clf.predict(T), true_result)
 assert_equal(10, len(clf))
 clf = ForestClassifier(n_estimators=10, max_features=1, random_state=1)
 clf.fit(X, y)
 assert_array_equal(clf.predict(T), true_result)
 assert_equal(10, len(clf))
 leaf_indices = clf.apply(X)
 assert_equal(leaf_indices.shape, (len(X), clf.n_estimators))

def check_classification_toy ( name ) : ForestClassifier = FOREST_CLASSIFIERS [ name ] clf = ForestClassifier ( n_estimators = 10 , random_state = 1 ) clf . fit ( X , y ) assert_array_equal ( clf . predict ( T ) , true_result ) assert_equal ( 10 , len ( clf ) ) clf = ForestClassifier ( n_estimators = 10 , max_features = 1 , random_state = 1 ) clf . fit ( X , y ) assert_array_equal ( clf . predict ( T ) , true_result ) assert_equal ( 10 , len ( clf ) ) leaf_indices = clf . apply ( X ) assert_equal ( leaf_indices . shape , ( len ( X ) , clf . n_estimators ) )
check classification on a toy dataset .