@kanaries/ml
API Reference/Imputation

IterativeImputer

Estimate each missing numeric feature from the others using the @kanaries/ml JavaScript IterativeImputer implementation in browser or Node.js.

View as Markdown

Algorithm overview

Iterative imputation begins with a column statistic, then repeatedly predicts each feature from the other features. It is useful when missing columns are correlated and a single mean or median would erase that relationship.

JavaScript implementation

@kanaries/ml clones and fits a registered regressor for every imputation step, records the fitted sequence for later transform, and supports deterministic ordering and bounds. Until BayesianRidge is added, the default base estimator is lightly regularized RidgeRegression; supply another registered regressor when needed.

Quick start example

import { Impute } from '@kanaries/ml';

const imputer = new Impute.IterativeImputer({ maxIter: 10, tol: 1e-3 });
const complete = imputer.fitTransform([[0, 1], [1, 3], [2, NaN], [3, 7]]);
const future = imputer.transform([[4, NaN]]);
console.log({ complete, future });

Detailed API reference

Options: estimator, maxIter, tol, initialStrategy: 'mean' | 'median' | 'mostFrequent' | 'constant', fillValue, imputationOrder: 'ascending' | 'descending' | 'roman' | 'arabic' | 'random', skipComplete, minValue, maxValue, and randomState.

Methods: fit, fitTransform, and transform. Learned imputationSequence and nIter are exposed. Missing values must be represented by NaN.