Skip to content

Commit

Permalink
feat: ⚡️ Incorporaten validation related changes from rhoadesj/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
rhoadesScholar committed Feb 8, 2024
1 parent 2a29afd commit 9a9e5f1
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions dacapo/experiments/tasks/evaluators/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,52 @@ def is_best(
else:
return getattr(score, criterion) < previous_best_score

def get_overall_best(self, dataset: "Dataset", criterion: str):
overall_best = None
if self.best_scores:
for _, parameter, _ in self.best_scores.keys():
score = self.best_scores[(dataset, parameter, criterion)]
if score is None:
overall_best = None
else:
_, current_parameter_score = score
if overall_best is None:
overall_best = current_parameter_score
else:
if current_parameter_score:
if self.higher_is_better(criterion):
if current_parameter_score > overall_best:
overall_best = current_parameter_score
else:
if current_parameter_score < overall_best:
overall_best = current_parameter_score
return overall_best

def get_overall_best_parameters(self, dataset: "Dataset", criterion: str):
overall_best = None
overall_best_parameters = None
if self.best_scores:
for _, parameter, _ in self.best_scores.keys():
score = self.best_scores[(dataset, parameter, criterion)]
if score is None:
overall_best = None
else:
_, current_parameter_score = score
if overall_best is None:
overall_best = current_parameter_score
overall_best_parameters = parameter
else:
if current_parameter_score:
if self.higher_is_better(criterion):
if current_parameter_score > overall_best:
overall_best = current_parameter_score
overall_best_parameters = parameter
else:
if current_parameter_score < overall_best:
overall_best = current_parameter_score
overall_best_parameters = parameter
return overall_best_parameters

def set_best(self, validation_scores: "ValidationScores") -> None:
"""
Find the best iteration for each dataset/post_processing_parameter/criterion
Expand Down

0 comments on commit 9a9e5f1

Please sign in to comment.