[英]Variable importance plot using randomforest package in R
I created a random forest model
and now want to look at the variable importance.我创建了一个
random forest model
现在想看看变量的重要性。 While trying to do so, it only shows the MeanDecreaseGini
plot, not the MeanDecreaseAccuracy
plot. If I try to specify type = 1
, it gives an error saying在尝试这样做时,它只显示
MeanDecreaseGini
plot,而不是MeanDecreaseAccuracy
plot。如果我尝试指定type = 1
,它会给出错误提示
Error in imp[, i]: subscript out of bounds
imp[, i] 错误:下标越界
but the same doesn't happen with type = 2
.但是
type = 2
不会发生同样的情况。
The code I used is:我使用的代码是:
RF_Model<- randomForest(as.factor(Ash )~B1+B2+B3+B4+B5+B6+B7+B8+B9+B10+B11+B12+B13+B14+B15
+B16+B17+B18+B19+B20, data=Subset, ntree=2000, Importance=TRUE)
print(RF_Model)
Important=RF_Model$importance
View( Important).
Could anyone help me with this?谁能帮我解决这个问题?
It should be importance=TRUE
instead of Importance=TRUE
.它应该是
importance=TRUE
而不是Importance=TRUE
。 Please, see below for reproducible example:请参阅下面的可重现示例:
rf = randomForest(Species ~ .,data=iris,Importance=TRUE)
importance(rf,type=1)
Sepal.Length
Sepal.Width
Petal.Length
Petal.Width
rf = randomForest(Species ~ .,data=iris,importance=TRUE)
importance(rf,type=1)
MeanDecreaseAccuracy
Sepal.Length 10.035280
Sepal.Width 4.849584
Petal.Length 32.512948
Petal.Width 34.386394
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.