Evaluation¶
Evaluation defines the metric contract for a run and the optional subgroup breakdowns that appear in the saved outputs and reports.
The main configuration object is soma.config.EvalConfig.
- class soma.config.EvalConfig(metrics=<factory>, subgroups=<factory>, save_segmentation_overlays=True, save_segmentation_probabilities=False, save_detection_overlays=True, save_detection_heatmaps=False, holdout_test=False, overwrite_test=False)¶
Bases:
objectEvaluation metrics and subgroup analysis configuration.
Metrics are validated against the selected task family, and subgroup columns are used to break down the reported metrics in the run outputs. The dense-artifact toggles form a symmetric 2×2 over the segmentation and detection paths — cheap visual overlays default on (but suppressible, for a metrics-only run), heavy raw outputs default off:
save_segmentation_overlayswrites the pred/GT color overlays;save_segmentation_probabilitiesadditionally writes a per-tile float16(C, H, W)softmax sidecar underprobs/— opt-in because it is ~C×/precision× larger than the always-written argmax raster, and unlocks post-hoc soft-Dice/calibration/entropy/ensembling without re-running inference;save_detection_overlayswrites the detection point overlays;save_detection_heatmapswrites the colormap overlays and the npz sidecar.holdout_testskips all test-split work (no test inference, nopredictions_test.csv, notestentries inmetrics.json/summary.json) and reports tune only — the model-selection protocol for benchmark sweeps: rank every candidate by tune score, then re-run only the winner with the test held out in. The test split may still be declared insplits.csv; it is simply not touched. Tune evaluation, threshold sweeps, checkpoint selection, and training are unaffected.overwrite_testgoverns the test-results clobber guard (issue #247): because experiment identity is test-invariant, one checkpoint may be scored against several test sets over its life. Each test set’s result is namespaced by its test identity; re-scoring an already-scored test set is refused by default (a loud skip that leaves the prior result intact) unlessoverwrite_testis set. It is an operational flag, not part of the experiment identity.
- class soma.config.SubgroupConfig(columns=<factory>)¶
Bases:
objectColumns used for subgroup metric breakdowns.
Metric families¶
The default metrics depend on the task family:
Task family |
Default metrics |
Notes |
|---|---|---|
|
|
Standard binary classification reporting |
|
|
Multi-class classification |
|
|
Ordered labels |
|
|
Continuous targets |
|
|
Dense per-pixel prediction |
|
|
Class-aware F1 at matching distance δ ( |
Use the smallest set of metrics that answers the scientific question, and keep it fixed when comparing runs.
Subgroup metrics¶
Subgroup columns are read from dataset.csv and used to break down metrics
for each distinct value in the selected columns.
evaluation:
metrics: [auroc, balanced_accuracy]
subgroups:
columns: [center, grade]
The run outputs write subgroup tables to subgroup_metrics_<split>.json and
the HTML report includes the same breakdowns. The detailed statistical tests
used for subgroup comparisons are described in Reporting.
Evaluation results¶
The per-split evaluation output is represented by
soma.evaluation.report.EvaluationReport.
- class soma.evaluation.report.EvaluationReport(split, metrics, predictions)¶
Bases:
objectEvaluation results for a single split.
- split¶
Split name (e.g. ‘test’, ‘tune’).
- metrics¶
Metric name -> value.
- predictions¶
Per-sample prediction records.
- class soma.evaluation.report.SamplePrediction(sample_id, true_label, predicted_label=None, probabilities=None, predicted_value=None, raw_score=None, risk_score=None, event=None, is_placeholder=False, missing_reason=None)¶
Bases:
objectPer-sample prediction record for audit trail.
For survival predictions,
true_labelholds the time-to-event,eventthe 0/1 indicator, andrisk_scorethe predicted risk (higher = earlier predicted event).