Skip to content
Closed
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
18 changes: 15 additions & 3 deletions autoemulate/experimental/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,15 +276,27 @@ def compare(self):
n_splits=self.n_splits,
shuffle=self.shuffle,
)
mean_scores = [np.mean(score).item() for score in scores]
best_score_idx = np.argmax(mean_scores)

def mean_minus_one_stderr(score: list[float]) -> float:
"""Calculate the mean score and subtract one standard
error to increase robustness of hyperparameter choice.
"""
mean = np.mean(score).item()
stddev = np.std(score, ddof=1).item()
stderr = stddev / np.sqrt(len(score))
return mean - stderr

summary_scores = [
mean_minus_one_stderr(score) for score in scores
]
best_score_idx = np.argmax(summary_scores)
best_config_for_this_model = configs[best_score_idx]
self.logger.debug(
'Tuner found best config for model "%s": '
"%s with score: %.3f",
model_cls.__name__,
best_config_for_this_model,
mean_scores[best_score_idx],
summary_scores[best_score_idx],
)

self.logger.debug(
Expand Down