Documentation
Classes
IterativeImputer

IterativeImputer

Multivariate imputer that estimates each feature from all the others.

A strategy for imputing missing values by modeling each feature with missing values as a function of other features in a round-robin fashion.

Read more in the User Guide.

Python Reference (opens in a new tab)

Constructors

constructor()

Signature

new IterativeImputer(opts?: object): IterativeImputer;

Parameters

NameTypeDescription
opts?object-
opts.add_indicator?booleanIf true, a MissingIndicator transform will stack onto output of the imputer’s transform. This allows a predictive estimator to account for missingness despite imputation. If a feature has no missing values at fit/train time, the feature won’t appear on the missing indicator even if there are missing values at transform/test time. Default Value false
opts.estimator?anyThe estimator to use at each step of the round-robin imputation. If sample\_posterior=True, the estimator must support return\_std in its predict method.
opts.imputation_order?"random" | "ascending" | "descending" | "roman" | "arabic"The order in which the features will be imputed. Possible values: Default Value 'ascending'
opts.initial_strategy?"most_frequent" | "constant" | "mean" | "median"Which strategy to use to initialize the missing values. Same as the strategy parameter in SimpleImputer. Default Value 'mean'
opts.keep_empty_features?booleanIf true, features that consist exclusively of missing values when fit is called are returned in results when transform is called. The imputed value is always 0 except when initial\_strategy="constant" in which case fill\_value will be used instead. Default Value false
opts.max_iter?numberMaximum number of imputation rounds to perform before returning the imputations computed during the final round. A round is a single imputation of each feature with missing values. The stopping criterion is met once max(abs(X\_t \- X\_{t-1}))/max(abs(X\[known\_vals\])) < tol, where X\_t is X at iteration t. Note that early stopping is only applied if sample\_posterior=False. Default Value 10
opts.max_value?number | ArrayLikeMaximum possible imputed value. Broadcast to shape (n\_features,) if scalar. If array-like, expects shape (n\_features,), one max value for each feature. The default is np.inf.
opts.min_value?number | ArrayLikeMinimum possible imputed value. Broadcast to shape (n\_features,) if scalar. If array-like, expects shape (n\_features,), one min value for each feature. The default is \-np.inf.
opts.missing_values?numberThe placeholder for the missing values. All occurrences of missing\_values will be imputed. For pandas’ dataframes with nullable integer dtypes with missing values, missing\_values should be set to np.nan, since pd.NA will be converted to np.nan.
opts.n_nearest_features?numberNumber of other features to use to estimate the missing values of each feature column. Nearness between features is measured using the absolute correlation coefficient between each feature pair (after initial imputation). To ensure coverage of features throughout the imputation process, the neighbor features are not necessarily nearest, but are drawn with probability proportional to correlation for each imputed target feature. Can provide significant speed-up when the number of features is huge. If undefined, all features will be used.
opts.random_state?numberThe seed of the pseudo random number generator to use. Randomizes selection of estimator features if n\_nearest\_features is not undefined, the imputation\_order if random, and the sampling from posterior if sample\_posterior=True. Use an integer for determinism. See the Glossary.
opts.sample_posterior?booleanWhether to sample from the (Gaussian) predictive posterior of the fitted estimator for each imputation. Estimator must support return\_std in its predict method if set to true. Set to true if using IterativeImputer for multiple imputations. Default Value false
opts.skip_complete?booleanIf true then features with missing values during transform which did not have any missing values during fit will be imputed with the initial imputation method only. Set to true if you have many features with no missing values at both fit and transform time to save compute. Default Value false
opts.tol?numberTolerance of the stopping condition. Default Value 0.001
opts.verbose?numberVerbosity flag, controls the debug messages that are issued as functions are evaluated. The higher, the more verbose. Can be 0, 1, or 2. Default Value 0

Returns

IterativeImputer

Defined in: generated/impute/IterativeImputer.ts:25 (opens in a new tab)

Properties

_isDisposed

boolean = false

Defined in: generated/impute/IterativeImputer.ts:23 (opens in a new tab)

_isInitialized

boolean = false

Defined in: generated/impute/IterativeImputer.ts:22 (opens in a new tab)

_py

PythonBridge

Defined in: generated/impute/IterativeImputer.ts:21 (opens in a new tab)

id

string

