@arizeai/phoenix-evals
Version:
A library for running evaluations for AI use cases
27 lines • 1.2 kB
JavaScript
import { formatBetaForMetricName, getAverageMetricNameSuffix, } from "./classificationMetrics.js";
import { createClassificationMetricEvaluator } from "./createClassificationMetricEvaluator.js";
/**
* Creates a code evaluator that computes the F-beta score: the weighted
* harmonic mean of precision and recall, where `beta` controls how much more
* weight recall gets relative to precision (`beta = 1` is the standard F1
* score).
*
* Supports binary classification (via `positiveLabel`, or auto-detected when
* `average` is at its default `"macro"` and labels are the numeric set
* `{0, 1}`) and multi-class classification (via the `average` strategy).
*
* @example
* ```typescript
* const f2 = createFBetaEvaluator({ beta: 2 });
* const result = await f2.evaluate({
* expected: ["cat", "dog", "cat", "bird"],
* output: ["cat", "cat", "cat", "bird"],
* });
* ```
*/
export function createFBetaEvaluator(options = {}) {
const { beta = 1 } = options;
const suffix = getAverageMetricNameSuffix(options);
return createClassificationMetricEvaluator(`${formatBetaForMetricName(beta)}${suffix}`, "fScore", options);
}
//# sourceMappingURL=createFBetaEvaluator.js.map