import { ClassifierBase } from '../base'; import { BaseEstimator, Params } from '../base/estimator'; import { ClassifierLike } from './common'; export interface OneVsRestClassifierProps { /** Prototype classifier; one unfitted clone is fitted per class. */ estimator: BaseEstimator; } /** * One-vs-rest (one-vs-all) multiclass strategy, mirroring sklearn's * `OneVsRestClassifier`. * * For each of the K classes, a clone of `estimator` is fitted on a binary * problem where samples of that class are relabeled 1 and every other sample * 0. This turns any binary-only classifier into a multiclass classifier. * * Prediction picks the class whose member produces the highest score * (first class wins ties). The per-member score is, in order of preference: * `predictProba`'s positive-class column, `decisionFunction`, or the raw * 0/1 `predict` output (vote). * * Deviations from sklearn (documented): * - sklearn fits a single estimator when y is binary (LabelBinarizer emits * one column); this implementation always fits one member per class. * - `predictProba` rows whose positive-class probabilities sum to 0 fall * back to a uniform distribution instead of producing NaN. * * Nested params are addressable as `estimator__` in `setParams`. */ export declare class OneVsRestClassifier extends ClassifierBase { private estimator; private classes_; private estimators_; constructor(props: OneVsRestClassifierProps); 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-class members, ordered like `classes`. */ get estimators(): ClassifierLike[]; fit(X: number[][], y: number[], sampleWeight?: number[]): void; private ensureFitted; /** Per-class score matrix [nSamples][nClasses] used by predict. */ private memberScores; predict(X: number[][]): number[]; /** * Positive-class probability of each member, normalized so every row * sums to 1 (sklearn behavior). Requires the members to implement * `predictProba`. */ predictProba(X: number[][]): number[][]; /** * Per-class decision values, shape [nSamples][nClasses]. Requires the * members to implement `decisionFunction`. */ decisionFunction(X: number[][]): number[][]; }