0

No, because when you run caret::confusionMatrix (data.testTree, testing $ money.gain) tells me this: the data can not have any more than the reference levels.

I have run these commands:

cvControl <- trainControl(method = "repeatedcv" number = 10, repeats = 5)
tree.rpart <- caret::train(form.in,data=training,method="rpart",
    metric="money.gain",trControl=cvControl)

For the whole test run the following command:

testing <- testing[complete.cases(testing),]
data.testTree <- caret::predict.train(tree.rpart, NewData = testing)

Now we have to finalize the results obtained with the confusion matrix:

caret::confusionMatrix(data.testTree, testing$money.gain)

identical (levels(testing$money.gain), levels(testing$money.gain))
[1] TRUE
MrFlick
  • 195,160
  • 17
  • 277
  • 295
LuisoBKM
  • 1
  • 1

1 Answers1

0

Your dataTest.tree object might not contain your predicted classes since the option to caret::predict.train function is 'newdata' not 'NewData' like you have it. Try changing that line to:

dataTest.tree <- caret::predict.train(tree.part, newdata = testing)

Also, in the line after that, the identical function is comparing the same thing and will always return a TRUE result. I'm assuming you wanted to compare the result of the predict function and the test data set response levels. I bet if you changed that, the result of that line will be a FALSE.

FelixNNelson
  • 161
  • 4