library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.4.4     ✔ tibble    3.2.1
## ✔ lubridate 1.9.2     ✔ tidyr     1.3.0
## ✔ purrr     1.0.1     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(readxl)
library(tidymodels)
## ── Attaching packages ────────────────────────────────────── tidymodels 1.1.0 ──
## ✔ broom        1.0.4     ✔ rsample      1.1.1
## ✔ dials        1.2.0     ✔ tune         1.1.1
## ✔ infer        1.0.4     ✔ workflows    1.1.3
## ✔ modeldata    1.2.0     ✔ workflowsets 1.0.1
## ✔ parsnip      1.1.0     ✔ yardstick    1.2.0
## ✔ recipes      1.0.6     
## ── Conflicts ───────────────────────────────────────── tidymodels_conflicts() ──
## ✖ scales::discard() masks purrr::discard()
## ✖ dplyr::filter()   masks stats::filter()
## ✖ recipes::fixed()  masks stringr::fixed()
## ✖ dplyr::lag()      masks stats::lag()
## ✖ yardstick::spec() masks readr::spec()
## ✖ recipes::step()   masks stats::step()
## • Learn how to get started at https://www.tidymodels.org/start/
library(discrim)
## 
## Attaching package: 'discrim'
## 
## The following object is masked from 'package:dials':
## 
##     smoothness
library(naivebayes)
## naivebayes 0.9.7 loaded
library(randomForest)
## randomForest 4.7-1.1
## Type rfNews() to see new features/changes/bug fixes.
## 
## Attaching package: 'randomForest'
## 
## The following object is masked from 'package:dplyr':
## 
##     combine
## 
## The following object is masked from 'package:ggplot2':
## 
##     margin
library(DataExplorer)
library(plotly)
## 
## Attaching package: 'plotly'
## 
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## 
## The following object is masked from 'package:stats':
## 
##     filter
## 
## The following object is masked from 'package:graphics':
## 
##     layout
library(parsnip)
library(vip)
## 
## Attaching package: 'vip'
## 
## The following object is masked from 'package:utils':
## 
##     vi
library(yardstick)
library(knitr)
library(kableExtra)
## 
## Attaching package: 'kableExtra'
## 
## The following object is masked from 'package:dplyr':
## 
##     group_rows
file_path <- "data/Modeling Task_v3b.xlsx"

sheet_names <- excel_sheets(file_path) #Checking to see if the Excel file has more than one tab. 

df <- read_excel("data/Modeling Task_v3b.xlsx") 

glimpse(df)
## Rows: 100,000
## Columns: 11
## $ AccountID          <dbl> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, …
## $ Age                <dbl> 23, 25, 21, 21, 35, 31, 36, 37, 34, 28, 47, 29, 43,…
## $ State              <chr> "NSW", "QLD", "QLD", "VIC", "VIC", "WA", "Other", "…
## $ RegistrationDate   <dttm> 2021-02-13, 2021-02-13, 2021-02-13, 2020-03-10, 20…
## $ RegistrationDevice <chr> "Tablet", "MobileApp", "TabletApp", "Tablet", "Tabl…
## $ FirstBetDate       <dttm> 2021-02-13, 2021-02-13, 2021-02-13, 2020-03-10, 20…
## $ FirstBetDevice     <chr> "Tablet", "MobileApp", "TabletApp", "Tablet", "Tabl…
## $ AcquisitionSource  <chr> "Direct Traffic", "Direct Traffic", "Direct Traffic…
## $ MainBetSport       <chr> "Horse Racing", "Horse Racing", "Horse Racing", "Ho…
## $ FirstWeekTurnover  <dbl> 41, 630, 911, 37, 63, 4526, 7, 66, 856, 50, 1184, 4…
## $ SurveyAnswer       <chr> "No Answer", "No Answer", "No Answer", "No Answer",…
df %>%
  plot_missing()

Step 1 is to split out the data with no answer. We can later use our fit model to predict the outcome, based on out inputs.

#Split dataframe into 2 files. 1 file = with "No Answer" to the survey and second file will include survey responses for ice cream flavour. 

#File with no survey response = prediction set.
df_predict <- df %>% 
  filter(SurveyAnswer == "No Answer") %>% 
  mutate(SurveyAnswer = as.factor(SurveyAnswer))

#File with survey responses.
df_answers <- df %>% 
  filter(SurveyAnswer != "No Answer") %>% 
  mutate(SurveyAnswer = as.factor(SurveyAnswer))

#Next we will split the file with survey answers into a training and test set, stratifying to retain the same proportion of ice cream flavours in the training and test set. In this instance I am using a 70:30 Training:Test split. 
set.seed(123)
df_split <- initial_split(df_answers, prop = 0.7, strata = SurveyAnswer)

train_data <- training(df_split) #6,989 customer records
test_data  <- testing(df_split) #2,997 customer records


#As I am using tidymodels, I use a recipe to conduct the pre-processing steps. 
df_recipe <- 
  recipe(SurveyAnswer ~ ., data = train_data) %>% 
  update_role(AccountID, new_role = "id variable") %>% #Variables included as id variables are not included as predictors. 
  step_zv(all_predictors()) #%>% #remove columns from the data when the training set data have a single value
 # step_upsample(SurveyAnswer, over_ratio = 0.5) #%>%
 #   prep() %>%
 #  bake(new_data = NULL) %>%
 #  ggplot(aes(SurveyAnswer)) +
 #  geom_bar()
  
summary(df_recipe)
## # A tibble: 11 × 4
##    variable           type      role        source  
##    <chr>              <list>    <chr>       <chr>   
##  1 AccountID          <chr [2]> id variable original
##  2 Age                <chr [2]> predictor   original
##  3 State              <chr [3]> predictor   original
##  4 RegistrationDate   <chr [1]> predictor   original
##  5 RegistrationDevice <chr [3]> predictor   original
##  6 FirstBetDate       <chr [1]> predictor   original
##  7 FirstBetDevice     <chr [3]> predictor   original
##  8 AcquisitionSource  <chr [3]> predictor   original
##  9 MainBetSport       <chr [3]> predictor   original
## 10 FirstWeekTurnover  <chr [2]> predictor   original
## 11 SurveyAnswer       <chr [3]> outcome     original
#Include set of model options to implement.

