rhscope.bench.result

Benchmark result container.

BenchResult carries everything a reader needs to interpret a run: pooled and per-category AUROC, threshold-dependent accuracy, calibration metrics, and provenance (detector name, n_examples, split, dataset version). Rendered as a markdown table via summary() or as JSON via to_dict().

class rhscope.bench.result.BenchResult(detector_name, split, n_examples, pooled_auroc, accuracy, threshold, tpr, fpr, ece, brier, per_category_auroc=<factory>, per_category_count=<factory>, dataset_name='', dataset_version='', extra=<factory>)[source]

Bases: object

Result of evaluating a detector on a benchmark split.

Variables:
  • detector_name (str) – Identifier used in the summary table.

  • split (str) – Split name ("train" / "val" / "test").

  • n_examples (int) – Number of examples scored.

  • pooled_auroc (float) – AUROC computed over all categories combined.

  • accuracy (float) – Accuracy at the Youden-J-optimal threshold.

  • threshold (float) – The optimal threshold itself.

  • tpr (float) – True-positive rate at that threshold.

  • fpr (float) – False-positive rate at that threshold.

  • ece (float) – Expected calibration error (after sigmoid transform).

  • brier (float) – Brier score (after sigmoid transform).

  • per_category_auroc (dict[str, float]) – Mapping category -> AUROC over that subset. Empty when the benchmark has no category labels.

  • per_category_count (dict[str, int]) – Mapping category -> example count in this split.

  • dataset_name (str) – Human-readable dataset identifier.

  • dataset_version (str) – Version / hash tag for reproducibility.

  • extra (dict[str, Any]) – Free-form provenance fields preserved across serialization.

Parameters:
detector_name: str
split: str
n_examples: int
pooled_auroc: float
accuracy: float
threshold: float
tpr: float
fpr: float
ece: float
brier: float
per_category_auroc: dict[str, float]
per_category_count: dict[str, int]
dataset_name: str = ''
dataset_version: str = ''
extra: dict[str, Any]
summary()[source]

Return a markdown-formatted summary of this result.

Return type:

str

to_dict()[source]

Return a JSON-serializable dict representation.

Return type:

dict[str, Any]

to_json(*, indent=2)[source]

Return a JSON string of to_dict().

Parameters:

indent (int | None)

Return type:

str

save_json(path, *, indent=2)[source]

Persist to_dict() to disk.

Parameters:
Return type:

Path

classmethod from_dict(data)[source]

Reconstruct a BenchResult from to_dict() output.

Parameters:

data (dict[str, Any])

Return type:

BenchResult