r random forest error - type of predictors in new data do not match

前端 未结 8 1413
挽巷
挽巷 2020-12-04 14:37

I am trying to use quantile regression forest function in R (quantregForest) which is built on Random Forest package. I am getting a type mismatch error that I can\'t quite

8条回答
  •  暖寄归人
    2020-12-04 15:39

    This happens because your factor variables in training set and test set have different levels(to be more precise test set doesn't have some of the levels present in training). So you can solve this for example by using below code for all your factor variables.:

    levels(test$SectionName) <- levels(train$SectionName)
    

提交回复
热议问题