| cv_xgboost | R Documentation | 
xgboost - parameter tuning and model selection with k-fold cross-validation and grid search
cv_xgboost(
  x,
  y,
  params = cv_param_grid(),
  n_folds = 5,
  n_threads = 1,
  seed = 42,
  verbose = TRUE
)
x | 
 Predictor matrix.  | 
y | 
 Response vector.  | 
params | 
 Parameter grid generated by   | 
n_folds | 
 Number of folds. Default is 5.  | 
n_threads | 
 The number of parallel threads. For optimal speed, match this to the number of physical CPU cores, not threads. See respective model documentation for more details. Default is 1.  | 
seed | 
 Random seed for reproducibility.  | 
verbose | 
 Show progress?  | 
A data frame containing the complete tuning grid and the AUC values, with the best parameter combination and the highest AUC value.
sim_data <- msaenet::msaenet.sim.binomial(
  n = 100,
  p = 10,
  rho = 0.6,
  coef = rnorm(5, mean = 0, sd = 10),
  snr = 1,
  p.train = 0.8,
  seed = 42
)
params <- cv_xgboost(
  sim_data$x.tr,
  sim_data$y.tr,
  params = cv_param_grid(
    n_iterations = c(100, 200),
    max_depth = c(3, 5),
    learning_rate = c(0.1, 0.5)
  ),
  n_folds = 5,
  n_threads = 1,
  seed = 42,
  verbose = FALSE
)
params$df
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.