Performs random search over XGBoost hyperparameters using match-grouped cross-validation folds. Returns the best parameter set found.
Usage
tune_xgb_params(
dtrain,
folds,
fixed_params = list(objective = "multi:softprob", num_class = 7, eval_metric =
"mlogloss"),
n_iter = 20,
max_rounds = 2000,
early_stopping = 20,
seed = 42,
param_grid = NULL,
verbose = TRUE
)Arguments
- dtrain
xgb.DMatrix. Training data
- folds
List of integer vectors. Grouped CV fold indices (e.g., from match-grouped splitting)
- fixed_params
List. Fixed XGBoost parameters (objective, eval_metric, num_class)
- n_iter
Integer. Number of random parameter combinations to try (default 20)
- max_rounds
Integer. Maximum boosting rounds per trial (default 2000)
- early_stopping
Integer. Early stopping patience (default 20)
- seed
Integer. Random seed for reproducibility
- param_grid
Named list. Parameter search spaces. Each element is a list with 'min' and 'max' for continuous params or a vector for discrete. Defaults to a sensible grid for tree-based models.
- verbose
Logical. Print progress (default TRUE)
