建立精簡的隨機森林
現在,請使用 train_reduced 來擬合精簡模型,並用 test_reduced 進行評估。rf_spec 已為你準備好,可用來擬合這個精簡模型。完整模型的 F1 值為 0.948。當你擬合並評估精簡模型時,記得模型的簡潔度與效能之間總是存在取捨。你需要判斷模型精簡所帶來的好處,是否值得(如果有的話)效能上的些微下降。
已為你載入 tidyverse、tidymodels 和 vip 套件。
本練習屬於課程
R 的降維
練習說明
- 使用
rf_spec擬合精簡的隨機森林模型。 - 將精簡模型的預測結果與
test_reduced綁在一起。 - 計算精簡模型的 F1 指標。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Fit a reduced model
rf_reduced_fit <- ___ %>%
___(___, ___ = ___)
# Create test set prediction data frame
predict_reduced_df <- ___ %>%
___(predict = ___(___, ___))
# Calculate F1 performance
___(___, ___, ___)