import { FoldIndices, ScoringFunction, SearchEstimator, SplitterLike } from './modelSelection'; import { trainTestSplit } from './sampling'; export { trainTestSplit }; export type { TrainTestSplitOptions, TrainTestSplitResult } from './sampling'; export interface ShuffleSplitProps { nSplits?: number; /** Fraction in (0, 1) or absolute count. Defaults to 0.1 when trainSize is unset. */ testSize?: number; /** Fraction in (0, 1) or absolute count. Defaults to the complement of testSize. */ trainSize?: number; randomState?: number; } /** Random permutation cross-validator (sklearn `ShuffleSplit`). */ export declare class ShuffleSplit implements SplitterLike { private nSplits; private testSize?; private trainSize?; private randomState?; constructor(props?: ShuffleSplitProps); split(X: any[], y?: any[]): FoldIndices[]; } /** * Stratified random permutation cross-validator (sklearn * `StratifiedShuffleSplit`): each split preserves per-class proportions. * Per-class counts use deterministic largest-remainder rounding (sklearn * randomizes the rounding of remainders), so proportions match sklearn but * exact index draws do not. */ export declare class StratifiedShuffleSplit implements SplitterLike { private nSplits; private testSize?; private trainSize?; private randomState?; constructor(props?: ShuffleSplitProps); split(X: any[], y?: any[]): FoldIndices[]; } export interface GroupKFoldProps { nSplits?: number; } /** * K-fold with non-overlapping groups (sklearn `GroupKFold`): the same group * never appears in both train and test, and fold sizes are balanced by * greedily assigning the largest groups to the least-filled fold. */ export declare class GroupKFold implements SplitterLike { private nSplits; constructor(props?: GroupKFoldProps); split(X: any[], y?: any[], groups?: any[]): FoldIndices[]; } export interface GroupShuffleSplitProps extends ShuffleSplitProps { } /** Random train/test partitions over unique groups rather than samples. */ export declare class GroupShuffleSplit implements SplitterLike { private nSplits; private testSize?; private trainSize?; private randomState?; constructor(props?: GroupShuffleSplitProps); split(X: any[], y?: any[], groups?: any[]): FoldIndices[]; } export interface StratifiedGroupKFoldProps extends GroupKFoldProps { shuffle?: boolean; randomState?: number; } /** Greedy class-balanced K-fold splitting with groups kept intact. */ export declare class StratifiedGroupKFold implements SplitterLike { private nSplits; private shuffle; private randomState?; constructor(props?: StratifiedGroupKFoldProps); split(X: any[], y?: any[], groups?: any[]): FoldIndices[]; } export interface TimeSeriesSplitProps { nSplits?: number; maxTrainSize?: number; testSize?: number; gap?: number; } /** * Forward-chaining time-series cross-validator (sklearn `TimeSeriesSplit`): * successive training sets are supersets of earlier ones and always precede * the test set. No shuffling. */ export declare class TimeSeriesSplit implements SplitterLike { private nSplits; private maxTrainSize?; private testSize?; private gap; constructor(props?: TimeSeriesSplitProps); split(X: any[], y?: any[]): FoldIndices[]; } export interface RepeatedKFoldProps { nSplits?: number; nRepeats?: number; randomState?: number; } /** Repeats shuffled KFold `nRepeats` times with fresh randomization each repeat. */ export declare class RepeatedKFold implements SplitterLike { private nSplits; private nRepeats; private randomState?; constructor(props?: RepeatedKFoldProps); split(X: any[], y?: any[]): FoldIndices[]; } /** Repeats shuffled StratifiedKFold `nRepeats` times with fresh randomization each repeat. */ export declare class RepeatedStratifiedKFold implements SplitterLike { private nSplits; private nRepeats; private randomState?; constructor(props?: RepeatedKFoldProps); split(X: any[], y?: any[]): FoldIndices[]; } /** Each sample is used once as a single-element test set (sklearn `LeaveOneOut`). */ export declare class LeaveOneOut implements SplitterLike { split(X: any[], y?: any[]): FoldIndices[]; } /** * Multi-metric scoring spec: a built-in name, a scoring function, a list of * built-in names, or a record mapping result keys to names/functions. */ export type MultiScoring = string | ScoringFunction | string[] | Record; export interface CrossValidateOptions { cv?: number | SplitterLike; scoring?: MultiScoring; returnTrainScore?: boolean; /** Passed through to group-aware splitters (e.g. GroupKFold). */ groups?: any[]; } export interface CrossValidateResult { /** Per-metric test scores, one entry per fold. */ testScore: Record; /** Present only when `returnTrainScore` is true. */ trainScore?: Record; /** Wall-clock fit time per fold in milliseconds. */ fitTimeMs: number[]; } /** * Cross-validate a contract estimator (cloned per fold), evaluating one or * more metrics on each fold and timing each fit. */ export declare function crossValidate(estimator: SearchEstimator, X: number[][], y: number[], options?: CrossValidateOptions): CrossValidateResult; export interface LearningCurveOptions { /** Fractions in (0, 1] of the max training size, or absolute counts (> 1). */ trainSizes?: number[]; cv?: number | SplitterLike; scoring?: string | ScoringFunction; /** Shuffle each CV training fold before taking incremental subsets. */ shuffle?: boolean; randomState?: number; } export interface LearningCurveResult { /** Ascending unique absolute training sizes (rows of the score matrices). */ trainSizesAbs: number[]; /** trainScores[sizeIndex][foldIndex] */ trainScores: number[][]; /** testScores[sizeIndex][foldIndex] */ testScores: number[][]; } /** * sklearn `learning_curve`: for each CV fold, fit the estimator on growing * prefixes of the SAME (optionally shuffled) training fold and score both the * training subset and the fold's test set. */ export declare function learningCurve(estimator: SearchEstimator, X: number[][], y: number[], options?: LearningCurveOptions): LearningCurveResult; export interface ValidationCurveOptions { /** Parameter to sweep; supports pipeline-style `step__param` addressing. */ paramName: string; paramRange: any[]; cv?: number | SplitterLike; scoring?: string | ScoringFunction; } export interface ValidationCurveResult { /** trainScores[paramIndex][foldIndex] */ trainScores: number[][]; /** testScores[paramIndex][foldIndex] */ testScores: number[][]; } /** * sklearn `validation_curve`: train/test scores across a sweep of one * hyperparameter, applied per fold via `clone().setParams(...)`. */ export declare function validationCurve(estimator: SearchEstimator, X: number[][], y: number[], options: ValidationCurveOptions): ValidationCurveResult;