【问题标题】:Predict (Random Forest): prob or vote not meaningful for regression预测(随机森林):概率或投票对回归没有意义
【发布时间】:2014-07-24 21:10:47
【问题描述】:

当我运行预测函数时,我得到这个错误:

Error in predict.randomForest(fit, newdata = na.roughfix(csvTest[, -c(1:2,  : 
'prob' or 'vote' not meaningful for regression code here

这是代码:

fit <- foreach (ntree = rep (round(number_trees/nc), nc), 
            .combine = combine, .packages = 'randomForest') %dopar% randomForest(y=csv$mal,x=na.roughfix (csv[, c(1:2,4:5,8:13,17,19:20,22:29,ncol(csv))]), ntree = number_trees)
prob <- predict (fit, newdata = na.roughfix (csvTest[, -c(1:2,4:5,8:13,17,19:20,22:29,ncol(csvTest))]), type = 'prob')[, 2]

谁能帮我理解这是什么问题? 谢谢

【问题讨论】:

    标签: r random-forest predict


    【解决方案1】:

    我刚刚解决了。这是因为我的目标变量 (csv$mal) 默认被 R 设置为“数字”,而它应该是“因子”一(0 或 1)。

    对于数字,随机森林以 type="regression" 运行,而不是 type="classification"。

    【讨论】:

      猜你喜欢
      • 2015-05-03
      • 2020-10-15
      • 2016-01-28
      • 2014-08-07
      • 2021-11-20
      • 2019-04-11
      • 2019-12-06
      • 2017-04-24
      相关资源
      最近更新 更多