【问题标题】:The explanation of the verbose mode during running randomForest in RR中运行randomForest期间详细模式的解释
【发布时间】:2015-03-23 12:38:16
【问题描述】:

我在 R 中使用详细模式(do.trace)运行 randomForest, 我想知道消息中列的含义是什么。 我可以看到ntree 是树的数量,OOB 是袋外样本的百分比,但是“1”和“2”是什么?

> rf.m <- randomForest(x = X.train, y=as.factor(y.train), do.trace=10)
ntree      OOB      1      2
   10:  32.03% 15.60% 82.47%
   20:  29.18% 10.51% 86.31%
   30:  27.44%  7.47% 88.57%
   40:  26.48%  5.29% 91.33%
   50:  25.92%  4.35% 91.96%
   ....

【问题讨论】:

    标签: r random-forest


    【解决方案1】:

    输出中的列12 给出了每个类的分类错误。 OOB 值是类错误的加权平均值(由每个类中的观察分数加权)。

    一个例子(改编自帮助页面的随机森林例子):

    # Keep every 100th tree in the trace
    set.seed(71)
    iris.rf <- randomForest(Species ~ ., data=iris, importance=TRUE,
                            proximity=TRUE, do.trace=100)
    
    ntree      OOB      1      2      3
      100:   6.00%  0.00%  8.00% 10.00%
      200:   5.33%  0.00%  6.00% 10.00%
      300:   6.00%  0.00%  8.00% 10.00%
      400:   4.67%  0.00%  8.00%  6.00%
      500:   5.33%  0.00%  8.00%  8.00%
    

    第 100 棵树的类错误的加权平均值给出了 6.0% 的 OOB 错误率,与上面的跟踪中报告的完全一样。 (prop.table 返回每​​个类别(每个类别)物种的观察分数)。我们将该元素乘以第 100 棵树的类误差,如上面的跟踪值所示,然后求和以获得所有类的加权平均误差(OOB 误差)。

    sum(prop.table(table(iris$Species)) * c(0, 0.08, 0.10))
    [,1]
    [1,] 0.06
    

    如果你使用矩阵乘法,你可以避免使用 sum,这里相当于点/标量/内积:

    prop.table(table(iris$Species)) %*% c(0, 0.08, 0.10)
    

    【讨论】:

      猜你喜欢
      • 2018-08-30
      • 2017-09-19
      • 2019-09-08
      • 1970-01-01
      • 2021-05-25
      • 1970-01-01
      • 1970-01-01
      • 2023-03-12
      • 1970-01-01
      相关资源
      最近更新 更多