Machine Learning with Swift
上QQ阅读APP看书,第一时间看更新

Training the random forest

Training the random forest model is not very different from training the decision tree:

In []: 
from sklearn.ensemble import RandomForestClassifier 
rf_model = RandomForestClassifier(criterion = 'entropy', random_state=42) 
rf_model = rf_model.fit(X_train, y_train) 
print(rf_model) 
Out[]: 
RandomForestClassifier(bootstrap=True, class_weight=None, criterion='entropy', 
            max_depth=None, max_features='auto', max_leaf_nodes=None, 
            min_impurity_split=1e-07, min_samples_leaf=1, 
            min_samples_split=2, min_weight_fraction_leaf=0.0, 
            n_estimators=10, n_jobs=1, oob_score=False, random_state=42, 
            verbose=0, warm_start=False)