Defined in: generated/impute/IterativeImputer.ts:18 (opens in a new tab)

opts

any

Defined in: generated/impute/IterativeImputer.ts:19 (opens in a new tab)

Accessors

feature_names_in_

Names of features seen during fit. Defined only when X has feature names that are all strings.

Signature

feature_names_in_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/impute/IterativeImputer.ts:526 (opens in a new tab)

imputation_sequence_

Each tuple has (feat\_idx, neighbor\_feat\_idx, estimator), where feat\_idx is the current feature to be imputed, neighbor\_feat\_idx is the array of other features used to impute the current feature, and estimator is the trained estimator used for the imputation. Length is self.n\_features\_with\_missing\_ \* self.n\_iter\_.

Signature

imputation_sequence_(): Promise<any>;

Returns

Promise<any>

Defined in: generated/impute/IterativeImputer.ts:445 (opens in a new tab)

indicator_

Indicator used to add binary indicators for missing values. undefined if add\_indicator=False.

Signature

indicator_(): Promise<any>;

Returns

Promise<any>

Defined in: generated/impute/IterativeImputer.ts:580 (opens in a new tab)

initial_imputer_

Imputer used to initialize the missing values.

Signature

initial_imputer_(): Promise<any>;

Returns

Promise<any>

Defined in: generated/impute/IterativeImputer.ts:418 (opens in a new tab)

n_features_in_

Number of features seen during fit.

Signature

n_features_in_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/impute/IterativeImputer.ts:499 (opens in a new tab)

n_features_with_missing_

Number of features with missing values.

Signature

n_features_with_missing_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/impute/IterativeImputer.ts:553 (opens in a new tab)

n_iter_

Number of iteration rounds that occurred. Will be less than self.max\_iter if early stopping criterion was reached.

Signature

n_iter_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/impute/IterativeImputer.ts:472 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/impute/IterativeImputer.ts:128 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/impute/IterativeImputer.ts:132 (opens in a new tab)

random_state_

RandomState instance that is generated either from a seed, the random number generator or by np.random.

Signature

random_state_(): Promise<any>;

Returns

Promise<any>

Defined in: generated/impute/IterativeImputer.ts:607 (opens in a new tab)

Methods

dispose()

Disposes of the underlying Python resources.

Once dispose() is called, the instance is no longer usable.

Signature

dispose(): Promise<void>;

Returns

Promise<void>

Defined in: generated/impute/IterativeImputer.ts:207 (opens in a new tab)

fit()

Fit the imputer on X and return self.

Signature

fit(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeInput data, where n\_samples is the number of samples and n\_features is the number of features.
opts.y?anyNot used, present for API consistency by convention.

Returns

Promise<any>

Defined in: generated/impute/IterativeImputer.ts:224 (opens in a new tab)

fit_transform()

Fit the imputer on X and return the transformed X.

Signature

fit_transform(opts: object): Promise<ArrayLike>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeInput data, where n\_samples is the number of samples and n\_features is the number of features.
opts.y?anyNot used, present for API consistency by convention.

Returns

Promise<ArrayLike>

Defined in: generated/impute/IterativeImputer.ts:264 (opens in a new tab)

get_feature_names_out()

Get output feature names for transformation.

Signature

get_feature_names_out(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.input_features?anyInput features.

Returns

Promise<any>

Defined in: generated/impute/IterativeImputer.ts:306 (opens in a new tab)

init()

Initializes the underlying Python resources.

This instance is not usable until the Promise returned by init() resolves.

Signature

init(py: PythonBridge): Promise<void>;

Parameters

NameType
pyPythonBridge

Returns

Promise<void>

Defined in: generated/impute/IterativeImputer.ts:141 (opens in a new tab)

set_output()

Set output container.

See Introducing the set_output API for an example on how to use the API.

Signature

set_output(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.transform?"default" | "pandas"Configure output of transform and fit\_transform.

Returns

Promise<any>

Defined in: generated/impute/IterativeImputer.ts:346 (opens in a new tab)

transform()

Impute all missing values in X.

Note that this is stochastic, and that if random\_state is not fixed, repeated calls, or permuted input, results will differ.

Signature

transform(opts: object): Promise<ArrayLike>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]The input data to complete.

Returns

Promise<ArrayLike>

Defined in: generated/impute/IterativeImputer.ts:383 (opens in a new tab)