Skip to content

Commit

Permalink
modify note
Browse files Browse the repository at this point in the history
  • Loading branch information
tohmae committed Feb 6, 2022
1 parent 904d2e5 commit 897b201
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Examples can be found in [optuna/optuna-examples](https://github.com/optuna/optu

* [AllenNLP](https://github.com/optuna/optuna-examples/tree/main/allennlp)
* [Catalyst](https://github.com/optuna/optuna-examples/tree/main/pytorch/catalyst_simple.py)
* [Catboost](https://github.com/optuna/optuna-examples/blob/main/catboost/catboost_pruning.py)
* [Catboost](https://github.com/optuna/optuna-examples/tree/main/catboost/catboost_pruning.py)
* [Chainer](https://github.com/optuna/optuna-examples/tree/main/chainer/chainer_integration.py)
* FastAI ([V1](https://github.com/optuna/optuna-examples/tree/main/fastai/fastaiv1_simple.py), [V2](https://github.com/optuna/optuna-examples/tree/main/fastai/fastaiv2_simple.py))
* [Keras](https://github.com/optuna/optuna-examples/tree/main/keras/keras_integration.py)
Expand Down
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This page contains a list of example codes written with Optuna. The example file
* [AllenNLP](https://github.com/optuna/optuna-examples/blob/main/allennlp/allennlp_simple.py)
* [AllenNLP (Jsonnet)](https://github.com/optuna/optuna-examples/blob/main/allennlp/allennlp_jsonnet.py)
* [Catalyst](https://github.com/optuna/optuna-examples/blob/main/pytorch/catalyst_simple.py)
* [CatBoost](https://github.com/optuna/optuna-examples/blob/main/catboost/catboost_simple.py)
* [CatBoost](https://github.com/optuna/optuna-examples/blob/main/catboost/catboost_pruning.py)
* [Chainer](https://github.com/optuna/optuna-examples/blob/main/chainer/chainer_simple.py)
* [ChainerMN](https://github.com/optuna/optuna-examples/blob/main/chainer/chainermn_simple.py)
* [Dask-ML](https://github.com/optuna/optuna-examples/blob/main/dask_ml/dask_ml_simple.py)
Expand Down
16 changes: 11 additions & 5 deletions optuna/integration/catboost.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from typing import Any
from typing import Optional

from packaging import version

import optuna
from optuna._experimental import experimental
from optuna._imports import try_import


Expand All @@ -13,6 +15,7 @@
raise ImportError(f"You don't have CatBoost>=0.26! CatBoost version: {cb.__version__}")


@experimental("3.0.0")
class CatBoostPruningCallback(object):
"""Callback for catboost to prune unpromising trials.
Expand All @@ -21,11 +24,12 @@ class CatBoostPruningCallback(object):
if you want to add a pruning callback which observes validation accuracy of
a CatBoost model.
If :class:`optuna.TrialPruned` is raised in ``after_iteration`` via
``CatBoostPruningCallback``, then catboost terminates abnormally.
.. note::
You must call ``check_pruned`` after training manually unlike other pruning callbacks
:class:`optuna.TrialPruned` cannot be raised
in :meth:`~optuna.integration.CatBoostPruningCallback.after_iteration`
that is called in CatBoost via ``CatBoostPruningCallback``.
You must call :meth:`~optuna.integration.CatBoostPruningCallback.check_pruned`
after training manually unlike other pruning callbacks
to raise :class:`optuna.TrialPruned`.
Args:
Expand All @@ -45,7 +49,9 @@ class CatBoostPruningCallback(object):
``eval_set_index``, e.g., ``0`` or ``1`` when ``eval_set`` contains two datasets.
"""

def __init__(self, trial: optuna.trial.Trial, metric: str, eval_set_index: int = None) -> None:
def __init__(
self, trial: optuna.trial.Trial, metric: str, eval_set_index: Optional[int] = None
) -> None:
default_valid_name = "validation"
self._trial = trial
self._metric = metric
Expand Down

0 comments on commit 897b201

Please sign in to comment.