Skip to content

Instantly share code, notes, and snippets.

@hatosuke
Created May 9, 2018 13:00
Show Gist options
  • Save hatosuke/7955d5c9598489efe822a152d6466fe0 to your computer and use it in GitHub Desktop.
Save hatosuke/7955d5c9598489efe822a152d6466fe0 to your computer and use it in GitHub Desktop.
# 乱数種を設定し、同じ結果が返されるようにする
set.seed(754)
# Survivedが目的変数で、~以降が説明変数、全ての変数を利用するわけではない
rf_model <- randomForest(factor(Survived) ~
 Pclass + SibSp + Parch + Fare + Parch,
   data = train)
# Show model error
plot(rf_model, ylim=c(0, 0.6))
# legend : plotに判例をつける
# col : ラインの色
# fill : boxの色
legend('topright', colnames(rf_model$err.rate), col=1:3, fill=1:3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment