import { RegressorBase } from '../base'; import { Params } from '../base/estimator'; export type IsotonicOutOfBounds = 'clip' | 'nan' | 'raise'; export interface IsotonicRegressionProps { /** Lower bound on the fitted values (sklearn `y_min`). */ yMin?: number; /** Upper bound on the fitted values (sklearn `y_max`). */ yMax?: number; /** * Whether the fitted function is non-decreasing (`true`, default), * non-increasing (`false`) or inferred from the sign of the Spearman rank * correlation between x and y (`'auto'`, sklearn `check_increasing`). */ increasing?: boolean | 'auto'; /** * How `predict`/`transform` handle inputs outside the training range: * 'clip' (default) evaluates at the nearest boundary, 'nan' returns NaN, * 'raise' throws. */ outOfBounds?: IsotonicOutOfBounds; } /** * Pool-adjacent-violators algorithm producing the weighted least-squares * non-decreasing fit. Direct port of scikit-learn's * `_inplace_contiguous_isotonic_regression` (Best & Chakravarti 1990 active * set, O(n)). */ export declare function pavaNonDecreasing(y: number[], w: number[]): number[]; /** * Isotonic (monotonic) regression, mirroring `sklearn.isotonic.IsotonicRegression`. * * Fits a free-form, non-decreasing (or non-increasing) step-linear function to * 1-D data by weighted pool-adjacent-violators (PAVA), then predicts by linear * interpolation between the fitted thresholds. * * Input shape: the estimator is inherently 1-D, so `fit`, `predict` and * `transform` accept either a plain `number[]` or a single-column * `number[][]` matrix (so it composes with matrix-based meta-estimators). * * Matches sklearn: * - ties in x are lexicographically sorted by (x, y) and merged into a single * point whose y is the sample-weight-weighted mean (sklearn `_make_unique`); * - `increasing='auto'` picks the direction from the sign of the Spearman * rank correlation (sklearn `check_increasing`, `rho >= 0` → increasing); * - `yMin`/`yMax` clip the fitted values after PAVA; * - `outOfBounds` = 'clip' | 'nan' | 'raise' as in sklearn. * * Omitted vs sklearn: the redundant-threshold trimming sklearn applies before * building its interpolator (`_build_y` keeps only points where the fit * changes slope). We keep every unique-x point; the interpolated predictions * are identical. The `increasing='auto'` confidence-interval warning is also * omitted. */ export declare class IsotonicRegression extends RegressorBase { private yMin?; private yMax?; private increasing; private outOfBounds; /** Unique ascending x thresholds of the fitted function. */ private xThresholds; /** Fitted values aligned with `xThresholds`. */ private yThresholds; /** Direction actually used at fit time (resolves 'auto'). */ increasingFitted: boolean | null; private fitted; constructor(props?: IsotonicRegressionProps); getParams(): Params; fit(X: number[][] | number[], y: number[], sampleWeight?: number[]): void; /** Piecewise-linear interpolation over the fitted thresholds. */ private interpolate; predict(X: number[][] | number[]): number[]; /** Alias of `predict` (sklearn exposes both). */ transform(X: number[][] | number[]): number[]; }