File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 22Changelog
33#########
44
5+ Version 3.1.1 (2025-02-07)
6+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
7+
8+ - fix: should_prune() takes no argument
9+ - fix: make `Optimizer.best_loss`` return infinity with no trial
10+
11+
512Version 3.1.0 (2025-01-12)
613~~~~~~~~~~~~~~~~~~~~~~~~~~
714
Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ class Optimizer:
7676 Seed value for the random number generator of the sampler.
7777 Defaults to no seed.
7878 average_case : `bool`, optional
79- Optimize for average case (default).
79+ Optimize for average case (default).
8080 Set to False to optimize for worst case.
8181 """
8282
@@ -148,7 +148,12 @@ def __init__(
148148 @property
149149 def best_loss (self ) -> float :
150150 """Return best loss so far"""
151- return self .study_ .best_value
151+ try :
152+ best_value = self .study_ .best_value
153+ except Exception :
154+ direction : int = 1 if self .pipeline .get_direction () == "minimize" else - 1
155+ best_value = direction * np .inf
156+ return best_value
152157
153158 @property
154159 def best_params (self ) -> dict :
@@ -255,8 +260,8 @@ def objective(trial: Trial) -> float:
255260 continue
256261
257262 trial .report (np .mean (losses ) if metric is None else abs (metric ), i )
258- if trial .should_prune (i ):
259- raise optuna .structs . TrialPruned ()
263+ if trial .should_prune ():
264+ raise optuna .TrialPruned ()
260265
261266 if show_progress != False :
262267 progress_bar .close ()
You can’t perform that action at this time.
0 commit comments