定稿模型
是時候把你的調參成果落實,讓人力資源團隊眼前一亮。你可以用找出的最佳懲罰係數來定稿模型,並檢視是否符合你的預期。你的結果已載入,且使用者自訂函式 class_evaluate() 已可在你的環境中使用。
本練習屬於課程
R 的特徵工程
練習說明
- 選出 Lasso 的最佳懲罰係數。
- 使用最佳懲罰係數擬合最終模型。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Select the optimal penalty for the Lasso
best_penalty <- ___(tune_output, metric = 'roc_auc', desc(penalty))
best_penalty
# Fit a final model using the optimal penalty
final_fit <- ___(workflow_lasso_tuned, best_penalty) %>%
fit(data = train)
final_fit %>% tidy()
final_fit %>% augment(test) %>% class_evaluate(truth = Attrition,
estimate = .pred_class,
.pred_Yes)