/** * Voting meta-estimators, mirroring sklearn's `VotingClassifier` and * `VotingRegressor`. * * Both take a named `[name, estimator]` list (the Pipeline pattern) so that * members are addressable in `setParams` as `name__param`, e.g. * `votingClf.setParams({ lr__maxIter: 50 })`. */ import { ClassifierBase, RegressorBase } from '../base'; import { BaseEstimator, Params } from '../base/estimator'; /** Structural contract for a voting/stacking classifier member. */ export interface ClassifierLike extends BaseEstimator { fit(X: number[][], y: number[], sampleWeight?: number[]): void; predict(X: number[][]): number[]; /** Columns ordered by the member's sorted classes (base-class contract). */ predictProba?(X: number[][]): number[][]; decisionFunction?(X: number[][]): number[] | number[][]; } /** Structural contract for a voting/stacking regressor member. */ export interface RegressorLike extends BaseEstimator { fit(X: number[][], y: number[], sampleWeight?: number[]): void; predict(X: number[][]): number[]; } export type NamedEstimator = [name: string, estimator: T]; /** Validate a named-estimator list (Pipeline-style rules). */ export declare function validateNamedEstimators(estimators: NamedEstimator[], owner: string): void; /** Split a params object into own keys and nested `name__param` groups. */ export declare function splitNestedParams(params: Params): { own: Params; nested: Map; }; export declare function validateVotingWeights(weights: number[] | undefined, nEstimators: number): void; export declare function sortedUniqueLabels(y: number[]): number[]; /** * Index of the maximum value; on an exact tie the FIRST (lowest-index) * maximum wins — the same rule as numpy's `argmax`, which is what sklearn's * voting uses. Since classes are stored in ascending sorted order, ties * therefore resolve to the smallest class label. */ export declare function argmaxFirst(values: number[]): number; export interface VotingClassifierProps { /** Named members; addressable as `name__param` in setParams. */ estimators: NamedEstimator[]; /** 'hard': weighted majority of labels; 'soft': argmax of weighted-average predictProba. */ voting?: 'hard' | 'soft'; /** Per-estimator weights (default: uniform). */ weights?: number[]; } /** * Soft/hard voting ensemble following sklearn's `VotingClassifier`. * * Tie-breaking rule (both modes): the class with the highest weighted * vote/probability wins; on an exact tie the smallest class label (first in * ascending sorted class order) is returned, matching sklearn/np.argmax. */ export declare class VotingClassifier extends ClassifierBase { private estimators; private voting; private weights?; private classes; private fitted; constructor(props: VotingClassifierProps); getParams(): Params; /** Supports both own params and nested `name__param` addressing. */ setParams(params: Params): this; getEstimator(name: string): BaseEstimator; get namedEstimators(): Record; getClasses(): number[]; fit(X: number[][], y: number[], sampleWeight?: number[]): void; predict(X: number[][]): number[]; /** Weighted-average class probabilities. Only available with voting='soft'. */ predictProba(X: number[][]): number[][]; private averagedProba; } export interface VotingRegressorProps { /** Named members; addressable as `name__param` in setParams. */ estimators: NamedEstimator[]; /** Per-estimator weights (default: uniform). */ weights?: number[]; } /** Weighted-mean prediction ensemble following sklearn's `VotingRegressor`. */ export declare class VotingRegressor extends RegressorBase { private estimators; private weights?; private fitted; constructor(props: VotingRegressorProps); getParams(): Params; /** Supports both own params and nested `name__param` addressing. */ setParams(params: Params): this; getEstimator(name: string): BaseEstimator; get namedEstimators(): Record; fit(X: number[][], y: number[], sampleWeight?: number[]): void; predict(X: number[][]): number[]; }