その他の木のオプションと混同行列の作成

R で学ぶクレジットリスク・モデリング

Lore Dirick

Manager of Data Science Curriculum at Flatiron School

rpart() のその他の有用な引数

  • rpart() 内
    • weights: ケース重みを指定
  • rpart() の control 引数(rpart.control)
    • minsplit: 分割を試みる最小観測数
    • minbucket: 葉ノードの最小観測数
R で学ぶクレジットリスク・モデリング
pred_undersample_class = predict(ptree_undersample, newdata = test_set, type ="class")
1     2     3    ...   29073 29079 29084 29090 29091
0     0     0    ...     1     0     0     0     0

または

pred_undersample = predict(ptree_undersample, newdata = test_set)
          0         1
1     0.7382920 0.2617080
2     0.5665138 0.4334862
3     0.5992366 0.4007634
          ...          ... 
29084 0.7382920 0.2617080
29090 0.7382920 0.2617080
29091 0.7382920 0.2617080
R で学ぶクレジットリスク・モデリング

混同行列の作成

table(test_set$loan_status, pred_undersample_class)
pred_undersample_class
       0    1
  0 8314  346
  1  964   73
R で学ぶクレジットリスク・モデリング

演習に進みましょう!

R で学ぶクレジットリスク・モデリング

Preparing Video For Download...