import { ClassifierBase } from '../base'; import { BaseEstimator, Params } from '../base/estimator'; import { ClassifierLike } from './common'; export interface OneVsOneClassifierProps { /** Prototype classifier; one unfitted clone is fitted per class pair. */ estimator: BaseEstimator; } /** * TypeScript port of sklearn's `_ovr_decision_function`: fold per-pair binary * predictions and confidences into a per-class decision matrix of * * votes + sumOfConfidences / (3 * (|sumOfConfidences| + 1)) * * `predictions[k][s]` is member k's 0/1 prediction for sample s and * `confidences[k][s]` its signed confidence (positive favors the pair's * second class). Pair k corresponds to the class-index pair (i, j) in the * order `for i in [0, K): for j in (i, K)`. * * The monotone transform maps each confidence sum into (-1/3, 1/3), so the * confidence term can only break ties between equal vote counts — it can * never overturn a vote. */ export declare function ovrDecisionFunction(predictions: number[][], confidences: number[][], nClasses: number): number[][]; /** * One-vs-one multiclass strategy, mirroring sklearn's `OneVsOneClassifier`. * * For every unordered class pair (cI, cJ) with cI < cJ, a clone of * `estimator` is fitted on just that pair's samples, relabeled 0 (cI) and 1 * (cJ). Members are stored in sklearn's pair order * `for i in [0, K): for j in (i, K)`. * * Prediction counts pairwise votes and, like sklearn, adds the per-class sum * of signed member confidences squashed into (-1/3, 1/3) (see * `ovrDecisionFunction`), so confidences break vote ties but never overturn * a vote. Member confidence is `decisionFunction` when available, else * `predictProba`'s positive-class column. * * Deviations from sklearn (documented): * - when the members expose neither `decisionFunction` nor `predictProba`, * sklearn raises; here the confidences are all 0, so vote ties fall back * to the first (lowest-index) tied class. * * Nested params are addressable as `estimator__` in `setParams`. */ export declare class OneVsOneClassifier extends ClassifierBase { private estimator; private classes_; private estimators_; constructor(props: OneVsOneClassifierProps); getParams(): Params; /** Supports own params plus nested `estimator__param` addressing. */ setParams(params: Params): this; /** Sorted class labels seen during fit. */ get classes(): number[]; /** The fitted per-pair members, in sklearn's (i, j) pair order. */ get estimators(): ClassifierLike[]; fit(X: number[][], y: number[], sampleWeight?: number[]): void; private ensureFitted; /** votes + squashed-confidence matrix, shape [nSamples][nClasses]. */ private decisionMatrix; predict(X: number[][]): number[]; /** * The vote + squashed-confidence matrix [nSamples][nClasses]; for binary * problems the positive-class column is returned as a flat array * (sklearn behavior). */ decisionFunction(X: number[][]): number[] | number[][]; }