8000 add standard deviation Stopper for Gaussian process by RuifMaxx · Pull Request #1170 · scikit-optimize/scikit-optimize · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Feb 28, 2024. It is now read-only.

add standard deviation Stopper for Gaussian process #1170

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions skopt/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,29 @@ def _criterion(self, result):
return None


class StdStopper(EarlyStopper):
"""
Stop the optimization when the standard deviation of the Gaussian
process is lower than the threshold.
Paper: automatic-termination-for-hyperparameter-optimization
"""
def __init__(self, threshold: float, log_interval=10) -> None:
super(EarlyStopper, self).__init__()
self.threshold = threshold
self.log_interval = log_interval

def _criterion(self, result) -> bool:
y_train_std_ = []
for model in result.models:
y_train_std_.append(model.y_train_std_)
if len(y_train_std_) == 0:
return False
if len(y_train_std_) % self.log_interval == 0:
print("num_models:", len(y_train_std_), "min_std:",
min(y_train_std_), "max_std:", max(y_train_std_))
return min(y_train_std_) <= self.threshold


class ThresholdStopper(EarlyStopper):
"""
Stop the optimization when the objective value is lower
Expand Down
0