import { ClassifierBase } from '../base'; import { BaseEstimator, Params } from '../base/estimator'; export type CalibrationMethod = 'sigmoid' | 'isotonic'; /** * Any contract classifier exposing a continuous score: * `predictProba` (preferred) or `decisionFunction`. */ export interface CalibratableClassifier extends BaseEstimator { fit(X: number[][], y: number[], sampleWeight?: number[]): void; predict(X: number[][]): number[]; predictProba?(X: number[][]): number[][]; decisionFunction?(X: number[][]): number[] | number[][]; } export interface CalibratedClassifierCVProps { /** The base classifier to calibrate. It is cloned, never mutated. */ estimator: CalibratableClassifier; /** 'sigmoid' (Platt scaling, default) or 'isotonic'. */ method?: CalibrationMethod; /** Number of StratifiedKFold folds (default 5). */ cv?: number; /** * `true` (default, sklearn's default): keep one (classifier, calibrators) * pair per fold and average their calibrated probabilities at inference. * `false`: pool the out-of-fold scores, fit a single calibrator set on * them, and refit the base classifier on the full data (sklearn's * `ensemble=False`). */ ensemble?: boolean; } /** * Platt scaling: probability = 1 / (1 + exp(a * score + b)) with (a, b) * fitted by minimizing the cross-entropy against Bayesian-prior-smoothed * targets t+ = (n+ + 1)/(n+ + 2), t- = 1/(n- + 2) (Platt 1999), using the * Newton method with backtracking line search from Lin, Lin & Weng (2007) — * the same algorithm as sklearn's `_sigmoid_calibration` / LIBSVM's * `sigmoid_train`. */ export declare class SigmoidCalibration { a: number; b: number; fit(scores: number[], targets: number[], sampleWeight?: number[]): void; predict(scores: number[]): number[]; } /** * Probability calibration with out-of-fold cross-validation, mirroring * `sklearn.calibration.CalibratedClassifierCV`. * * `fit` splits (X, y) with `StratifiedKFold(cv)` (no shuffle, deterministic); * per fold, a clone of the base classifier is fitted on the train part and * scored on the held-out part. Scores are the `predictProba` output when the * base classifier provides it (positive-class column for binary problems), * else `decisionFunction`. Calibrators are fitted one-vs-rest — one per class, * or a single one for binary problems. * * With `ensemble=true` (the default, matching sklearn) each fold keeps its own * (classifier, calibrators) pair and `predictProba` averages the calibrated * probabilities of all folds. With `ensemble=false` the out-of-fold scores are * pooled into a single calibrator set and the base classifier is refit on the * full data (sklearn's pooled variant). * * `predictProba` returns per-class calibrated scores normalized to sum to 1 * (binary problems return [1 - p, p] directly); `predict` is the argmax. * * Omitted vs sklearn: `cv='prefit'` / `FrozenEstimator` support, arbitrary * splitter objects for `cv` (only an integer fold count is accepted), and * fold-classifiers trained on a subset of the classes (StratifiedKFold * guarantees every class appears in every training part, and errors out when * a class has fewer than `cv` samples). */ export declare class CalibratedClassifierCV extends ClassifierBase { private estimator; private method; private cv; private ensemble; private classes; private calibratedPairs; private fitted; constructor(props: CalibratedClassifierCVProps); getParams(): Params; /** * Continuous per-class scores for the OvR calibrators, shape * [nSamples][nClasses] (or [nSamples][1] for binary problems). */ private rawScores; private fitCalibrators; fit(X: number[][], y: number[], sampleWeight?: number[]): void; predictProba(X: number[][]): number[][]; predict(X: number[][]): number[]; }