Random Forest for Classification - Nori12/Machine-Learning-Tutorial GitHub Wiki
Machine Learning Tutorial
Random Forest for Classification
Check the page Concepts when Building a Random Forest model if you want to understand more about the model.
from sklearn.ensemble import RandomForestClassifier
forest = RandomForestClassifier(n_estimators=10000, random_state=2)
forest.fit(X_train, y_train)
Tips
- If you are using a multi-core processor, you can use the n_jobs parameter to adjust the number of cores to use. n_jobs=-1 to use all the cores in your computer;
- In any real application, we would use many trees (often hundreds or thousands);
- Often the default parameters of the random forest already work quite well, so adjusting the max_features setting, or applying pre-pruning can be skipped for non state-of-art applications;
- Typically, the feature importances provided by the random forest are more reliable than the ones provided by a single tree.