optuna.integration.CatBoostPruningCallback
- class optuna.integration.CatBoostPruningCallback(trial, metric, eval_set_index=None)[source]
Callback for catboost to prune unpromising trials.
See the example if you want to add a pruning callback which observes validation accuracy of a CatBoost model.
Note
optuna.TrialPrunedcannot be raised inafter_iteration()that is called in CatBoost viaCatBoostPruningCallback. You must callcheck_pruned()after training manually unlike other pruning callbacks to raiseoptuna.TrialPruned.Note
This callback cannot be used with CatBoost on GPUs because CatBoost doesn’t support a user-defined callback for GPU. Please refer to CatBoost issue.
- Parameters
trial (Trial) – A
Trialcorresponding to the current evaluation of the objective function.metric (str) – An evaluation metric for pruning, e.g.,
LoglossandAUC. Please refer to CatBoost reference for further details.eval_set_index (Optional[int]) – The index of the target validation dataset. If you set only one
eval_set,eval_set_indexis None. If you set multiple datasets aseval_set, the index ofeval_setmust beeval_set_index, e.g.,0or1wheneval_setcontains two datasets.
Note
Added in v3.0.0 as an experimental feature. The interface may change in newer versions without prior notice. See https://github.com/optuna/optuna/releases/tag/v3.0.0.
Methods
after_iteration(info)Report an evaluation metric value for Optuna pruning after each CatBoost's iteration.
Raise
optuna.TrialPrunedmanually if the CatBoost optimization is pruned.- after_iteration(info)[source]
Report an evaluation metric value for Optuna pruning after each CatBoost’s iteration.
This method is called by CatBoost.
- Parameters
info (Any) – A
SimpleNamespacecontaining iteraion,validation_name,metric_nameand history of losses. For exampleSimpleNamespace(iteration=2, metrics={ 'learn': {'Logloss': [0.6, 0.5]}, 'validation': {'Logloss': [0.7, 0.6], 'AUC': [0.8, 0.9]} }).- Returns
A boolean value. If
False, CatBoost internally stops the optimization with Optuna’s pruning logic without raisingoptuna.TrialPruned. Otherwise, the optimization continues.- Return type
- check_pruned()[source]
Raise
optuna.TrialPrunedmanually if the CatBoost optimization is pruned.- Return type
None