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.
Relevant Source Files
src/code/index.tssrc/code/classificationMetrics.ts
Example
Built-In Evaluator Factories
createPrecisionEvaluator(options?)—scoreis precisioncreateRecallEvaluator(options?)—scoreis recallcreateF1Evaluator(options?)—scoreis F1 (F-beta withbeta: 1)createFBetaEvaluator(options?)—scoreis F-beta; setbetato weight recall (beta > 1) or precision (beta < 1) more heavilycreatePrecisionRecallFScoreEvaluators(options?)— returns{ precision, recall, fScore }: three separate evaluators built from one shared options object
{ 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: 2when missing a true positive is costlier than a false alarm)
examples/classification_metrics_example.ts.
Source Map
src/code/index.tssrc/code/classificationMetrics.tssrc/code/createClassificationMetricEvaluator.tssrc/code/createPrecisionEvaluator.tssrc/code/createRecallEvaluator.tssrc/code/createFBetaEvaluator.tssrc/code/createF1Evaluator.tssrc/code/createPrecisionRecallFScoreEvaluators.ts

