Machine Learning: Random Forest, Gradient Boosting, and AdaBoost
1. Implementing a Random Forest in Python
Random forest can be implemented in Python using the scikit - learn library. Here are the implementation details:
from sklearn.ensemble import RandomForestClassifier
rfc = RandomForestClassifier(n_estimators=100,max_depth=5,min_samples_leaf=100,random_state=10)
rfc.fit(X_train, y_train)
To make predictions:
rfc_pred=rfc.predict_proba(X_test)
After making predictions, the AUC can be calculated as follows:
from sklearn.metrics import roc_auc_score
roc_auc_score(y_test, rfc_pred[:,1])
超级会员免费看
订阅专栏 解锁全文
861

被折叠的 条评论
为什么被折叠?



