> require(party) > require(mlbench) > data(BreastCancer) > BreastCancer$Id <- NULL > grid <- expand.grid(.maxdepth=c(2:6), .mincriterion=c(0.95, 0.97, 0.99)) > print(grid) .maxdepth .mincriterion 1 2 0.95 2 3 0.95 3 4 0.95 4 5 0.95 5 6 0.95 6 2 0.97 7 3 0.97 8 4 0.97 9 5 0.97 10 6 0.97 11 2 0.99 12 3 0.99 13 4 0.99 14 5 0.99 15 6 0.99 > ct.best <- train(Class ~ . , data=BreastCancer, method="ctree", tuneGrid=grid) Loading required package: class Attaching package: 'class' The following object(s) are masked from 'package:reshape': condense Attaching package: 'e1071' The following object(s) are masked from 'package:gtools': permutations Fitting: maxdepth=2, mincriterion=0.95 Fitting: maxdepth=3, mincriterion=0.95 Fitting: maxdepth=4, mincriterion=0.95 Fitting: maxdepth=5, mincriterion=0.95 Fitting: maxdepth=6, mincriterion=0.95 > grid <- expand.grid(.maxdepth=c(2, 4), .mincriterion=c(0.95, 0.99)) > print(grid) .maxdepth .mincriterion 1 2 0.95 2 4 0.95 3 2 0.99 4 4 0.99 > ct.best <- train(Class ~ . , data=BreastCancer, method="ctree", tuneGrid=grid) Fitting: maxdepth=2, mincriterion=0.95 Fitting: maxdepth=4, mincriterion=0.95 Fitting: maxdepth=2, mincriterion=0.99 Fitting: maxdepth=4, mincriterion=0.99 Aggregating results Selecting tuning parameters Fitting model on full training set > print(ct.best) 683 samples 80 predictors Pre-processing: None Resampling: Bootstrap (25 reps) Summary of sample sizes: 683, 683, 683, 683, 683, 683, ... Resampling results across tuning parameters: mincriterion Accuracy Kappa maxdepth Accuracy SD Kappa SD maxdepth SD 0.95 0.939 0.867 3 0.0156 0.0337 1.01 0.99 0.94 0.868 3 0.0157 0.0337 1.01 Accuracy was used to select the optimal model using the largest value. The final value used for the model was mincriterion = 0.99. > > > > > grid <- expand.grid(.maxdepth=c(2, 4), .mincriterion=c(0.95, 0.99)) > print(grid) .maxdepth .mincriterion 1 2 0.95 2 4 0.95 3 2 0.99 4 4 0.99 > ct.best <- train(Class ~ . , data=BreastCancer, method="ctree2", tuneGrid=grid) Fitting: maxdepth=2, mincriterion=0.95 Fitting: maxdepth=4, mincriterion=0.95 Fitting: maxdepth=2, mincriterion=0.99 Fitting: maxdepth=4, mincriterion=0.99 Aggregating results Selecting tuning parameters Fitting model on full training set > print(ct.best) 683 samples 80 predictors Pre-processing: None Resampling: Bootstrap (25 reps) Summary of sample sizes: 683, 683, 683, 683, 683, 683, ... Resampling results across tuning parameters: maxdepth Accuracy Kappa mincriterion Accuracy SD Kappa SD mincriterion SD 2 0.935 0.858 0.97 0.0163 0.0343 0.0202 4 0.935 0.857 0.97 0.0142 0.0322 0.0202 Accuracy was used to select the optimal model using the largest value. The final value used for the model was maxdepth = 4.