Random Forests - setiamanlhc/python-snippet-code GitHub Wiki

from sklearn.ensemble import RandomForestClassifier
rfc = RandomForestClassifier(n_estimators=100)
#Train
rfc.fit(X_train, y_train)

#Predict
rfc_pred = rfc.predict(X_test)

#Print Report
from sklearn.metrics import classification_report,confusion_matrix
print(confusion_matrix(y_test,rfc_pred))
print(classification_report(y_test,rfc_pred))