Skip to content

registry

agentic_ml.metrics.registry

A small registry of named metrics with their optimization direction.

Metric dataclass

Metric(
    name: str,
    fn: Callable[[object, object], float],
    greater_is_better: bool,
)

A named metric.

greater_is_better drives best-trial selection: True means higher is better.

get_metric

get_metric(name: str) -> Metric

Return the :class:Metric registered under name.

Source code in src/agentic_ml/metrics/registry.py
35
36
37
38
39
40
41
42
def get_metric(name: str) -> Metric:
    """Return the :class:`Metric` registered under ``name``."""
    try:
        return _REGISTRY[name]
    except KeyError:
        raise KeyError(
            f"unknown metric '{name}'. Available: {', '.join(sorted(_REGISTRY))}"
        ) from None

list_metrics

list_metrics() -> list[str]

Return the names of all registered metrics.

Source code in src/agentic_ml/metrics/registry.py
45
46
47
def list_metrics() -> list[str]:
    """Return the names of all registered metrics."""
    return sorted(_REGISTRY)