| """Public evaluation entry points for the MacroLens unified API. |
| |
| Thin wrappers over :func:`whatif_bench.eval.score` and |
| :func:`whatif_bench.eval.compare_methods`. The eval layer owns all |
| metric computation, bootstrap-CI logic, and multiple-comparisons |
| correction; this module exists only so that |
| ``import macrolens as ml; ml.score(...)`` has a stable, lightweight |
| surface. |
| """ |
|
|
| from __future__ import annotations |
|
|
| from typing import Any, Literal |
|
|
| from ..eval import compare_methods as _compare_methods |
| from ..eval import score as _score |
| from ._types import MetricValue |
|
|
|
|
| def score( |
| task: str, |
| y_true: Any, |
| y_pred: Any, |
| *, |
| cluster_keys: Any = None, |
| close_last: Any = None, |
| resample: Literal["cluster", "iid"] = "cluster", |
| n_boot: int | Literal["adaptive"] = "adaptive", |
| alpha: float = 0.05, |
| seed: int = 42, |
| return_sensitivity: bool = False, |
| ) -> dict[str, MetricValue]: |
| """Score a ``(task, y_true, y_pred)`` triple. Defaults to cluster bootstrap.""" |
| return _score( |
| task, y_true, y_pred, |
| cluster_keys=cluster_keys, |
| close_last=close_last, |
| resample=resample, |
| n_boot=n_boot, |
| alpha=alpha, |
| seed=seed, |
| return_sensitivity=return_sensitivity, |
| ) |
|
|
|
|
| def compare_methods( |
| task: str, |
| records: list, |
| *, |
| correction: Literal["holm", "bh"] = "holm", |
| alpha: float = 0.05, |
| headline_metric: str | None = None, |
| ): |
| """Pairwise compare every method on ``task`` against the best baseline.""" |
| return _compare_methods( |
| task, records, |
| correction=correction, |
| alpha=alpha, |
| headline_metric=headline_metric, |
| ) |
|
|
|
|
| __all__ = ["score", "compare_methods"] |
|
|