This function wraps xgb.train to standardize model
training within the traineR framework. It automatically handles preprocessing,
parameter configuration, multiclass settings, and metadata generation for predictions.
train.xgboost(
formula,
data,
nrounds,
evals = list(),
custom_metric = NULL,
verbose = 1,
print_every_n = 1L,
early_stopping_rounds = NULL,
maximize = NULL,
save_period = NULL,
save_name = "xgboost.model",
xgb_model = NULL,
callbacks = list(),
eval_metric = NULL,
extra_params = NULL,
booster = "gbtree",
objective = NULL,
eta = 0.3,
gamma = 0,
max_depth = 6,
min_child_weight = 1,
subsample = 1,
colsample_bytree = 1,
...
)An object of class xgb.Booster.prmdt containing:
The trained xgboost model.
Metadata used by traineR for prediction output.
A model formula describing the response and predictors.
A data frame containing the training data. Internally, it is converted to
an xgb.DMatrix.
Maximum number of boosting iterations.
A named list of xgb.DMatrix objects for evaluation during training.
Defaults to training data if empty.
A custom evaluation function for xgboost.
Controls verbosity: 0 = silent, 1 = progress printed.
Print evaluation results every print_every_n iterations.
Number of rounds with no improvement before stopping.
Logical indicating if the evaluation metric should be maximized.
Save the model every save_period rounds. Defaults to saving at the end.
File name for saving the model.
A previously trained xgboost model for continuation.
A list of callback functions for xgboost during training.
Evaluation metric for xgboost (e.g., "mlogloss", "rmse").
Optional list of additional xgboost parameters.
Booster type: "gbtree" or "gblinear". Default is "gbtree".
Objective function for xgboost. If NULL, it's chosen automatically:
Regression → "reg:squarederror"
Binary classification → "binary:logistic"
Multiclass → "multi:softprob"
Learning rate. Default is 0.3.
Minimum loss reduction for a split. Default is 0.
Maximum depth of trees. Default is 6.
Minimum sum of instance weight in a child.
Subsample ratio for training instances. Default is 1.
Subsample ratio of columns per tree. Default is 1.
Additional arguments for xgb.train.
xgb.train, xgb.DMatrix