#multinomial logistic regression
lr_mod <- 
  multinom_reg() %>% 
  set_engine("nnet") #64.8%, model with all predictors, except Account ID

#DT model
tree_mod <- 
  decision_tree() %>% 
  set_engine("rpart") %>% 
    set_mode("classification") #66.1%, model with all predictors, except Account ID

#Random forest model
rf_mod <- 
  rand_forest(trees = 1000) %>% 
  set_engine("ranger",importance = "impurity") %>% 
  set_mode("classification") %>%  #65.1%, model with all predictors, except Account ID 
   translate()
#The first application of modelling is to trial cross validation. 
# 10-fold cross-validation on the training data. That enables us to assess model fit, before applying to test set. 
set.seed(345)
folds <- vfold_cv(train_data, v = 10)

#We don't use recipe in this instance so we may need to apply a few additional steps here.
df_wflow <- 
  workflow() %>% 
  add_model(rf_mod) %>% #Change method, as desired
  add_formula(SurveyAnswer ~ .)

df_fit <- 
df_wflow %>% 
   fit_resamples(folds)

collect_metrics(df_fit) #When using the rf_mod, the mean accuracy for 10 fold CV = 64.9. We can use this to ensure we don't have a vastly different accuracy when applying the trained model to the testing data.
## # A tibble: 2 × 6
##   .metric  .estimator  mean     n std_err .config             
##   <chr>    <chr>      <dbl> <int>   <dbl> <chr>               
## 1 accuracy multiclass 0.649    10 0.00588 Preprocessor1_Model1
## 2 roc_auc  hand_till  0.698    10 0.00564 Preprocessor1_Model1
#Now to run the model and assess model fit on the testing data set.
df_wflow <- 
  workflow() %>% 
  add_model(rf_mod) %>% #Change method, as desired
  add_recipe(df_recipe)

df_fit <- 
df_wflow %>% 
  fit(data = train_data)


predict(df_fit, test_data)
## # A tibble: 2,997 × 1
##    .pred_class
##    <fct>      
##  1 Chocolate  
##  2 Chocolate  
##  3 Vanilla    
##  4 Vanilla    
##  5 Chocolate  
##  6 Chocolate  
##  7 Chocolate  
##  8 Chocolate  
##  9 Chocolate  
## 10 Chocolate  
## # ℹ 2,987 more rows
df_aug <- 
  augment(df_fit, test_data) #change to df_predict when needed


#Calculating metrics to assess model fit

last_fit_rf <- last_fit(df_wflow, 
                        split = df_split,
                        metrics = metric_set(
                          recall, precision, f_meas, mcc,
                          accuracy, kap,
                          roc_auc, sens, spec)
                        )

table_data <- last_fit_rf %>% 
  collect_metrics()

kable(table_data,
       caption = "Model Performance Metrics",
       col.names = c("Metric", "Estimator", "Estimate", "Configuration"),
       digits = 3)  # Adjust digits for desired precision
Model Performance Metrics
Metric Estimator Estimate Configuration
recall macro 0.423 Preprocessor1_Model1
precision macro 0.530 Preprocessor1_Model1
f_meas macro 0.420 Preprocessor1_Model1
mcc multiclass 0.200 Preprocessor1_Model1
accuracy multiclass 0.654 Preprocessor1_Model1
kap multiclass 0.173 Preprocessor1_Model1
sens macro 0.423 Preprocessor1_Model1
spec macro 0.713 Preprocessor1_Model1
roc_auc hand_till 0.682 Preprocessor1_Model1
kable(table_data, caption = "Model Performance Metrics", col.names = c("Metric", "Estimator", "Estimate", "Configuration"),
       digits = 3) %>%
  kable_styling(full_width = FALSE,
                latex_options = "HOLD_position")
Model Performance Metrics
Metric Estimator Estimate Configuration
recall macro 0.423 Preprocessor1_Model1
precision macro 0.530 Preprocessor1_Model1
f_meas macro 0.420 Preprocessor1_Model1
mcc multiclass 0.200 Preprocessor1_Model1
accuracy multiclass 0.654 Preprocessor1_Model1
kap multiclass 0.173 Preprocessor1_Model1
sens macro 0.423 Preprocessor1_Model1
spec macro 0.713 Preprocessor1_Model1
roc_auc hand_till 0.682 Preprocessor1_Model1
accuracy(df_aug, truth = SurveyAnswer, .pred_class) #When the trained model is applied to the test data the accuracy is similar (65.2%) to the 10 fold CV trained model performance, this suggests the model is not suffering from being overfit. 
## # A tibble: 1 × 3
##   .metric  .estimator .estimate
##   <chr>    <chr>          <dbl>
## 1 accuracy multiclass     0.652
#We have many other options for assess model fit
mcc(df_aug, SurveyAnswer, .pred_class) #Matthews Correlation Coefficient- ideal for imbalance classification problems!
## # A tibble: 1 × 3
##   .metric .estimator .estimate
##   <chr>   <chr>          <dbl>
## 1 mcc     multiclass     0.197
#https://towardsdatascience.com/matthews-correlation-coefficient-when-to-use-it-and-when-to-avoid-it-310b3c923f7e#:~:text=The%20F1%20score%20and%20the,used%20in%20binary%20classification%20scenarios.

kap(df_aug, SurveyAnswer, .pred_class) #Kappa = 0.17
## # A tibble: 1 × 3
##   .metric .estimator .estimate
##   <chr>   <chr>          <dbl>
## 1 kap     multiclass     0.171
precision(df_aug, SurveyAnswer, .pred_class)
## # A tibble: 1 × 3
##   .metric   .estimator .estimate
##   <chr>     <chr>          <dbl>
## 1 precision macro          0.521
precision(df_aug, SurveyAnswer, .pred_class, estimator = "macro_weighted")
## # A tibble: 1 × 3
##   .metric   .estimator     .estimate
##   <chr>     <chr>              <dbl>
## 1 precision macro_weighted     0.600
class_totals <- 
  count(df_aug, SurveyAnswer, name = "totals") %>% 
  mutate(class_wts = totals / sum(totals))

cell_counts <- 
  df_aug %>% 
  group_by(SurveyAnswer, .pred_class) %>% 
  count() %>% 
  ungroup()

