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

前端 未结 8 1374
挽巷
挽巷 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:37

    This is a problem with the levels of each of the different factors. You need to check to make sure that your factor levels stay consistent between your test and training sets.

    This is a weird quirk of random forest, and it doesn't make sense to me.

    0 讨论(0)
  • 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)
    
    0 讨论(0)
提交回复
热议问题