Skip to content

Instantly share code, notes, and snippets.

@alfredplpl
Last active December 23, 2015 03:49
Show Gist options
  • Save alfredplpl/6575907 to your computer and use it in GitHub Desktop.
Save alfredplpl/6575907 to your computer and use it in GitHub Desktop.
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