cb.early.stop
From xgboost v0.6-3
by Tong He
Callback closure to activate the early stopping.
Callback closure to activate the early stopping.
Usage
cb.early.stop(stopping_rounds, maximize = FALSE, metric_name = NULL, verbose = TRUE)
Arguments
- 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
watchlist
was labelled asdtest
, and one wants to use the AUC in test data for early stopping regardless of where it is in thewatchlist
, then one of the following would need to be set:metric_name='dtest-auc'
ormetric_name='dtest_auc'
. All dash '-' characters in metric names are considered equivalent to '_'. - verbose
- whether to print the early stopping information.
Details
This callback function determines the condition for early stopping
by setting the stop_condition = TRUE
flag in its calling frame.
The following additional fields are assigned to the model's R object:
-
best_score
the evaluation score at the best iteration -
best_iteration
at which boosting iteration the best score has occurred (1-based index) -
best_ntreelimit
to use with thentreelimit
parameter inpredict
. It differs frombest_iteration
in multiclass or random forest settings.
The Same values are also stored as xgb-attributes:
-
best_iteration
is stored as a 0-based iteration index (for interoperability of binary models) -
best_msg
message string is also stored.
At least one data element is required in the evaluation watchlist for early stopping to work.
Callback function expects the following values to be set in its calling frame:
stop_condition
,
bst_evaluation
,
rank
,
bst
(or bst_folds
and basket
),
iteration
,
begin_iteration
,
end_iteration
,
num_parallel_tree
.
See Also
Community examples
Looks like there are no examples yet.