RandomForest功能警告

发布于 2025-02-06 14:08:19 字数 846 浏览 1 评论 0原文

当我尝试运行随机森林(用于分类)时,我会得到警告,

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文