-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathevaluation_factory.py
More file actions
37 lines (30 loc) · 1.2 KB
/
evaluation_factory.py
File metadata and controls
37 lines (30 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from data_layer.data_object import DataObject
from evaluation_layer.evaluation_object import EvaluationObject
from typing import Dict, Any, List, Optional
_EVAL_REGISTRY = {}
def register_evaluation(name: str):
"""Decorator to register an evaluation metric class by name."""
def decorator(cls):
_EVAL_REGISTRY[name] = cls
return cls
return decorator
def create_evaluations(metrics_config: List[Dict[str, Any]],
data: DataObject) -> List[EvaluationObject]:
"""
Instantiate all requested evaluation modules from the experiment config.
Args:
metrics_config: List of dicts, each with "name" and optional "hyperparameters".
data: The DataObject instance.
Returns:
List of EvaluationObject instances.
"""
evaluations = []
for metric in metrics_config:
name = metric["name"]
hyperparams = metric.get("hyperparameters", None)
if name not in _EVAL_REGISTRY:
raise ValueError(
f"Evaluation '{name}' is not registered. Available: {list(_EVAL_REGISTRY.keys())}"
)
evaluations.append(_EVAL_REGISTRY[name](data, hyperparams))
return evaluations