I've conducting a tree model with R caret. I'm now trying to generate a confusion matrix and keep getting the following error:
Error: data
and reference
should be factors with the same levels.
intrain<-createDataPartition(y=df$share, p=0.7, list=FALSE)
train<-df[intrain, ]
test<-df[-intrain, ]
partymod<-ctree(share~., data=train)
partypred<-predict(partymod, test)
confusionMatrix(partypred, test$share)
I cant figure out what the problem is. Any help would be greatly appreciated as its making me cracked!!