【问题标题】:RandomForest function warningRandomForest 函数警告
【发布时间】:2022-06-12 22:04:37
【问题描述】:

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

Warning message:
In randomForest.default(m, y, ...) :
  The response has five or fewer unique values.  Are you sure you want to do regression?

我已经用 janitor 包清理了我的(巨大的)数据集,并尝试将变量分解。有谁明白为什么我仍然收到此警告?


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)

【问题讨论】:

  • 警告意味着您最多有 5 个课程。你应该考虑分类而不是回归

标签: r random-forest


猜你喜欢
  • 2013-12-11
  • 2017-08-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-04-24
  • 2013-06-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多