Measuring the prediction performance of a conditional inference tree
After building a conditional inference tree as a classification model, we can use the treeresponse and predict functions to predict categories of the testing dataset, testset, and further validate the prediction power with a classification table and a confusion matrix.
Getting ready
You need to have the previous recipe completed by generating the conditional inference tree model, ctree.model. In addition to this, you need to have both trainset and testset loaded in an R session.
How to do it...
Perform the following steps to measure the prediction performance of a conditional inference tree:
- You can use the
predictfunction to predict the category of the testing datasettestset:
> ctree.predict = predict(ctree.model ,testset)
> table(ctree.predict, testset$churn)
Output
ctree.predict yes no
yes 99 15
no 42 862 - Furthermore, you can use
confusionMatrixfrom...