Expanding the Hyper-Parameter Search Grid in Caret I was wondering if there was a way to expand the hyper-parameter search within caret package or with slight modification. For example, evtree can currently only take alpha in caret but the evtree.control can take many more arguments. I doubt that I can just pass it through method = "evtree".
ctrl <- trainControl(method = "repeatedcv", number=10, repeats = 5,classProbs=TRUE,summaryFunction = twoClassSummary)


# Set up the cross-validated hyper-parameter search
EVTREE_GRID= expand.grid(pmutatemajor=c(0.2,0.2), pmutateminor=c(0.2,0.2), pcrossover=c(0.2,0.2),
                     psplit=c(0.2,0.2), pprune=c(0.2,0.2), minbucket=c(5L,10L), minsplit=c(15L,25L),
                     maxdepth=c(5L,15L),alpha=c(1L,5L))


EVTREE_fit_bayes <- function(pmutatemajor, pmutateminor, pcrossover, 
  psplit,pprune,minbucket,minsplit,maxdepth,alpha) {
    txt <- capture.output(
      mod <- train(Creditability~ ., data =XY_train,
                  method = "evtree",
                  preProc = c("center", "scale"),
                  metric = "AUC",
                  trControl = ctrl,
                  tuneGrid = EVTREE_GRID))

 list(Score = getTrainPerf(mod)[, "TrainAUC"], Pred)
 }


 library(rBayesianOptimization)
   EVTREE_Search <- BayesianOptimization(EVTREE_fit_bayes,

             bounds = list(pmutatemajor=c(0.2,0.2), pmutateminor=c(0.2,0.2), pcrossover=c(0.2,0.2), 
                           psplit=c(0.2,0.2), pprune=c(0.2,0.2), minbucket=c(5L,10L), 
                           minsplit=c(15L,25L), maxdepth=c(5L,15L), alpha=c(1L,5L)),

             init_grid_dt =NULL, 
             init_points =10, 
             n_iter = 10,
             acq = "ucb", 
             kappa =1, 
             eps = 0.0,
             verbose = TRUE)

 A: you can create your own model so basically you redefine the parameters for evtree, basically redefining the existing one for evtree, the elements of the list to change are under parameters, grid and fit (where you pass in evtree.control) :
evtree_ext <- list(label = "Tree Models from Genetic Algorithms",
                  library = c("evtree"),
                  loop = NULL,
                  type = c('Regression', 'Classification'),
                  parameters = data.frame(parameter = c("maxdepth","alpha"),
                                          class = rep('numeric',2),
                                          label = c('maxdepth','alpha')),
                  grid = function(x, y, len = NULL, search = "grid") {
                    if(search == "grid") {
                      out <- data.frame(alpha = seq(1, 3, length = len),maxdepth=seq(1,20,len=len)) 
                    } else {
                      out <- data.frame(alpha = runif(len, min = 1, max = 5),maxdepth=sample(1:20,len=len))
                    }
                    out
                  },
                  fit = function(x, y, wts, param, lev, last, classProbs, ...){
                    dat <- if(is.data.frame(x)) x else as.data.frame(x, stringsAsFactors = TRUE)
                    dat$.outcome <- y
                    theDots <- list(...)

                    if(any(names(theDots) == "control"))
                    {
                      theDots$control$alpha <- param$alpha 
                      ctl <- theDots$control
                      theDots$control <- NULL
                    } else ctl <- evtree::evtree.control(alpha = param$alpha,maxdepth=param$alpha)

                    ## pass in any model weights
                    if(!is.null(wts)) theDots$weights <- wts

                    modelArgs <- c(list(formula = as.formula(".outcome ~ ."),
                                        data = dat,
                                        control = ctl),
                                   theDots)

                    out <- do.call(evtree::evtree, modelArgs)
                    out
                  },
                  levels = function(x) x$obsLevels,
                  predict = function(modelFit, newdata, submodels = NULL) {
                    if(!is.data.frame(newdata)) newdata <- as.data.frame(newdata, stringsAsFactors = TRUE)
                    predict(modelFit, newdata)
                    },
                  prob = function(modelFit, newdata, submodels = NULL) {
                    if(!is.data.frame(newdata)) newdata <- as.data.frame(newdata, stringsAsFactors = TRUE)
                    predict(modelFit, newdata, type = "prob")
                    },
                  tags = c("Tree-Based Model", "Implicit Feature Selection", "Accepts Case Weights"),
                  sort = function(x) x[order(x[,1]),])

Using an example (sorry not familiar with this package, might be nonsense):
library(MASS)
library(caret)
library(evtree)
library(rBayesianOptimization)

mod <- train(type~ ., data =Pima.tr,method=evtree_ext,
tuneGrid=data.frame(alpha=c(1,2),maxdepth=c(5,10)),
trControl=trainControl(method="cv",number=2))

mod$results

  alpha maxdepth Accuracy     Kappa  AccuracySD    KappaSD
1     1        5    0.715 0.3511444 0.007071068 0.04724272
2     2       10    0.725 0.3273370 0.007071068 0.01357389

