Last active
December 23, 2015 03:49
-
-
Save alfredplpl/6575907 to your computer and use it in GitHub Desktop.
How to use the variable important of Random forest.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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