one_versus_all <- 
  cell_counts %>% 
  filter(SurveyAnswer == .pred_class) %>% 
  full_join(class_totals, by = "SurveyAnswer") %>% 
  mutate(sens = n / totals)
one_versus_all
## # A tibble: 3 × 6
##   SurveyAnswer .pred_class     n totals class_wts   sens
##   <fct>        <fct>       <int>  <int>     <dbl>  <dbl>
## 1 Chocolate    Chocolate    1755   1943     0.648 0.903 
## 2 Strawberry   Strawberry     33    477     0.159 0.0692
## 3 Vanilla      Vanilla       167    577     0.193 0.289
one_versus_all %>% 
  summarize(
    macro = mean(sens), 
    macro_wts = weighted.mean(sens, class_wts),
    micro = sum(n) / sum(totals))
## # A tibble: 1 × 3
##   macro macro_wts micro
##   <dbl>     <dbl> <dbl>
## 1 0.421     0.652 0.652
sensitivity(df_aug, SurveyAnswer, .pred_class, estimator = "macro")
## # A tibble: 1 × 3
##   .metric     .estimator .estimate
##   <chr>       <chr>          <dbl>
## 1 sensitivity macro          0.421
sensitivity(df_aug, SurveyAnswer, .pred_class, estimator = "macro_weighted")
## # A tibble: 1 × 3
##   .metric     .estimator     .estimate
##   <chr>       <chr>              <dbl>
## 1 sensitivity macro_weighted     0.652
sensitivity(df_aug, SurveyAnswer, .pred_class, estimator = "micro")
## # A tibble: 1 × 3
##   .metric     .estimator .estimate
##   <chr>       <chr>          <dbl>
## 1 sensitivity micro          0.652
roc_auc(df_aug, SurveyAnswer, .pred_Chocolate, .pred_Strawberry, .pred_Vanilla)
## # A tibble: 1 × 3
##   .metric .estimator .estimate
##   <chr>   <chr>          <dbl>
## 1 roc_auc hand_till      0.682
roc_auc(df_aug, SurveyAnswer, .pred_Chocolate, .pred_Strawberry, .pred_Vanilla, estimator = "hand_till")
## # A tibble: 1 × 3
##   .metric .estimator .estimate
##   <chr>   <chr>          <dbl>
## 1 roc_auc hand_till      0.682
df_aug %>%
roc_curve(SurveyAnswer, .pred_Chocolate:.pred_Vanilla) %>%
autoplot() +
  theme_classic()

#Identifying what variables are important in the model and visualise 
fitted_model <- extract_fit_parsnip(df_fit)
vi_data <- vip(fitted_model)

plot(vi_data) +
  geom_col(fill = "lightblue") +
  ggpubr::theme_pubr() +
  ggpubr::rotate_x_text(45) +
  labs(title = "Variable Importance")

#understanding customer characteristics representative for each ice cream flavour.
train_data %>%
  ggplot(aes(x = SurveyAnswer, fill = MainBetSport)) +
  geom_bar(position = "dodge") +  # Use position = "dodge" to separate bars
  geom_text(aes(label = after_stat(count)), stat = "count", position = position_dodge(0.9), vjust = -0.2) +
  ggpubr::theme_pubr() +
  labs(title = "Count of MainBetSport by SurveyAnswer Category",
       x = "SurveyAnswer Category",
       y = "Count")

df_aug %>%
  ggplot(aes(x = .pred_class, fill = MainBetSport)) +
  geom_bar(position = "dodge") +  # Use position = "dodge" to separate bars
  ggpubr::theme_pubr() +
    geom_text(aes(label = after_stat(count)), stat = "count", position = position_dodge(0.9), vjust = -0.2) +
  labs(title = "Count of MainBetSport by SurveyAnswer Category",
       x = "SurveyAnswer Category",
       y = "Count")

#Another approach to attacking the problem. Secondary method. 
rf.fit <- randomForest(SurveyAnswer ~ ., data=train_data, ntree=1000,
                       keep.forest=FALSE, importance=TRUE)

varImpPlot(rf.fit)

# Get variable importance from the model fit
ImpData <- as.data.frame(rf.fit$importance) %>% 
  slice(-1) #Removes AccountID from variable ranking
ImpData$Var.Names <- row.names(ImpData)

# Reorder the data based on MeanDecreaseGini
ImpData <- transform(ImpData, Var.Names = reorder(Var.Names, MeanDecreaseGini))

# Plot the data
var_imp_plot <- ggplot(ImpData, aes(x = Var.Names, y = MeanDecreaseGini)) +
  geom_segment(aes(x = Var.Names, xend = Var.Names, y = 0, yend = MeanDecreaseGini), color = "skyblue") +
  geom_point(aes(size = MeanDecreaseAccuracy), color = "blue", alpha = 0.6) +
  theme_classic() +
  coord_flip() +
  theme(
    legend.position = "bottom",
    panel.grid.major.y = element_blank(),
    panel.border = element_blank(),
    axis.ticks.y = element_blank(),
    axis.title.y = element_blank()
  )


ggplotly(var_imp_plot)
#Investigating customer characteristics for each flavour 
df_answers %>% 
  dplyr::group_by(SurveyAnswer) %>% 
count(MainBetSport) %>% 
  arrange(desc(SurveyAnswer))
## # A tibble: 30 × 3
## # Groups:   SurveyAnswer [3]
##    SurveyAnswer MainBetSport              n
##    <fct>        <chr>                 <int>
##  1 Vanilla      Cricket                  19
##  2 Vanilla      Darts                    42
##  3 Vanilla      Elephant Racing         418
##  4 Vanilla      Horse Racing           1310
##  5 Vanilla      Motor Racing             14
##  6 Vanilla      Politics                 25
##  7 Vanilla      Scrabble                 50
##  8 Vanilla      Soccer                   15
##  9 Vanilla      Synchronised Swimming    16
## 10 Vanilla      e Sports                 13
## # ℹ 20 more rows
#Some further methods and model investigations
library(caret)
## Loading required package: lattice
## 
## Attaching package: 'caret'
## The following objects are masked from 'package:yardstick':
## 
##     precision, recall, sensitivity, specificity
## The following object is masked from 'package:purrr':
## 
##     lift
library(mlbench)

control <- trainControl(method="cv", number=10)

