Skip to content

predict problem

1 message · Weiwei Shi

#
Hi, there:
I have a question on predict() function.
I built a set of trees using rpart and when I do prediction, I got the
following error:
Error in model.frame.default(Terms, newdata, na.action = act, xlev = attr(object
,  :
        factor V19 has new level(s) 45
Execution halted

I think the problem is caused by a new level (which is not used in
building trees) for V19. I am wondering if there is an argument in
predict() which can help suppress this error by just ignoring this
special observation in validation sample. If not, I can do some
pre-treatment to remove the obs with new level out for the time being.

Thanks,