I am having a hard time troubleshooting the error message below. I am trying to do a random forest model on a titanic
data set. Is there a way to get around this error? Is there a code to check the levels in the tree?
Error in predict.randomForest(my_rf_model, test1) : Type of predictors in new data
do not match that of the training data.
This is probably occurring because one of the predictor variables in
test1
is a factor variable that has a value not present in the original data set. For example, iftitanic
has a column calledgroup
that can have valuesA
orB
, buttest1$group
can have a value ofC
, then you would get that error.For example: