Metric

A metric scores model predictions against ground truth. Metrics accumulate y_true and y_pred arrays across batches via update(), then reduce them in compute() to a single value (accuracy, MAE, TM-score, Spearman’s ρ, etc.).

MultiMetric combines several metrics into one evaluation pass. Result formats scores for console output, CSV, or LaTeX tables and tracks whether higher or lower values are better.

Benchmarks call update() during evaluation, which inverse-transforms predictions back to the original label space before updating the metric. See Metrics.

class bioverse.metric.Metric(property: str | None = None, name: str = 'Metric', reduction: str | None = 'mean', on: int = 1, per: int | None = None)[source]

Bases: ABC

Score model predictions against ground truth.

Metrics accumulate y_true and y_pred arrays across evaluation batches via update(), then compute a scalar in compute(). Benchmark calls update() during validation and test; result() returns a formatted Result.

Set better to "higher" or "lower" for leaderboard sorting. Use property to select which field of a structured target array to score.

Examples

from bioverse.metrics import MeanAbsoluteErrorMetric

metric = MeanAbsoluteErrorMetric(property="target")
metric.update(y_true, y_pred)
result = metric.result(model_name="MyModel")
result.to_console()
class bioverse.metric.MultiMetric(metrics=[])[source]

Bases: object

Combine multiple Metric instances into one evaluation pass.

Metrics are updated and reduced independently. Use + to build a MultiMetric from individual metrics.

Examples

from bioverse.metrics import MeanAbsoluteErrorMetric, PearsonsRMetric

metrics = MeanAbsoluteErrorMetric() + PearsonsRMetric()
metrics.update(y_true, y_pred)
metrics.result().to_console()
class bioverse.metric.Result(data=[], better={})[source]

Bases: object

Formatted collection of metric scores for display and export.

Results aggregate rows of {Model, Metric, Value} dictionaries and track whether higher or lower values are better per metric. Supports console, LaTeX, and dictionary export via to_console(), to_latex(), and to_dict().