DocumentationClassesIterativeImputer

Class: 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

Constructors

new IterativeImputer()

new IterativeImputer(opts?): IterativeImputer

Parameters

ParameterTypeDescription
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.
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.fill_value?stringWhen strategy="constant", fill_value is used to replace all occurrences of missing_values. For string or object data types, fill_value must be a string. If undefined, fill_value will be 0 when imputing numerical data and “missing_value” for strings or object data types.
opts.imputation_order?"random" | "ascending" | "descending" | "roman" | "arabic"The order in which the features will be imputed. Possible values:
opts.initial_strategy?"most_frequent" | "constant" | "mean" | "median"Which strategy to use to initialize the missing values. Same as the strategy parameter in SimpleImputer.
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.
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.
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.
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.
opts.tol?numberTolerance of the stopping condition.
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.

Returns IterativeImputer

Defined in generated/impute/IterativeImputer.ts:25

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/impute/IterativeImputer.ts:23
_isInitializedbooleanfalsegenerated/impute/IterativeImputer.ts:22
_pyPythonBridgeundefinedgenerated/impute/IterativeImputer.ts:21
idstringundefinedgenerated/impute/IterativeImputer.ts:18
optsanyundefinedgenerated/impute/IterativeImputer.ts:19

Accessors

feature_names_in_

Get Signature

get feature_names_in_(): Promise<ArrayLike>

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

Returns Promise<ArrayLike>

Defined in generated/impute/IterativeImputer.ts:548


imputation_sequence_

Get Signature

get imputation_sequence_(): Promise<any>

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_.

Returns Promise<any>

Defined in generated/impute/IterativeImputer.ts:467


indicator_

Get Signature

get indicator_(): Promise<any>

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

Returns Promise<any>

Defined in generated/impute/IterativeImputer.ts:602


initial_imputer_

Get Signature

get initial_imputer_(): Promise<any>

Imputer used to initialize the missing values.

Returns Promise<any>

Defined in generated/impute/IterativeImputer.ts:440


n_features_in_

Get Signature

get n_features_in_(): Promise<number>

Number of features seen during fit.

Returns Promise<number>

Defined in generated/impute/IterativeImputer.ts:521


n_features_with_missing_

Get Signature

get n_features_with_missing_(): Promise<number>

Number of features with missing values.

Returns Promise<number>

Defined in generated/impute/IterativeImputer.ts:575


n_iter_

Get Signature

get n_iter_(): Promise<number>

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

Returns Promise<number>

Defined in generated/impute/IterativeImputer.ts:494


py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

Returns void

Defined in generated/impute/IterativeImputer.ts:133


random_state_

Get Signature

get random_state_(): Promise<any>

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

Returns Promise<any>

Defined in generated/impute/IterativeImputer.ts:629

Methods

dispose()

dispose(): Promise<void>

Disposes of the underlying Python resources.

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

Returns Promise<void>

Defined in generated/impute/IterativeImputer.ts:187


fit()

fit(opts): Promise<any>

Fit the imputer on X and return self.

Parameters

ParameterTypeDescription
optsobject-
opts.fit_params?anyParameters routed to the fit method of the sub-estimator via the metadata routing API.
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:204


fit_transform()

fit_transform(opts): Promise<ArrayLike>

Fit the imputer on X and return the transformed X.

Parameters

ParameterTypeDescription
optsobject-
opts.params?anyParameters routed to the fit method of the sub-estimator via the metadata routing API.
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:248


get_feature_names_out()

get_feature_names_out(opts): Promise<any>

Get output feature names for transformation.

Parameters

ParameterTypeDescription
optsobject-
opts.input_features?anyInput features.

Returns Promise<any>

Defined in generated/impute/IterativeImputer.ts:294


get_metadata_routing()

get_metadata_routing(opts): Promise<any>

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Parameters

ParameterTypeDescription
optsobject-
opts.routing?anyA MetadataRouter encapsulating routing information.

Returns Promise<any>

Defined in generated/impute/IterativeImputer.ts:332


init()

init(py): Promise<void>

Initializes the underlying Python resources.

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

Parameters

ParameterType
pyPythonBridge

Returns Promise<void>

Defined in generated/impute/IterativeImputer.ts:146


set_output()

set_output(opts): Promise<any>

Set output container.

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

Parameters

ParameterTypeDescription
optsobject-
opts.transform?"default" | "pandas" | "polars"Configure output of transform and fit_transform.

Returns Promise<any>

Defined in generated/impute/IterativeImputer.ts:370


transform()

transform(opts): Promise<ArrayLike>

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.

Parameters

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

Returns Promise<ArrayLike>

Defined in generated/impute/IterativeImputer.ts:406