how to initialize values of mtry for R.Forest

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

how to initialize values of mtry for R.Forest

NehaBologna
Hi, I am using Simulated Annealing to tune the parameters of the R.Forest.
The code I use is below:

My question is that did I do correctly when I used the values 1:24 in the
optim function of the Simulated annealing? I used 1:24 because my number of
features in the dataset are 24, and the mtry should be between 1-num of
features I guess.

obj <- function(param, maximize = FALSE) {
  mod <- train(log10(bugs) ~ ., data = training,
               method = "rf",
               preProc = c("center", "scale", "zv"),
               metric = "MAE",
               trControl = ctrl,

               tuneGrid = data.frame(mtry = 10^(param[1])))

                if(maximize)
    -getTrainPerf(mod)[, "TrainMAE"] else
      getTrainPerf(mod)[, "TrainMAE"]
}
num_mods <- 50

## Simulated annealing from base R

san_res <- optim(par = c(1:24), fn = obj, method = "SANN",
                 control = list(maxit = num_mods))
san_res

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.