fastrag.benchmark.comparison#
The Comparison: any number of runs, side by side.
Classes
|
Any number of |
- class fastrag.benchmark.comparison.Comparison(results)[source]#
Bases:
objectAny number of
BenchmarkResult, compared.from fastrag.benchmark import Comparison comparison = Comparison.load("results/*.json") # or Comparison.of([r1, r2, r3]) print(comparison.to_markdown()) print(comparison.best("ndcg@5"))
- Parameters:
results (list[BenchmarkResult])
- results: list[BenchmarkResult]#
- classmethod of(results)[source]#
Build a comparison from results already in memory.
- Parameters:
results (Iterable[BenchmarkResult])
- Return type:
- classmethod load(pattern)[source]#
Load every result file matching a glob
pattern, sorted by path.- Raises:
ConfigurationError –
patternmatched no files — an empty comparison is the silent-wrong-answer shape, so this raises rather than returning one.- Parameters:
- Return type:
- to_markdown(stat='mean')[source]#
Render one row per run, one column per metric,
statof each.statis anyDistributionSummaryfield ("mean","p95", …); an unknown one raisesConfigurationErrorrather than printing zeros. A run with no such metric prints—. Whenstatis not"mean"every header carries it, e.g.latency_ms p95.
- best(metric, stat='mean')[source]#
The result whose
metricis best, per that metric’s own direction.- Raises:
ConfigurationError – no result carries
metric.- Parameters:
- Return type:
- save(path)[source]#
Write
to_markdown()’s default (mean) table topath.