Skip to main content

The code entrypoint provides deterministic, non-LLM evaluators for classification metrics: precision, recall, and F-beta (including F1). Unlike the per-row LLM evaluators elsewhere in this package, these are dataset-level — expected and output are the full sequence of labels across every example you want to score together, not a single row’s label.

Example#

Built-In Evaluator Factories#

  • createPrecisionEvaluator(options?) — score is precision
  • createRecallEvaluator(options?) — score is recall
  • createF1Evaluator(options?) — score is F1 (F-beta with beta: 1)
  • createFBetaEvaluator(options?) — score is F-beta; set beta to weight recall (beta > 1) or precision (beta < 1) more heavily
  • createPrecisionRecallFScoreEvaluators(options?) — returns { precision, recall, fScore }: three separate evaluators built from one shared options object

Each evaluator resolves to a single { score }. (Python’s PrecisionRecallFScore returns all three scores from one call; in TypeScript each evaluator yields one score, so use the bundle above to get all three.) Each factory accepts the same options:

Binary Classification#

Multi-Class Averaging#

When To Use#

  • Scoring classification or labeling tasks (routing, tagging, moderation categories) against ground-truth labels
  • Comparing predicted vs. expected label sequences collected from an experiment or dataset
  • Choosing an F-beta weighting that matches the cost of false positives vs. false negatives for your task (e.g. beta: 2 when missing a true positive is costlier than a false alarm)

For the underlying formulas, the precision/recall tradeoff, averaging-strategy semantics, and citations, see the Precision / Recall / F-Score guide. A runnable walkthrough covering binary classification, F-beta tradeoffs, and all three averaging strategies lives in the package’s examples/classification_metrics_example.ts.