[R] how to initialize values of mtry for R.Forest
    Neha gupta 
    neh@@bo|ogn@90 @end|ng |rom gm@||@com
       
    Sat Dec 21 19:38:06 CET 2019
    
    
  
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]]
    
    
More information about the R-help
mailing list