Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 运行随机林模型时获取此错误_R_Random Forest - Fatal编程技术网

R 运行随机林模型时获取此错误

R 运行随机林模型时获取此错误,r,random-forest,R,Random Forest,这就是错误: Error in eval(predvars, data, env) : object '.data_Holand.Netherlands' not found 这是我运行时的代码: rf2<-randomForest(income~., data = income_df_train2, importance= TRUE) income_df_test2$.data_.Holand.Netherlands<-rep(0, times = nrow(income_

这就是错误:

Error in eval(predvars, data, env) : 
  object '.data_Holand.Netherlands' not found
这是我运行时的代码:

rf2<-randomForest(income~., data = income_df_train2, importance= TRUE)
income_df_test2$.data_.Holand.Netherlands<-rep(0, times = nrow(income_df_test2))
predicted<-predict(rf2, newdata = income_df_test2, type = "prob") ####This line does not work need to check why
ID<-income_df_test$Id

rf2在发布之前,请花时间理解并调查错误消息。错误为未找到
.data\u Holand.nertherlands
。这意味着它不存在于测试数据帧中。但事实并非如此。您已经创建了列
.data\uu.Holand.nertherlands
而不是
.data\u Holand.nertherlands

您可以检查
列名(income\u df\u test2)