fit <- train(SurveyAnswer~., data=train_data, method="gbm", metric="Accuracy", trControl=control)
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1258
##      2        1.0262             nan     0.1000    0.0888
##      3        0.9737             nan     0.1000    0.0627
##      4        0.9353             nan     0.1000    0.0438
##      5        0.9085             nan     0.1000    0.0341
##      6        0.8869             nan     0.1000    0.0235
##      7        0.8712             nan     0.1000    0.0190
##      8        0.8591             nan     0.1000    0.0146
##      9        0.8499             nan     0.1000    0.0116
##     10        0.8423             nan     0.1000    0.0098
##     20        0.8078             nan     0.1000    0.0020
##     40        0.7862             nan     0.1000    0.0003
##     60        0.7769             nan     0.1000   -0.0003
##     80        0.7719             nan     0.1000   -0.0003
##    100        0.7681             nan     0.1000   -0.0005
##    120        0.7656             nan     0.1000   -0.0002
##    140        0.7636             nan     0.1000   -0.0004
##    150        0.7625             nan     0.1000   -0.0005
## 
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1287
##      2        1.0196             nan     0.1000    0.0899
##      3        0.9643             nan     0.1000    0.0665
##      4        0.9233             nan     0.1000    0.0456
##      5        0.8931             nan     0.1000    0.0361
##      6        0.8701             nan     0.1000    0.0262
##      7        0.8518             nan     0.1000    0.0200
##      8        0.8386             nan     0.1000    0.0154
##      9        0.8285             nan     0.1000    0.0105
##     10        0.8210             nan     0.1000    0.0091
##     20        0.7864             nan     0.1000    0.0024
##     40        0.7683             nan     0.1000   -0.0002
##     60        0.7584             nan     0.1000   -0.0007
##     80        0.7511             nan     0.1000   -0.0005
##    100        0.7450             nan     0.1000   -0.0014
##    120        0.7400             nan     0.1000   -0.0005
##    140        0.7349             nan     0.1000   -0.0012
##    150        0.7327             nan     0.1000   -0.0008
## 
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1320
##      2        1.0194             nan     0.1000    0.0937
##      3        0.9631             nan     0.1000    0.0662
##      4        0.9195             nan     0.1000    0.0499
##      5        0.8883             nan     0.1000    0.0378
##      6        0.8657             nan     0.1000    0.0287
##      7        0.8478             nan     0.1000    0.0217
##      8        0.8335             nan     0.1000    0.0153
##      9        0.8217             nan     0.1000    0.0119
##     10        0.8137             nan     0.1000    0.0090
##     20        0.7787             nan     0.1000    0.0014
##     40        0.7575             nan     0.1000   -0.0003
##     60        0.7438             nan     0.1000   -0.0010
##     80        0.7330             nan     0.1000   -0.0010
##    100        0.7232             nan     0.1000   -0.0017
##    120        0.7141             nan     0.1000   -0.0018
##    140        0.7050             nan     0.1000   -0.0014
##    150        0.7013             nan     0.1000   -0.0009
## 
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1251
##      2        1.0251             nan     0.1000    0.0882
##      3        0.9722             nan     0.1000    0.0634
##      4        0.9336             nan     0.1000    0.0463
##      5        0.9059             nan     0.1000    0.0341
##      6        0.8847             nan     0.1000    0.0239
##      7        0.8690             nan     0.1000    0.0175
##      8        0.8562             nan     0.1000    0.0140
##      9        0.8472             nan     0.1000    0.0106
##     10        0.8396             nan     0.1000    0.0078
##     20        0.8068             nan     0.1000    0.0018
##     40        0.7854             nan     0.1000   -0.0003
##     60        0.7764             nan     0.1000   -0.0007
##     80        0.7711             nan     0.1000   -0.0002
##    100        0.7679             nan     0.1000   -0.0007
##    120        0.7646             nan     0.1000   -0.0006
##    140        0.7620             nan     0.1000   -0.0006
##    150        0.7608             nan     0.1000   -0.0005
## 
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1302
##      2        1.0194             nan     0.1000    0.0915
##      3        0.9633             nan     0.1000    0.0662
##      4        0.9221             nan     0.1000    0.0477
##      5        0.8908             nan     0.1000    0.0357
##      6        0.8678             nan     0.1000    0.0258
##      7        0.8508             nan     0.1000    0.0209
##      8        0.8372             nan     0.1000    0.0137
##      9        0.8266             nan     0.1000    0.0108
##     10        0.8195             nan     0.1000    0.0088
##     20        0.7861             nan     0.1000    0.0021
##     40        0.7665             nan     0.1000   -0.0003
##     60        0.7576             nan     0.1000   -0.0005
##     80        0.7510             nan     0.1000   -0.0003
##    100        0.7449             nan     0.1000   -0.0010
##    120        0.7388             nan     0.1000   -0.0007
##    140        0.7331             nan     0.1000   -0.0009
##    150        0.7310             nan     0.1000   -0.0008
## 
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1321
##      2        1.0189             nan     0.1000    0.0926
##      3        0.9610             nan     0.1000    0.0679
##      4        0.9181             nan     0.1000    0.0494
##      5        0.8878             nan     0.1000    0.0374
##      6        0.8632             nan     0.1000    0.0261
##      7        0.8460             nan     0.1000    0.0217
##      8        0.8316             nan     0.1000    0.0163
##      9        0.8196             nan     0.1000    0.0134
##     10        0.8109             nan     0.1000    0.0089
##     20        0.7760             nan     0.1000   -0.0001
##     40        0.7564             nan     0.1000   -0.0005
##     60        0.7453             nan     0.1000   -0.0010
##     80        0.7357             nan     0.1000   -0.0012
##    100        0.7265             nan     0.1000   -0.0014
##    120        0.7181             nan     0.1000   -0.0007
##    140        0.7093             nan     0.1000   -0.0018
##    150        0.7055             nan     0.1000   -0.0016
## 
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1251
##      2        1.0255             nan     0.1000    0.0876
##      3        0.9735             nan     0.1000    0.0611
##      4        0.9342             nan     0.1000    0.0443
##      5        0.9077             nan     0.1000    0.0332
##      6        0.8869             nan     0.1000    0.0235
##      7        0.8719             nan     0.1000    0.0186
##      8        0.8599             nan     0.1000    0.0132
##      9        0.8512             nan     0.1000    0.0112
##     10        0.8443             nan     0.1000    0.0078
##     20        0.8102             nan     0.1000    0.0027
##     40        0.7881             nan     0.1000   -0.0002
##     60        0.7793             nan     0.1000   -0.0003
##     80        0.7737             nan     0.1000   -0.0003
##    100        0.7701             nan     0.1000   -0.0002
##    120        0.7672             nan     0.1000   -0.0009
##    140        0.7648             nan     0.1000   -0.0009
##    150        0.7640             nan     0.1000   -0.0006
## 
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1281
##      2        1.0214             nan     0.1000    0.0893
##      3        0.9661             nan     0.1000    0.0665
##      4        0.9268             nan     0.1000    0.0473
##      5        0.8956             nan     0.1000    0.0338
##      6        0.8733             nan     0.1000    0.0267
##      7        0.8554             nan     0.1000    0.0192
##      8        0.8424             nan     0.1000    0.0169
##      9        0.8313             nan     0.1000    0.0128
##     10        0.8230             nan     0.1000    0.0086
##     20        0.7883             nan     0.1000    0.0010
##     40        0.7698             nan     0.1000   -0.0002
##     60        0.7597             nan     0.1000   -0.0013
##     80        0.7520             nan     0.1000   -0.0012
##    100        0.7463             nan     0.1000   -0.0011
##    120        0.7406             nan     0.1000   -0.0015
##    140        0.7354             nan     0.1000   -0.0006
##    150        0.7331             nan     0.1000   -0.0007
## 
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1282
##      2        1.0196             nan     0.1000    0.0925
##      3        0.9627             nan     0.1000    0.0661
##      4        0.9210             nan     0.1000    0.0496
##      5        0.8893             nan     0.1000    0.0353
##      6        0.8658             nan     0.1000    0.0272
##      7        0.8492             nan     0.1000    0.0209
##      8        0.8356             nan     0.1000    0.0145
##      9        0.8255             nan     0.1000    0.0126
##     10        0.8158             nan     0.1000    0.0081
##     20        0.7808             nan     0.1000    0.0007
##     40        0.7601             nan     0.1000   -0.0008
##     60        0.7461             nan     0.1000   -0.0015
##     80        0.7352             nan     0.1000   -0.0011
##    100        0.7254             nan     0.1000   -0.0014
##    120        0.7156             nan     0.1000   -0.0013
##    140        0.7076             nan     0.1000   -0.0013
##    150        0.7039             nan     0.1000   -0.0021
## 
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1218
##      2        1.0236             nan     0.1000    0.0859
##      3        0.9724             nan     0.1000    0.0627
##      4        0.9353             nan     0.1000    0.0451
##      5        0.9075             nan     0.1000    0.0325
##      6        0.8871             nan     0.1000    0.0234
##      7        0.8715             nan     0.1000    0.0178
##      8        0.8594             nan     0.1000    0.0134
##      9        0.8501             nan     0.1000    0.0105
##     10        0.8425             nan     0.1000    0.0086
##     20        0.8084             nan     0.1000    0.0018
##     40        0.7885             nan     0.1000    0.0004
##     60        0.7790             nan     0.1000   -0.0008
##     80        0.7731             nan     0.1000   -0.0002
##    100        0.7693             nan     0.1000   -0.0008
##    120        0.7665             nan     0.1000   -0.0007
##    140        0.7640             nan     0.1000   -0.0003
##    150        0.7631             nan     0.1000   -0.0006
## 
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1282
##      2        1.0195             nan     0.1000    0.0910
##      3        0.9651             nan     0.1000    0.0647
##      4        0.9233             nan     0.1000    0.0466
##      5        0.8923             nan     0.1000    0.0345
##      6        0.8704             nan     0.1000    0.0267
##      7        0.8541             nan     0.1000    0.0206
##      8        0.8407             nan     0.1000    0.0152
##      9        0.8297             nan     0.1000    0.0116
##     10        0.8220             nan     0.1000    0.0080
##     20        0.7900             nan     0.1000    0.0013
##     40        0.7702             nan     0.1000   -0.0002
##     60        0.7605             nan     0.1000   -0.0007
##     80        0.7526             nan     0.1000   -0.0007
##    100        0.7470             nan     0.1000   -0.0006
##    120        0.7415             nan     0.1000   -0.0009
##    140        0.7366             nan     0.1000   -0.0006
##    150        0.7344             nan     0.1000   -0.0009
## 
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1303
##      2        1.0192             nan     0.1000    0.0926
##      3        0.9622             nan     0.1000    0.0667
##      4        0.9197             nan     0.1000    0.0481
##      5        0.8887             nan     0.1000    0.0351
##      6        0.8648             nan     0.1000    0.0264
##      7        0.8475             nan     0.1000    0.0193
##      8        0.8345             nan     0.1000    0.0171
##      9        0.8244             nan     0.1000    0.0104
##     10        0.8166             nan     0.1000    0.0089
##     20        0.7808             nan     0.1000    0.0006
##     40        0.7596             nan     0.1000   -0.0008
##     60        0.7469             nan     0.1000   -0.0010
##     80        0.7360             nan     0.1000   -0.0006
##    100        0.7262             nan     0.1000   -0.0019
##    120        0.7177             nan     0.1000   -0.0009
##    140        0.7095             nan     0.1000   -0.0018
##    150        0.7053             nan     0.1000   -0.0017
## 
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1237
##      2        1.0233             nan     0.1000    0.0868
##      3        0.9712             nan     0.1000    0.0624
##      4        0.9341             nan     0.1000    0.0459
##      5        0.9068             nan     0.1000    0.0326
##      6        0.8863             nan     0.1000    0.0248
##      7        0.8711             nan     0.1000    0.0184
##      8        0.8596             nan     0.1000    0.0139
##      9        0.8507             nan     0.1000    0.0105
##     10        0.8432             nan     0.1000    0.0091
##     20        0.8083             nan     0.1000    0.0008
##     40        0.7878             nan     0.1000    0.0000
##     60        0.7786             nan     0.1000   -0.0004
##     80        0.7737             nan     0.1000   -0.0001
##    100        0.7702             nan     0.1000   -0.0009
##    120        0.7669             nan     0.1000   -0.0006
##    140        0.7644             nan     0.1000   -0.0005
##    150        0.7634             nan     0.1000   -0.0006
## 
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1312
##      2        1.0236             nan     0.1000    0.0941
##      3        0.9675             nan     0.1000    0.0675
##      4        0.9260             nan     0.1000    0.0498
##      5        0.8951             nan     0.1000    0.0373
##      6        0.8719             nan     0.1000    0.0278
##      7        0.8540             nan     0.1000    0.0201
##      8        0.8407             nan     0.1000    0.0148
##      9        0.8303             nan     0.1000    0.0119
##     10        0.8215             nan     0.1000    0.0094
##     20        0.7899             nan     0.1000    0.0006
##     40        0.7700             nan     0.1000   -0.0003
##     60        0.7597             nan     0.1000   -0.0006
##     80        0.7523             nan     0.1000   -0.0006
##    100        0.7459             nan     0.1000   -0.0008
##    120        0.7398             nan     0.1000   -0.0007
##    140        0.7348             nan     0.1000   -0.0008
##    150        0.7323             nan     0.1000   -0.0006
## 
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1328
##      2        1.0195             nan     0.1000    0.0926
##      3        0.9616             nan     0.1000    0.0678
##      4        0.9206             nan     0.1000    0.0487
##      5        0.8893             nan     0.1000    0.0362
##      6        0.8661             nan     0.1000    0.0269
##      7        0.8488             nan     0.1000    0.0199
##      8        0.8349             nan     0.1000    0.0168
##      9        0.8243             nan     0.1000    0.0132
##     10        0.8155             nan     0.1000    0.0083
##     20        0.7815             nan     0.1000    0.0027
##     40        0.7587             nan     0.1000   -0.0010
##     60        0.7455             nan     0.1000   -0.0013
##     80        0.7354             nan     0.1000   -0.0017
##    100        0.7258             nan     0.1000   -0.0011
##    120        0.7180             nan     0.1000   -0.0017
##    140        0.7106             nan     0.1000   -0.0011
##    150        0.7068             nan     0.1000   -0.0011
## 
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1250
##      2        1.0246             nan     0.1000    0.0873
##      3        0.9719             nan     0.1000    0.0625
##      4        0.9337             nan     0.1000    0.0450
##      5        0.9052             nan     0.1000    0.0316
##      6        0.8843             nan     0.1000    0.0248
##      7        0.8698             nan     0.1000    0.0172
##      8        0.8573             nan     0.1000    0.0133
##      9        0.8489             nan     0.1000    0.0114
##     10        0.8412             nan     0.1000    0.0086
##     20        0.8079             nan     0.1000    0.0014
##     40        0.7874             nan     0.1000    0.0004
##     60        0.7783             nan     0.1000   -0.0002
##     80        0.7732             nan     0.1000   -0.0006
##    100        0.7698             nan     0.1000   -0.0006
##    120        0.7669             nan     0.1000   -0.0012
##    140        0.7647             nan     0.1000   -0.0005
##    150        0.7636             nan     0.1000   -0.0008
## 
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1286
##      2        1.0194             nan     0.1000    0.0903
##      3        0.9642             nan     0.1000    0.0660
##      4        0.9236             nan     0.1000    0.0490
##      5        0.8922             nan     0.1000    0.0358
##      6        0.8689             nan     0.1000    0.0274
##      7        0.8515             nan     0.1000    0.0193
##      8        0.8390             nan     0.1000    0.0163
##      9        0.8286             nan     0.1000    0.0116
##     10        0.8198             nan     0.1000    0.0094
##     20        0.7883             nan     0.1000    0.0016
##     40        0.7692             nan     0.1000   -0.0008
##     60        0.7602             nan     0.1000   -0.0011
##     80        0.7528             nan     0.1000   -0.0017
##    100        0.7459             nan     0.1000   -0.0011
##    120        0.7403             nan     0.1000   -0.0010
##    140        0.7346             nan     0.1000   -0.0006
##    150        0.7324             nan     0.1000   -0.0010
## 
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1317
##      2        1.0181             nan     0.1000    0.0937
##      3        0.9612             nan     0.1000    0.0667
##      4        0.9193             nan     0.1000    0.0494
##      5        0.8886             nan     0.1000    0.0380
##      6        0.8651             nan     0.1000    0.0277
##      7        0.8482             nan     0.1000    0.0218
##      8        0.8339             nan     0.1000    0.0165
##      9        0.8229             nan     0.1000    0.0128
##     10        0.8139             nan     0.1000    0.0078
##     20        0.7790             nan     0.1000    0.0004
##     40        0.7576             nan     0.1000   -0.0009
##     60        0.7438             nan     0.1000   -0.0005
##     80        0.7336             nan     0.1000   -0.0008
##    100        0.7236             nan     0.1000   -0.0014
##    120        0.7149             nan     0.1000   -0.0008
##    140        0.7068             nan     0.1000   -0.0012
##    150        0.7032             nan     0.1000   -0.0011
## 
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1254
##      2        1.0231             nan     0.1000    0.0857
##      3        0.9703             nan     0.1000    0.0601
##      4        0.9329             nan     0.1000    0.0453
##      5        0.9051             nan     0.1000    0.0318
##      6        0.8833             nan     0.1000    0.0224
##      7        0.8683             nan     0.1000    0.0172
##      8        0.8563             nan     0.1000    0.0137
##      9        0.8472             nan     0.1000    0.0105
##     10        0.8402             nan     0.1000    0.0070
##     20        0.8059             nan     0.1000    0.0017
##     40        0.7851             nan     0.1000    0.0002
##     60        0.7749             nan     0.1000    0.0001
##     80        0.7694             nan     0.1000   -0.0006
##    100        0.7658             nan     0.1000   -0.0008
##    120        0.7631             nan     0.1000   -0.0008
##    140        0.7608             nan     0.1000   -0.0006
##    150        0.7596             nan     0.1000   -0.0007
## 
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1297
##      2        1.0201             nan     0.1000    0.0891
##      3        0.9627             nan     0.1000    0.0650
##      4        0.9227             nan     0.1000    0.0479
##      5        0.8917             nan     0.1000    0.0349
##      6        0.8688             nan     0.1000    0.0257
##      7        0.8520             nan     0.1000    0.0199
##      8        0.8384             nan     0.1000    0.0145
##      9        0.8274             nan     0.1000    0.0123
##     10        0.8194             nan     0.1000    0.0085
##     20        0.7857             nan     0.1000    0.0008
##     40        0.7663             nan     0.1000   -0.0008
##     60        0.7555             nan     0.1000   -0.0010
##     80        0.7481             nan     0.1000   -0.0008
##    100        0.7430             nan     0.1000   -0.0017
##    120        0.7378             nan     0.1000   -0.0008
##    140        0.7324             nan     0.1000   -0.0014
##    150        0.7302             nan     0.1000   -0.0009
## 
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1317
##      2        1.0173             nan     0.1000    0.0924
##      3        0.9594             nan     0.1000    0.0671
##      4        0.9171             nan     0.1000    0.0493
##      5        0.8850             nan     0.1000    0.0367
##      6        0.8609             nan     0.1000    0.0248
##      7        0.8437             nan     0.1000    0.0191
##      8        0.8301             nan     0.1000    0.0138
##      9        0.8204             nan     0.1000    0.0124
##     10        0.8119             nan     0.1000    0.0083
##     20        0.7774             nan     0.1000    0.0002
##     40        0.7562             nan     0.1000   -0.0006
##     60        0.7440             nan     0.1000   -0.0008
##     80        0.7336             nan     0.1000   -0.0007
##    100        0.7244             nan     0.1000   -0.0010
##    120        0.7162             nan     0.1000   -0.0015
##    140        0.7085             nan     0.1000   -0.0010
##    150        0.7044             nan     0.1000   -0.0021
## 
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1241
##      2        1.0246             nan     0.1000    0.0866
##      3        0.9728             nan     0.1000    0.0637
##      4        0.9346             nan     0.1000    0.0453
##      5        0.9056             nan     0.1000    0.0333
##      6        0.8850             nan     0.1000    0.0238
##      7        0.8706             nan     0.1000    0.0190
##      8        0.8592             nan     0.1000    0.0145
##      9        0.8501             nan     0.1000    0.0118
##     10        0.8426             nan     0.1000    0.0094
##     20        0.8070             nan     0.1000    0.0016
##     40        0.7855             nan     0.1000    0.0003
##     60        0.7767             nan     0.1000   -0.0001
##     80        0.7712             nan     0.1000   -0.0006
##    100        0.7674             nan     0.1000   -0.0006
##    120        0.7645             nan     0.1000   -0.0004
##    140        0.7624             nan     0.1000   -0.0006
##    150        0.7613             nan     0.1000   -0.0006
## 
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1294
##      2        1.0193             nan     0.1000    0.0891
##      3        0.9625             nan     0.1000    0.0656
##      4        0.9216             nan     0.1000    0.0475
##      5        0.8912             nan     0.1000    0.0368
##      6        0.8688             nan     0.1000    0.0269
##      7        0.8510             nan     0.1000    0.0186
##      8        0.8375             nan     0.1000    0.0148
##      9        0.8278             nan     0.1000    0.0115
##     10        0.8200             nan     0.1000    0.0075
##     20        0.7875             nan     0.1000    0.0017
##     40        0.7686             nan     0.1000   -0.0004
##     60        0.7582             nan     0.1000   -0.0006
##     80        0.7506             nan     0.1000   -0.0013
##    100        0.7453             nan     0.1000   -0.0006
##    120        0.7392             nan     0.1000   -0.0005
##    140        0.7337             nan     0.1000   -0.0012
##    150        0.7311             nan     0.1000   -0.0007
## 
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1316
##      2        1.0190             nan     0.1000    0.0933
##      3        0.9615             nan     0.1000    0.0675
##      4        0.9191             nan     0.1000    0.0485
##      5        0.8880             nan     0.1000    0.0360
##      6        0.8643             nan     0.1000    0.0278
##      7        0.8463             nan     0.1000    0.0209
##      8        0.8322             nan     0.1000    0.0143
##      9        0.8216             nan     0.1000    0.0134
##     10        0.8126             nan     0.1000    0.0081
##     20        0.7777             nan     0.1000    0.0002
##     40        0.7573             nan     0.1000   -0.0014
##     60        0.7444             nan     0.1000   -0.0008
##     80        0.7337             nan     0.1000   -0.0015
##    100        0.7244             nan     0.1000   -0.0012
##    120        0.7156             nan     0.1000   -0.0013
##    140        0.7088             nan     0.1000   -0.0015
##    150        0.7052             nan     0.1000   -0.0012
## 
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1239
##      2        1.0242             nan     0.1000    0.0875
##      3        0.9723             nan     0.1000    0.0617
##      4        0.9333             nan     0.1000    0.0440
##      5        0.9046             nan     0.1000    0.0314
##      6        0.8846             nan     0.1000    0.0237
##      7        0.8702             nan     0.1000    0.0177
##      8        0.8587             nan     0.1000    0.0140
##      9        0.8494             nan     0.1000    0.0114
##     10        0.8419             nan     0.1000    0.0092
##     20        0.8080             nan     0.1000    0.0021
##     40        0.7865             nan     0.1000    0.0000
##     60        0.7775             nan     0.1000   -0.0002
##     80        0.7726             nan     0.1000   -0.0006
##    100        0.7690             nan     0.1000   -0.0004
##    120        0.7661             nan     0.1000   -0.0008
##    140        0.7638             nan     0.1000   -0.0005
##    150        0.7631             nan     0.1000   -0.0006
## 
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1317
##      2        1.0209             nan     0.1000    0.0919
##      3        0.9654             nan     0.1000    0.0649
##      4        0.9243             nan     0.1000    0.0497
##      5        0.8939             nan     0.1000    0.0358
##      6        0.8718             nan     0.1000    0.0290
##      7        0.8544             nan     0.1000    0.0209
##      8        0.8415             nan     0.1000    0.0159
##      9        0.8307             nan     0.1000    0.0119
##     10        0.8229             nan     0.1000    0.0103
##     20        0.7888             nan     0.1000    0.0017
##     40        0.7682             nan     0.1000   -0.0009
##     60        0.7593             nan     0.1000   -0.0008
##     80        0.7517             nan     0.1000   -0.0010
##    100        0.7449             nan     0.1000   -0.0007
##    120        0.7391             nan     0.1000   -0.0010
##    140        0.7341             nan     0.1000   -0.0011
##    150        0.7317             nan     0.1000   -0.0005
## 
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1301
##      2        1.0185             nan     0.1000    0.0924
##      3        0.9609             nan     0.1000    0.0668
##      4        0.9181             nan     0.1000    0.0496
##      5        0.8880             nan     0.1000    0.0381
##      6        0.8639             nan     0.1000    0.0284
##      7        0.8457             nan     0.1000    0.0203
##      8        0.8327             nan     0.1000    0.0137
##      9        0.8226             nan     0.1000    0.0120
##     10        0.8144             nan     0.1000    0.0097
##     20        0.7786             nan     0.1000   -0.0012
##     40        0.7581             nan     0.1000   -0.0011
##     60        0.7448             nan     0.1000   -0.0016
##     80        0.7355             nan     0.1000   -0.0010
##    100        0.7261             nan     0.1000   -0.0013
##    120        0.7178             nan     0.1000   -0.0008
##    140        0.7102             nan     0.1000   -0.0015
##    150        0.7069             nan     0.1000   -0.0005
## 
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1258
##      2        1.0249             nan     0.1000    0.0867
##      3        0.9705             nan     0.1000    0.0609
##      4        0.9331             nan     0.1000    0.0457
##      5        0.9063             nan     0.1000    0.0326
##      6        0.8852             nan     0.1000    0.0233
##      7        0.8702             nan     0.1000    0.0178
##      8        0.8579             nan     0.1000    0.0146
##      9        0.8489             nan     0.1000    0.0101
##     10        0.8418             nan     0.1000    0.0091
##     20        0.8077             nan     0.1000    0.0020
##     40        0.7862             nan     0.1000    0.0004
##     60        0.7776             nan     0.1000   -0.0002
##     80        0.7720             nan     0.1000   -0.0004
##    100        0.7683             nan     0.1000   -0.0002
##    120        0.7657             nan     0.1000   -0.0002
##    140        0.7636             nan     0.1000   -0.0003
##    150        0.7623             nan     0.1000   -0.0013
## 
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1302
##      2        1.0202             nan     0.1000    0.0912
##      3        0.9649             nan     0.1000    0.0653
##      4        0.9239             nan     0.1000    0.0490
##      5        0.8931             nan     0.1000    0.0367
##      6        0.8697             nan     0.1000    0.0276
##      7        0.8519             nan     0.1000    0.0195
##      8        0.8386             nan     0.1000    0.0138
##      9        0.8293             nan     0.1000    0.0113
##     10        0.8212             nan     0.1000    0.0085
##     20        0.7873             nan     0.1000    0.0017
##     40        0.7684             nan     0.1000   -0.0017
##     60        0.7593             nan     0.1000   -0.0008
##     80        0.7515             nan     0.1000   -0.0003
##    100        0.7457             nan     0.1000   -0.0011
##    120        0.7408             nan     0.1000   -0.0008
##    140        0.7354             nan     0.1000   -0.0009
##    150        0.7332             nan     0.1000   -0.0016
## 
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1314
##      2        1.0193             nan     0.1000    0.0931
##      3        0.9617             nan     0.1000    0.0658
##      4        0.9205             nan     0.1000    0.0469
##      5        0.8890             nan     0.1000    0.0375
##      6        0.8649             nan     0.1000    0.0269
##      7        0.8473             nan     0.1000    0.0187
##      8        0.8346             nan     0.1000    0.0146
##      9        0.8227             nan     0.1000    0.0132
##     10        0.8136             nan     0.1000    0.0060
##     20        0.7772             nan     0.1000    0.0006
##     40        0.7576             nan     0.1000   -0.0008
##     60        0.7446             nan     0.1000   -0.0013
##     80        0.7343             nan     0.1000   -0.0003
##    100        0.7258             nan     0.1000   -0.0009
##    120        0.7180             nan     0.1000   -0.0010
##    140        0.7098             nan     0.1000   -0.0012
##    150        0.7063             nan     0.1000   -0.0007
## 
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.0986             nan     0.1000    0.1293
##      2        1.0182             nan     0.1000    0.0921
##      3        0.9609             nan     0.1000    0.0657
##      4        0.9188             nan     0.1000    0.0487
##      5        0.8876             nan     0.1000    0.0348
##      6        0.8644             nan     0.1000    0.0275
##      7        0.8476             nan     0.1000    0.0205
##      8        0.8337             nan     0.1000    0.0162
##      9        0.8231             nan     0.1000    0.0112
##     10        0.8154             nan     0.1000    0.0106
##     20        0.7804             nan     0.1000    0.0012
##     40        0.7593             nan     0.1000   -0.0005
##     60        0.7483             nan     0.1000   -0.0015
##     80        0.7375             nan     0.1000   -0.0014
##    100        0.7288             nan     0.1000   -0.0011
##    120        0.7203             nan     0.1000   -0.0011
##    140        0.7128             nan     0.1000   -0.0017
##    150        0.7097             nan     0.1000   -0.0013
print(fit)
## Stochastic Gradient Boosting 
## 
## 6989 samples
##   10 predictor
##    3 classes: 'Chocolate', 'Strawberry', 'Vanilla' 
## 
## No pre-processing
## Resampling: Cross-Validated (10 fold) 
## Summary of sample sizes: 6291, 6290, 6290, 6291, 6290, 6290, ... 
## Resampling results across tuning parameters:
## 
##   interaction.depth  n.trees  Accuracy   Kappa     
##   1                   50      0.6601823  0.09250061
##   1                  100      0.6586096  0.12284652
##   1                  150      0.6621878  0.15189283
##   2                   50      0.6633313  0.14513428
##   2                  100      0.6626117  0.17132133
##   2                  150      0.6643305  0.18683904
##   3                   50      0.6634715  0.16667731
##   3                  100      0.6630419  0.18392036
##   3                  150      0.6653311  0.19811774
## 
## Tuning parameter 'shrinkage' was held constant at a value of 0.1
## 
## Tuning parameter 'n.minobsinnode' was held constant at a value of 10
## Accuracy was used to select the optimal model using the largest value.
## The final values used for the model were n.trees = 150, interaction.depth =
##  3, shrinkage = 0.1 and n.minobsinnode = 10.