From 38bc250710aa6e1f3b7479e8614df6d37851078b Mon Sep 17 00:00:00 2001 From: Peter Hirsch Date: Wed, 8 Jun 2022 12:45:23 -0400 Subject: [PATCH] eval: add func to get score for set of parameters --- linajea/evaluation/__init__.py | 4 +++- linajea/evaluation/analyze_results.py | 26 +++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/linajea/evaluation/__init__.py b/linajea/evaluation/__init__.py index 4abbd4c..38feda2 100644 --- a/linajea/evaluation/__init__.py +++ b/linajea/evaluation/__init__.py @@ -3,11 +3,13 @@ from .match import match_edges from .match_nodes import match_nodes from .evaluate_setup import evaluate_setup +from .evaluator import Evaluator from .report import Report from .validation_metric import validation_score from .analyze_results import ( get_result, get_results, get_best_result, - get_results_sorted, get_best_result_with_config, get_result_id, get_results_sorted_db, + get_results_sorted, get_best_result_with_config, + get_result_id, get_result_params, get_results_sorted_db, get_best_result_per_setup, get_tgmm_results, get_best_tgmm_result, diff --git a/linajea/evaluation/analyze_results.py b/linajea/evaluation/analyze_results.py index 09ad0cf..f43c425 100644 --- a/linajea/evaluation/analyze_results.py +++ b/linajea/evaluation/analyze_results.py @@ -278,14 +278,34 @@ def get_result_id( config, parameters_id): ''' Get the scores, statistics, and parameters for given - setup, region, and parameters. + config and parameters_id. Returns a dictionary containing the keys and values of the score object. - - tracking_parameters can be a dict or a TrackingParameters object''' + ''' db_name = config.inference.data_source.db_name candidate_db = CandidateDatabase(db_name, config.general.db_host, 'r') result = candidate_db.get_score(parameters_id, eval_params=config.evaluate.parameters) return result + + +def get_result_params( + config, + parameters): + ''' Get the scores and statistics for a given config and set of + parameters. + Returns a dictionary containing the keys and values of the score + object. + ''' + db_name = config.inference.data_source.db_name + candidate_db = CandidateDatabase(db_name, config.general.db_host, 'r') + if config.evaluate.parameters.roi is None: + config.evaluate.parameters.roi = config.inference.data_source.roi + + result = candidate_db.get_score( + candidate_db.get_parameters_id_round( + parameters, + fail_if_not_exists=True), + eval_params=config.evaluate.parameters) + return result