【问题标题】:randomForest::importance() : type=2 is working, but not type=1randomForest::importance() : type=2 有效,但 type=1 无效
【发布时间】:2020-06-02 13:01:23
【问题描述】:

我正在使用 randomForest 包。为了获得可变的重要性,我使用了importance() 函数。 我想更改重要性度量的类型。它由“type”参数确定,它有 2 个可能的值:type=1 或 type=2。这是一个例子:

library(randomForest)

Y = runif(100, 0.0, 1.0)
X1 = runif(100, 0.0, 1.0)
X2 = runif(100, 0.0, 1.0)

rf.model = randomForest::randomForest(Y~X1+X2)

# type 2 : mean decrease in node impurity
imp2 = randomForest::importance(x=rf.model,type=2)

# type 1 : mean decrease in accuracy
imp1 = randomForest::importance(x=rf.model,type=1)

imp2 输出:

      IncNodePurity
X1      3.130248
X2      3.023091

imp1 输出:

X1
X2

如您所见,type=2(平均降低节点杂质)有效,但不是 type=1(平均降低准确性)。你知道如何解决这个问题吗?

【问题讨论】:

    标签: r random-forest


    【解决方案1】:

    你必须先在你的模型中启用它

    rf.model = randomForest::randomForest(Y~X1+X2,importance=T)
    

    然后它会工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-26
      • 1970-01-01
      • 1970-01-01
      • 2017-02-08
      • 1970-01-01
      • 2020-12-27
      • 1970-01-01
      • 2018-07-27
      相关资源
      最近更新 更多