I split Train
data set and Test
data set.
I used a package rpart
for CART (classification tree) in R (only train set). And I want to carry out a ROC analysis using the ROCR
package.
Variable is `n. use' (response varible... 1=yes, 0=no):
> Pred2 = prediction(Pred.cart, Test$n.use)
Error in prediction(Pred.cart, Test$n.use) :
**Format of predictions is invalid.**
This is my code. What is problem? And what is right type
("class"
or "prob"
?
library(rpart)
train.cart = rpart(n.use~., data=Train, method="class")
Pred.cart = predict(train.cart, newdata = Test, type = "class")
Pred2 = prediction(Pred.cart, Test$n.use)
roc.cart = performance(Pred2, "tpr", "fpr")