Skip to content

Instantly share code, notes, and snippets.

@glamp
Last active September 19, 2018 06:44
Show Gist options
  • Save glamp/6662879 to your computer and use it in GitHub Desktop.
Save glamp/6662879 to your computer and use it in GitHub Desktop.
cols <- names(train)[1:12]
system.time(clf <- randomForest(factor(quality) ~ ., data=train[,cols], ntree=20, nodesize=5, mtry=9))
# user system elapsed
# 0.366 0.006 0.372
table(test$quality, predict(clf, test[cols]))
# 3 4 5 6 7 8 9
# 3 0 0 4 5 0 0 0
# 4 0 0 35 22 1 0 0
# 5 0 0 375 137 6 1 0
# 6 0 1 129 531 52 1 0
# 7 0 0 13 113 150 2 0
# 8 0 0 0 19 13 18 0
# 9 0 0 0 3 0 0 0
sum(test$quality==predict(clf, test[cols])) / nrow(test)
# [1] 0.6609
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment