Zhe*_*nya 5 r classification machine-learning feature-selection random-forest
我无法理解randomForest内部重要性函数中的按类列。
我的数据集有两个类,“当前”和“已离开”。为了预测这些类别,
我首先创建一个随机森林模型:
fit <- randomForest(IsDeparted ~ ..., df_train),
Run Code Online (Sandbox Code Playgroud)
然后,我运行重要性函数:
importance(fit)
Run Code Online (Sandbox Code Playgroud)
现在,我得到如下结果片段:
有人可以解释如何解释前两类的列吗?排列特定变量的值后,预测该特定类别的准确性的平均下降是吗?如果是这样,这是否意味着如果我对某一类的模型性能更感兴趣,那么在进行特征选择时我应该专注于这些列而不是MDA列?
是的,前两列适用于特定类别。它是按其自身标准误差缩放的平均准确率下降。如果你对某一类的准确性感兴趣,你可以看看。
让我们使用一个示例,其中默认的 important() 函数返回按比例缩放的重要性:
library(randomForest)
set.seed(111)
fit = randomForest(Species ~ .,data=iris,importance=TRUE)
importance(fit)
setosa versicolor virginica MeanDecreaseAccuracy
Sepal.Length 6.716993 7.4654657 7.697842 10.869088
Sepal.Width 4.581990 -0.5208697 4.224459 3.772957
Petal.Length 22.155981 33.0549839 27.892363 33.272150
Petal.Width 22.497643 31.4966353 31.589361 33.123064
MeanDecreaseGini
Sepal.Length 9.333510
Sepal.Width 2.425592
Petal.Length 43.324744
Petal.Width 44.146107
Run Code Online (Sandbox Code Playgroud)
如果查看未缩放的数据,您可以看到 MDA 列大致是 3 个类别的平均值,在本例中是因为 3 个类别是平衡的。如果你的班级不平衡,情况就会有所不同:
setosa versicolor virginica MeanDecreaseAccuracy
Sepal.Length 0.034156211 0.021093423 0.036147901 0.030810465
Sepal.Width 0.006522917 -0.001117593 0.006937731 0.004273138
Petal.Length 0.329299111 0.301621639 0.296869242 0.305569113
Petal.Width 0.335363736 0.298729184 0.279526019 0.302855284
MeanDecreaseGini
Sepal.Length 9.333510
Sepal.Width 2.425592
Petal.Length 43.324744
Petal.Width 44.146107
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
544 次 |
| 最近记录: |