import { BaseEstimator, Params } from '../base/estimator'; export interface KFoldProps { nSplits?: number; shuffle?: boolean; randomState?: number; } export interface FoldIndices { trainIndices: number[]; testIndices: number[]; } export interface EstimatorLike { fit(trainX: number[][], trainY: number[]): void; predict(testX: number[][]): number[]; score?: (X: number[][], Y: number[]) => number; } /** sklearn-style classifier detection, including Pipeline final estimators. */ export declare function isClassifierLike(estimator: unknown): boolean; export interface CrossValScoreOptions { cv?: number | SplitterLike; scoring?: (actual: number[], expected: number[]) => number; } export interface SplitterLike { /** * `groups` is only consumed by group-aware splitters (e.g. `GroupKFold`); * all other splitters ignore it. */ split(X: any[], y?: any[], groups?: any[]): FoldIndices[]; } export interface SearchEstimatorFactory { (params: Record): EstimatorLike; } export type ScoringFunction = (actual: number[], expected: number[]) => number; /** A contract-following estimator usable as a search prototype. */ export type SearchEstimator = BaseEstimator & EstimatorLike; /** * Built-in scoring functions addressable by name in the `scoring` param so * that search meta-estimators remain serializable. All are * higher-is-better (losses are negated). */ export declare const SCORING_FUNCS: Record; export declare function resolveScoring(scoring: ScoringFunction | string | undefined): ScoringFunction | undefined; export interface GridSearchCVProps { /** * Prototype estimator; each candidate is `estimator.clone().setParams(p)`. * Serializable (the estimator is stored as a registered class instance). * Exactly one of `estimator` / `estimatorFactory` must be provided. */ estimator?: SearchEstimator; /** Factory building an estimator from params. NOT serializable. */ estimatorFactory?: SearchEstimatorFactory; paramGrid: Record; cv?: number | SplitterLike; /** * Either a scoring function or the string name of a built-in * (e.g. 'accuracyScore'). Only string names are serializable. */ scoring?: ScoringFunction | string; refit?: boolean; } export interface RandomizedSearchCVProps { /** See GridSearchCVProps.estimator. */ estimator?: SearchEstimator; /** See GridSearchCVProps.estimatorFactory. */ estimatorFactory?: SearchEstimatorFactory; paramDistributions: Record; nIter: number; cv?: number | SplitterLike; scoring?: ScoringFunction | string; randomState?: number; refit?: boolean; } export declare class KFold { private nSplits; private shuffle; private randomState?; constructor(props?: KFoldProps); split(X: any[], y?: any[]): FoldIndices[]; } export declare class StratifiedKFold implements SplitterLike { private nSplits; private shuffle; private randomState?; constructor(props?: KFoldProps); split(X: any[], y?: any[]): FoldIndices[]; } export declare class GridSearchCV extends BaseEstimator { private estimator?; private estimatorFactory?; private paramGrid; private cv?; private scoring?; private refit; bestParams: Record | null; bestScore: number; bestEstimator: EstimatorLike | null; constructor(props: GridSearchCVProps); getParams(): Params; private buildEstimator; fit(X: number[][], y: number[]): void; predict(X: number[][]): number[]; score(X: number[][], y: number[]): number; } export declare class RandomizedSearchCV extends BaseEstimator { private estimator?; private estimatorFactory?; private paramDistributions; private nIter; private cv?; private scoring?; private randomState?; private refit; bestParams: Record | null; bestScore: number; bestEstimator: EstimatorLike | null; constructor(props: RandomizedSearchCVProps); getParams(): Params; private buildEstimator; fit(X: number[][], y: number[]): void; predict(X: number[][]): number[]; score(X: number[][], y: number[]): number; } export declare function crossValScore(estimatorFactory: () => EstimatorLike, X: number[][], y: number[], options?: CrossValScoreOptions): number[]; /** Out-of-fold predictions, restored to the original sample order. */ export declare function crossValPredict(estimatorFactory: () => EstimatorLike, X: number[][], y: number[], options?: { cv?: number | SplitterLike; groups?: unknown[]; }): number[]; export * from './modelSelectionExtra';