Skip to content

Commit

Permalink
Merge branch 'optuna:master' into python3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
not522 authored Oct 23, 2023
2 parents a41db6b + 14770e5 commit 1490869
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 10 deletions.
61 changes: 61 additions & 0 deletions docs/source/reference/integration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,64 @@ XGBoost
:nosignatures:

optuna.integration.XGBoostPruningCallback

Dependencies of each integration
--------------------------------

We summarize the necessary dependencies for each integration.

+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| Integration | Dependencies |
+===================================================================================================================================================================================+====================================+
| `AllenNLP <https://github.com/optuna/optuna/tree/master/optuna/integration/allennlp>`_ | allennlp, torch, psutil, jsonnet |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| `BoTorch <https://github.com/optuna/optuna/blob/master/optuna/integration/botorch.py>`_ | botorch, gpytorch, torch |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| `Catalyst <https://github.com/optuna/optuna/blob/master/optuna/integration/catalyst.py>`_ | catalyst |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| `CatBoost <https://github.com/optuna/optuna/blob/master/optuna/integration/catboost.py>`_ | catboost |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| `ChainerMN <https://github.com/optuna/optuna/blob/master/optuna/integration/chainermn.py>`_ | chainermn |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| `Chainer <https://github.com/optuna/optuna/blob/master/optuna/integration/chainer.py>`_ | chainer |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| `pycma <https://github.com/optuna/optuna/blob/master/optuna/integration/cma.py>`_ | cma |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| `Dask <https://github.com/optuna/optuna/blob/master/optuna/integration/dask.py>`_ | distributed |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| FastAI (`v1 <https://github.com/optuna/optuna/blob/master/optuna/integration/fastaiv1.py>`_, `v2 <https://github.com/optuna/optuna/blob/master/optuna/integration/fastaiv2.py>`_) | fastai |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| `Keras <https://github.com/optuna/optuna/blob/master/optuna/integration/keras.py>`_ | keras |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| `LightGBMTuner <https://github.com/optuna/optuna/blob/master/optuna/integration/lightgbm.py>`_ | lightgbm, scikit-learn |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| `LightGBMPruningCallback <https://github.com/optuna/optuna/blob/master/optuna/integration/lightgbm.py>`_ | lightgbm |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| `MLflow <https://github.com/optuna/optuna/blob/master/optuna/integration/mlflow.py>`_ | mlflow |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| `MXNet <https://github.com/optuna/optuna/blob/master/optuna/integration/mxnet.py>`_ | mxnet |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| PyTorch `Distributed <https://github.com/optuna/optuna/blob/master/optuna/integration/pytorch_distributed.py>`_ | torch |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| PyTorch (`Ignite <https://github.com/optuna/optuna/blob/master/optuna/integration/pytorch_ignite.py>`_) | pytorch-ignite |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| PyTorch (`Lightning <https://github.com/optuna/optuna/blob/master/optuna/integration/pytorch_lightning.py>`_) | pytorch-lightning |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| `SHAP <https://github.com/optuna/optuna/blob/master/optuna/integration/shap.py>`_ | scikit-learn, shap |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| `Scikit-learn <https://github.com/optuna/optuna/blob/master/optuna/integration/sklearn.py>`_ | pandas, scipy, scikit-learn |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| `Scikit-optimize <https://github.com/optuna/optuna/blob/master/optuna/integration/skopt.py>`_ | scikit-optimize |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| `SKorch <https://github.com/optuna/optuna/blob/master/optuna/integration/skorch.py>`_ | skorch |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| `TensorBoard <https://github.com/optuna/optuna/blob/master/optuna/integration/tensorboard.py>`_ | tensorboard, tensorflow |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| `TensorFlow <https://github.com/optuna/optuna/blob/master/optuna/integration/tensorflow.py>`_ | tensorflow, tensorflow-estimator |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| `TensorFlow + Keras <https://github.com/optuna/optuna/blob/master/optuna/integration/tfkeras.py>`_ | tensorflow |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| `Weights & Biases <https://github.com/optuna/optuna/blob/master/optuna/integration/wandb.py>`_ | wandb |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
| `XGBoost <https://github.com/optuna/optuna/blob/master/optuna/integration/xgboost.py>`_ | xgboost |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------+
3 changes: 2 additions & 1 deletion optuna/_typing.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Mapping
from typing import Sequence
from typing import Union
Expand All @@ -13,5 +15,4 @@
None,
]


__all__ = ["JSONSerializable"]
2 changes: 1 addition & 1 deletion optuna/integration/fastaiv1.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class FastAIV1PruningCallback(TrackerCallback):
Args:
learn:
`fastai.basic_train.Learner <https://docs.fast.ai/basic_train.html#Learner>`_.
`fastai.basic_train.Learner <https://fastai1.fast.ai/basic_train.html#Learner>`_.
trial:
A :class:`~optuna.trial.Trial` corresponding to the current
evaluation of the objective function.
Expand Down
10 changes: 5 additions & 5 deletions optuna/samplers/_brute_force.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ class _TreeNode:
# 3. Normal node. It has a param_name and non-empty children.

param_name: Optional[str] = None
children: Optional[Dict[Any, "_TreeNode"]] = None
children: Optional[Dict[float, "_TreeNode"]] = None

def expand(self, param_name: Optional[str], search_space: Iterable[Any]) -> None:
def expand(self, param_name: Optional[str], search_space: Iterable[float]) -> None:
# If the node is unexpanded, expand it.
# Otherwise, check if the node is compatible with the given search space.
if self.children is None:
Expand All @@ -54,7 +54,7 @@ def set_leaf(self) -> None:
self.expand(None, [])

def add_path(
self, params_and_search_spaces: Iterable[Tuple[str, Iterable[Any], Any]]
self, params_and_search_spaces: Iterable[Tuple[str, Iterable[float], float]]
) -> Optional["_TreeNode"]:
# Add a path (i.e. a list of suggested parameters in one trial) to the tree.
current_node = self
Expand All @@ -74,7 +74,7 @@ def count_unexpanded(self) -> int:
else sum(child.count_unexpanded() for child in self.children.values())
)

def sample_child(self, rng: np.random.RandomState) -> Any:
def sample_child(self, rng: np.random.RandomState) -> float:
assert self.children is not None
# Sample an unexpanded node in the subtree uniformly, and return the first
# parameter value in the path to the node.
Expand Down Expand Up @@ -240,7 +240,7 @@ def after_trial(
study.stop()


def _enumerate_candidates(param_distribution: BaseDistribution) -> Sequence[Any]:
def _enumerate_candidates(param_distribution: BaseDistribution) -> Sequence[float]:
if isinstance(param_distribution, FloatDistribution):
if param_distribution.step is None:
raise ValueError(
Expand Down
2 changes: 2 additions & 0 deletions optuna/terminator/callback.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Optional

from optuna._experimental import experimental_class
Expand Down
2 changes: 2 additions & 0 deletions optuna/terminator/terminator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import abc
from typing import Optional

Expand Down
4 changes: 2 additions & 2 deletions optuna/visualization/matplotlib/_edf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from typing import Callable
from typing import Sequence
from collections.abc import Callable
from collections.abc import Sequence

from optuna._experimental import experimental_func
from optuna.logging import get_logger
Expand Down
2 changes: 1 addition & 1 deletion optuna/visualization/matplotlib/_hypervolume_history.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import Sequence
from collections.abc import Sequence

import numpy as np

Expand Down

0 comments on commit 1490869

Please sign in to comment.