Bayesian Optimization in r - results

Viewed 2885

I have an Bayesian Optimization code and it print results with Value and selected parameters. My question is - how is the best combinations chosen? The value in my case min RMSE was lower in different round?

Code:

library(xgboost)
library(rBayesianOptimization)


data(agaricus.train, package='xgboost')
dtrain <- xgb.DMatrix(agaricus.train$data, label = agaricus.train$label)

cv_folds <- KFold(
                  y
                  , nfolds = 5
                  , stratified = TRUE
                  , seed = 5000)

xgb_cv_bayes <- function(eta, max.depth, min_child_weight, subsample,colsample_bytree ) {
  cv <- xgb.cv(params = list(booster = "gbtree"
                            # , eta = 0.01
                             , eta = eta
                             , max_depth = max.depth
                             , min_child_weight = min_child_weight
                             , colsample_bytree = colsample_bytree
                             , subsample = subsample
                            #, colsample_bytree = 0.3
                             , lambda = 1
                             , alpha = 0
                             , objective = "reg:linear"
                             , eval_metric = "rmse")
               , data = dtrain
               , nround = 1000
               , folds = cv_folds
               , prediction = TRUE
               , showsd = TRUE
               , early_stopping_rounds = 10
               , maximize = TRUE
               , verbose = 0
               , finalize = TRUE)
  list(Score = cv$evaluation_log[,min(test_rmse_mean)]
       ,Pred = cv$pred
       , cb.print.evaluation(period = 1))
}

cat("Calculating Bayesian Optimum Parameters\n")

OPT_Res <- BayesianOptimization(xgb_cv_bayes
                                , bounds = list(
                                  eta = c(0.001, 0.03)
                                , max.depth = c(3L, 10L)
                                , min_child_weight = c(3L, 10L)
                                , subsample = c(0.8, 1)
                                , colsample_bytree = c(0.5, 1))

                                , init_grid_dt = NULL
                                , init_points = 10
                                , n_iter = 200
                                , acq = "ucb"
                                , kappa = 3
                                , eps = 1.5
                                , verbose = TRUE)
1 Answers
Related