UNPKG

@arizeai/phoenix-evals

Version:
28 lines 1.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createPrecisionEvaluator = createPrecisionEvaluator; const classificationMetrics_1 = require("./classificationMetrics"); const createClassificationMetricEvaluator_1 = require("./createClassificationMetricEvaluator"); /** * 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 } * ``` */ function createPrecisionEvaluator(options = {}) { const suffix = (0, classificationMetrics_1.getAverageMetricNameSuffix)(options); return (0, createClassificationMetricEvaluator_1.createClassificationMetricEvaluator)(`precision${suffix}`, "precision", options); } //# sourceMappingURL=createPrecisionEvaluator.js.map