sthoooon
2/23/2017 - 10:11 PM

Grow multiple decision trees from the bootstrap sample and label by majority vote

Grow multiple decision trees from the bootstrap sample and label by majority vote

from sklearn.ensemble import RandomForestClassifier

forest = RandomForestClassifier(criterion='entropy', 
                                n_estimators=10, 
                                random_state=1,
                                n_jobs=2)
'''
-criteria are “gini” for the Gini impurity and “entropy” for the information gain
-number of features d at each split = sqrt(number of features in traingset) by default
-n_estimators = number of trees in forest (10 by default)
-n_jobs = number of jobs to run in parallel for both fit and predict
'''

forest.fit(X_train, y_train)