export interface WilsonInterval { lower: number; upper: number; } export interface ClassificationLabelMetrics { label: string; truePositives: number; falsePositives: number; falseNegatives: number; support: number; predicted: number; precision: number; precisionInterval: WilsonInterval | null; recall: number; recallInterval: WilsonInterval | null; f1: number; } export interface ClassificationConfusionMatrix { /** Actual labels, in the same order as the matrix rows. */ labels: string[]; /** Predicted labels, in the same order as the matrix columns; null is abstention. */ predictedLabels: Array; counts: number[][]; } export interface ClassificationScore { perLabel: ClassificationLabelMetrics[]; macroF1: number; confusionMatrix: ClassificationConfusionMatrix; /** Null when there are no examples. */ abstainRate: number | null; } export interface ScoreClassificationInput { gold: readonly string[]; predicted: readonly (string | null)[]; labels: readonly string[]; } export interface ThresholdPoint { threshold: number; truePositives: number; predictedPositive: number; goldPositive: number; precision: number | null; recall: number | null; } export interface ThresholdSweepResult { points: ThresholdPoint[]; /** Null when targetRecall is omitted or no threshold has defined sufficient recall. */ largestThresholdMeetingTargetRecall: number | null; } export interface ThresholdSweepInput { gold: readonly boolean[]; probabilities: readonly number[]; thresholds?: readonly number[]; targetRecall?: number; } /** * Scores single-label classification results. A null prediction is an abstention * and contributes a false negative to its gold label, but no false positive. * Undefined precision/recall intervals are null; zero-division point metrics * use zero so macro-F1 remains defined for labels with no observations. */ export declare function scoreClassification({ gold, predicted, labels, }: ScoreClassificationInput): ClassificationScore; /** * Evaluates binary positive-class probabilities at each threshold. A score is * predicted positive when it is greater than or equal to the threshold, so ties * at the threshold are included. */ export declare function thresholdSweep({ gold, probabilities, thresholds, targetRecall, }: ThresholdSweepInput): ThresholdSweepResult; /** Computes binary expected calibration error using equal-width probability bins. */ export declare function expectedCalibrationError({ gold, probabilities, bins, }: { gold: readonly boolean[]; probabilities: readonly number[]; bins?: number; }): number | null;