RandomForest功能警告
当我尝试运行随机森林(用于分类)时,我会得到警告,
Warning message:
In randomForest.default(m, y, ...) :
The response has five or fewer unique values. Are you sure you want to do regression?
我已经用看门人包清洁了(巨大的)数据集,并试图考虑变量。有人理解为什么我仍然会发出警告吗?
data2 <- experimental_data
x = janitor::clean_names(data2)
#--------------------------------------
#Partition data
set.seed(93)
ind <- sample(2, nrow(x), replace= TRUE,prob=c(0.7,0.3))
train <- x[ind==1,]
test<- x[ind==2,]
str(train)
train[sapply(train, is.character)] <- lapply(train[sapply(train, is.character)],
as.factor)
str(train)
#Train Random forest on UCI heart dataset
rf <- randomForest(y_full~., data=train, importance=TRUE, predict.all=TRUE,proximity=TRUE)
When I try to run my random forest (for classification) I get the warning
Warning message:
In randomForest.default(m, y, ...) :
The response has five or fewer unique values. Are you sure you want to do regression?
I already cleaned my (huge) dataset with the janitor package and tried to factor the variables. Does anyone understand why I still get this warning?
data2 <- experimental_data
x = janitor::clean_names(data2)
#--------------------------------------
#Partition data
set.seed(93)
ind <- sample(2, nrow(x), replace= TRUE,prob=c(0.7,0.3))
train <- x[ind==1,]
test<- x[ind==2,]
str(train)
train[sapply(train, is.character)] <- lapply(train[sapply(train, is.character)],
as.factor)
str(train)
#Train Random forest on UCI heart dataset
rf <- randomForest(y_full~., data=train, importance=TRUE, predict.all=TRUE,proximity=TRUE)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论