UNPKG

@arizeai/phoenix-evals

Version:
25 lines 1.07 kB
import { getAverageMetricNameSuffix } from "./classificationMetrics.js"; import { createClassificationMetricEvaluator } from "./createClassificationMetricEvaluator.js"; /** * Creates a code evaluator that computes precision: of the labels the model * predicted as a given class, the fraction that were actually that class. * * 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 precision = createPrecisionEvaluator(); * const result = await precision.evaluate({ * expected: ["cat", "dog", "cat", "bird"], * output: ["cat", "cat", "cat", "bird"], * }); * // { score: 5/9 } * ``` */ export function createPrecisionEvaluator(options = {}) { const suffix = getAverageMetricNameSuffix(options); return createClassificationMetricEvaluator(`precision${suffix}`, "precision", options); } //# sourceMappingURL=createPrecisionEvaluator.js.map