始める無料で始める

モデルの学習と評価

欠損値への対応とダミー変数の作成ができたので、次はモデルの性能を評価しましょう!

attrition データセットに加えて、testtrain の分割、lr_recipe、そして宣言済みの logistic_model() はすべて読み込まれています。

この演習はコースの一部です

Rで学ぶ特徴量エンジニアリング

コースを見る

演習の手順

  • モデルとレシピを workflow にまとめます。
  • workflow を訓練データに適合させます。
  • 性能評価のための拡張データフレームを生成します。

実践的なインタラクティブ演習

このサンプルコードを完成させて、この演習に挑戦してみましょう。

# Bundle model and recipe in workflow
lr_workflow <- ___() %>%
  add_model(lr_model) %>%
  add_recipe(lr_recipe)

# Fit workflow to the train data
lr_fit <- ___(lr_workflow, data = train)

# Generate an augmented data frame for performance assessment
lr_aug <- lr_fit %>% ___(test)

lr_aug %>% roc_curve(truth = Attrition, .pred_No) %>% autoplot()
bind_rows(lr_aug %>% roc_auc(truth = Attrition, .pred_No),          
          lr_aug %>% accuracy(truth = Attrition, .pred_class))
コードを編集して実行