我是一名R的初学者,现在想用随机森林做分类预测,然后用来生存分析,下面是我运行的代码,但是总出现错误,请各位帮我看看,非常感谢大家!
train<-read.table("C:\\Users\\Administrator\\Desktop\\新建文件夹\\training1 .txt",
heade=T)
test<-read.table("C:\\Users\\Administrator\\Desktop\\新建文件夹\\test1.txt",
heade=T)
library(randomForest)
rf<-randomForest(zhonglei~.,data=train,ntree=1000,mtry=2,importance=TRUE)
print(ranfor)
pred<-predict(rf,test)
print(pred)
Error in randomForest.default(m, y, ...) :
Can not handle categorical predictors with more than 53 categories.
In addition: Warning message:
In randomForest.default(m, y, ...) :
The response has five or fewer unique values. Are you sure you want to do regression?
附件列表