Skip to content

Instantly share code, notes, and snippets.

@cdeterman
Last active August 29, 2015 14:07
Show Gist options
  • Save cdeterman/d0e38a768b1a55d9b900 to your computer and use it in GitHub Desktop.
Save cdeterman/d0e38a768b1a55d9b900 to your computer and use it in GitHub Desktop.
basic caret demo with ROC
library(mlbench)
library(caret)
data(Sonar)
inTraining <- createDataPartition(Sonar$Class, p = 0.75, list = FALSE)
training <- Sonar[inTraining, ]
testing <- Sonar[-inTraining, ]
myTuneGrid <- expand.grid(n.trees = 500,interaction.depth = 11,shrinkage = 0.1)
fitControl <- trainControl(method = "repeatedcv",
number = 7,
repeats = 1,
verboseIter = FALSE,
returnResamp = "all",
classProbs = TRUE,
summaryFunction=twoClassSummary)
set.seed(825)
gbmFit1 <- train(Class ~ ., data = training,
method = "gbm",
trControl = fitControl,
verbose = FALSE,
metric="ROC",
tuneGrid=myTuneGrid)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment