# How to predict new data with a classification tree in R?

I have built a classification tree for factor variables with the rpart package and now I want to predict unseen data with it.

1. How can I get a sense of whether the model is good at predicting unseen data or not ?

2. Is it possible to represent graphically the data and the model in order to see the difference between them ?

1. In order to evaluate if the model or the prediction is "good" or not, you need to know the loss function. For example, if you are doing regression, you can use $f(y,\hat y)=(y-\hat y)^2$ as loss. For classification task, 0-1 loss (number of correct predictions) can be used.