dimanche 12 juillet 2015

Error in confusionMatrix.default(data.testTree, testing$money.gain) : the data cannot have more levels than the reference

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

Aucun commentaire:

Enregistrer un commentaire