混同行列(Confusion matrix)
応答変数が解約のように2つの結果だけを持つ場合、モデルの評価は「解約したケースをどれだけ正しく予測できたか」と「解約しなかったケースをどれだけ正しく予測できたか」で行います。これは混同行列を作成し、その上でサマリ指標を計算することで確認できます。結果の可視化にはモザイクプロットが自然です。
churn と mdl_churn_vs_both_inter が利用可能で、dplyr と yardstick は読み込まれています。
この演習はコースの一部です
Rで学ぶ中級回帰分析
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
# Get the actual responses from churn
actual_response <- ___
# Get the predicted responses from the model
predicted_response <- ___
# Get a table of these values
outcomes <- ___
# Convert the table to a conf_mat object
confusion <- ___
# See the result
confusion