探索 Random Forest 的超參數
了解可用的超參數,以及不同超參數對模型的影響,是每位資料科學家的核心能力。隨著模型愈來愈複雜,可調整的設定很多,但只有部分會大幅影響模型表現。
你現在要評估一個既有的 random forest 模型(它的超參數設定有些不理想!),接著為新的 random forest 模型做出更好的選擇,並評估其效能。
你將會用到:
X_train、X_test、y_train、y_testDataFrame- 已經訓練好的既有 random forest 估計器
rf_clf_old - 既有 random forest 估計器在測試集上的預測
rf_old_predictions
本練習屬於課程
Python 超參數調校
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Print out the old estimator, notice which hyperparameter is badly set
print(____)
# Get confusion matrix & accuracy for the old rf_model
print("Confusion Matrix: \n\n {} \n Accuracy Score: \n\n {}".format(
confusion_matrix(____, ____),
accuracy_score(____, ____)))