Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
How to use the variable important of Random forest.
library(randomForest)
#「フィッシャーのあやめ」データセットを読み出す
data(iris)
#データセットを特徴量とラベルに分割
features<-iris[1:4]
labels<-iris[5]
#ラベルを因子化
labels<-as.factor(labels[[1]])
#学習して識別器をゲット
classifier<-randomForest(x=features,y=labels,importance=T)
#特徴量の重要度を表示
print(importance(classifier))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment