bibraeval.Aggregator

class bibraeval.Aggregator(comparator)

Bases: object

Aggregate a comparator’s field-level scores into precision/recall/F1.

Cell scores are computed at initialization. Add any custom strata columns to comparator.comparison_matrix before constructing the aggregator.

Parameters:

comparator (Comparator)

compute_intermediate_results(group_by)

Compute precision, recall and f1 per group.

For macro averaging group_by must contain exactly one of doc_id or field_name; other columns may be included as strata. When grouping by field_name, field weights are carried to the summary step; otherwise they are applied as weighted means within each group.

Set group_by=None for micro-averaging. For a stratified micro average, group only by the desired (additional) stratification columns. Value columns cannot be used as grouping keys.

Raises:

ValueError – If a grouping column is missing, a value column is requested, or both primary keys are included.

Parameters:

group_by (str | Sequence[str] | None)

Return type:

IntermediateResults

summarise_results(intermediate=None)

Summarize intermediate results while preserving strata.

Macro modes average the intermediate results; micro mode returns its pooled result without another aggregation. The long-form output has one row per metric and stratum, with metric, mode, value, and support columns in addition to any strata columns.

Raises:

ValueError – If no intermediate results are available and none are passed explicitly.

Parameters:

intermediate (IntermediateResults | None)

Return type:

DataFrame