随机森林软件包中的r-模型$importance vs importance(模型)



在r中使用randomForest包运行随机森林后,我对访问特性重要性的差异有点困惑。使用model$importance和importance(model(给出不同的值。有人知道为什么吗?

下面是示例代码。当我使用rf$importanceimportance(rf)时,MeanDecreaseAccuracy具有不同的值。

rf = randomForest(Species~., data=iris, importance=T)
rf$importance
                  setosa versicolor  virginica
Sepal.Length 0.028069924 0.02290131 0.02999196
Sepal.Width  0.007430743 0.00234842 0.00802824
Petal.Length 0.340913786 0.31065484 0.30779183
Petal.Width  0.326072508 0.31167317 0.27879456
             MeanDecreaseAccuracy MeanDecreaseGini
Sepal.Length          0.026581478         9.399968
Sepal.Width           0.005823167         2.256985
Petal.Length          0.317224058        43.508494
Petal.Width           0.302483961        44.047933
importance(rf)
                setosa versicolor virginica
Sepal.Length  5.848489   7.437477  6.817425
Sepal.Width   4.584855   1.294841  4.535271
Petal.Length 22.222062  33.130557 28.586522
Petal.Width  21.634934  32.550969 30.980522
             MeanDecreaseAccuracy MeanDecreaseGini
Sepal.Length             9.820337         9.399968
Sepal.Width              5.429112         2.256985
Petal.Length            33.999215        43.508494
Petal.Width             32.807621        44.047933

只需将每个MeanDecreaseAccuracy除以$importanceSD 的相应值

rf$importance[, 4]/ rf$importanceSD[,4]
#Sepal.Length  Sepal.Width Petal.Length  Petal.Width 
#10.643412     4.816711    34.096432    32.764032

在这里你可以看到为什么,importance()通过它的SD.来缩放MeanDecreaseAccuracy

最新更新