| xgb.cb.early.stop | R Documentation |
This callback function determines the condition for early stopping.
The following attributes are assigned to the booster's object:
best_score the evaluation score at the best iteration
best_iteration at which boosting iteration the best score has occurred
(0-based index for interoperability of binary models)
The same values are also stored as R attributes as a result of the callback, plus an additional
attribute stopped_by_max_rounds which indicates whether an early stopping by the stopping_rounds
condition occurred. Note that the best_iteration that is stored under R attributes will follow
base-1 indexing, so it will be larger by '1' than the C-level 'best_iteration' that is accessed
through xgb.attr() or xgb.attributes().
At least one dataset is required in evals for early stopping to work.
xgb.cb.early.stop(
stopping_rounds,
maximize = FALSE,
metric_name = NULL,
verbose = TRUE,
save_best = FALSE
)
stopping_rounds |
The number of rounds with no improvement in the evaluation metric in order to stop the training. |
maximize |
Whether to maximize the evaluation metric. |
metric_name |
The name of an evaluation column to use as a criteria for early
stopping. If not set, the last column would be used.
Let's say the test data in |
verbose |
Whether to print the early stopping information. |
save_best |
Whether training should return the best model or the last model. If
set to |
An xgb.Callback object, which can be passed to xgb.train() or xgb.cv().
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.