Skip to content

Instantly share code, notes, and snippets.

@svanderbleek
Last active January 7, 2019 03:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save svanderbleek/5b2ea104751c7215f4fa25590104ff7d to your computer and use it in GitHub Desktop.
Save svanderbleek/5b2ea104751c7215f4fa25590104ff7d to your computer and use it in GitHub Desktop.
bank
library(caret)
library(dplyr)
data = read.csv2("bank-additional-full.csv")
f = y ~ duration + pdays + euribor3m + month + day_of_week + job + default + age + previous + contact + poutcome + nr.employed + cons.price.idx
# Scaling Parameters
SAMPLE = 10
TREES = 100
TUNE = 1
# Stratified Sampling by y
sample = data %>% group_by(y) %>% sample_n(SAMPLE) %>% ungroup
rf = train(f, data = sample, method = "rf", ntrees = TREES, trControl = trainControl(method = "LOOCV", verboseIter = TRUE), verbose = TRUE)
knn = train(f, data = sample, method = "knn", tuneLength = TUNE, trControl = trainControl(method = "LOOCV", verboseIter = TRUE))
# Timing Example
system.time(train(f, data = sample, method = "rf", trControl = trainControl(method = "LOOCV")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment