【问题标题】:Manual calculation of randomForest() residuals手动计算 randomForest() 残差
【发布时间】:2015-10-10 13:57:20
【问题描述】:

在我看来,在回归案例中使用随机森林进行预测的过程并不简单,因为我得到的结果与内置过程不同:

set.seed(1)
wyn <- randomForest(y = iris[, 1], x = iris[, -1])
(wyn) #Mean of squared residuals: 0.1341068

response=predict(wyn, iris[, -1]) # is it ok ? below to lines gives different output

mean((iris[,1]-wyn$predicted)^2) #returns 0.1341068
mean((iris[,1]-response)^2) # returns 0.07259335


plot(wyn$predicted,response) # almost but not identical

我在上面使用predict() 有什么问题?

【问题讨论】:

    标签: r random-forest


    【解决方案1】:

    好的,现在我知道了:

    #returns out-of-bag error
    mean((iris[,1]-wyn$predicted)^2) #returns 0.1341068 
    
    #returns error calculated on whole dataset
    mean((iris[,1]-response)^2) # returns 0.07259335
    

    【讨论】:

      猜你喜欢
      • 2016-01-09
      • 1970-01-01
      • 2019-06-01
      • 1970-01-01
      • 2018-08-17
      • 2017-06-03
      • 2019-05-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多