我不能爲我的生活弄清楚如何計算rpart上的混淆矩陣。來自rpart的混淆矩陣
這裏是我做了什麼:
set.seed(12345)
UBANK_rand <- UBank[order(runif(1000)), ]
UBank_train <- UBank_rand[1:900, ]
UBank_test <- UBank_rand[901:1000, ]
dim(UBank_train)
dim(UBank_test)
#Build the formula for the Decision Tree
UB_tree <- Personal.Loan ~ Experience + Age+ Income +ZIP.Code + Family + CCAvg + Education
#Building the Decision Tree from Test Data
UB_rpart <- rpart(UB_tree, data=UBank_train)
現在,我想我會做類似
table(predict(UB_rpart, UBank_test, UBank_Test$Default))
但是,這不是給我一個混淆矩陣。