R 決定木 Decision Tree Analysis caret !!!confusionMatrix() * caretパッケージに含まれる * 混同行列(予測値と観測値の対応表)をもとに分類の精度を出す * C2, C3, JPの分類の例 ** モデル <- ctree(観測値 ~ 説明変数) {{pre CM.table <- table(predict(モデル), データ$観測値) CM.table C2 C3 JP C2 35 7 0 C3 3 19 1 JP 0 6 34 CM.result <- caret::confusionMatrix(CM.table) print(CM.result) Confusion Matrix and Statistics C2 C3 JP C2 35 7 0 C3 3 19 1 JP 0 6 34 Overall Statistics Accuracy : 0.8381 95% CI : (0.7535, 0.9028) No Information Rate : 0.3619 P-Value [Acc > NIR] : < 2.2e-16 Kappa : 0.7552 Mcnemar's Test P-Value : NA Statistics by Class: Class: C2 Class: C3 Class: JP Sensitivity 0.9211 0.5938 0.9714 Specificity 0.8955 0.9452 0.9143 Pos Pred Value 0.8333 0.8261 0.8500 Neg Pred Value 0.9524 0.8415 0.9846 Prevalence 0.3619 0.3048 0.3333 Detection Rate 0.3333 0.1810 0.3238 Detection Prevalence 0.4000 0.2190 0.3810 Balanced Accuracy 0.9083 0.7695 0.9429 }}