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.
new IterativeImputer(opts?: object): IterativeImputer;
Name | Type | Description |
---|---|---|
opts? |
object |
- |
opts.add_indicator? |
boolean |
If 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? |
any |
The 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? |
string |
When 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: 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? |
boolean |
If 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? |
number |
Maximum 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 | ArrayLike |
Maximum 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 | ArrayLike |
Minimum 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? |
number |
The 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? |
number |
Number 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? |
number |
The 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? |
boolean |
Whether 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? |
boolean |
If 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? |
number |
Tolerance of the stopping condition. Default Value 0.001 |
opts.verbose? |
number |
Verbosity 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 |
Defined in: generated/impute/IterativeImputer.ts:25
Disposes of the underlying Python resources.
Once dispose()
is called, the instance is no longer usable.
dispose(): Promise<void>;
Promise
<void
>
Defined in: generated/impute/IterativeImputer.ts:214
Fit the imputer on X
and return self.
fit(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.X? |
ArrayLike |
Input data, where n\_samples is the number of samples and n\_features is the number of features. |
opts.y? |
any |
Not used, present for API consistency by convention. |
Promise
<any
>
Defined in: generated/impute/IterativeImputer.ts:231
Fit the imputer on X
and return the transformed X
.
fit_transform(opts: object): Promise<ArrayLike>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.X? |
ArrayLike |
Input data, where n\_samples is the number of samples and n\_features is the number of features. |
opts.y? |
any |
Not used, present for API consistency by convention. |
Promise
<ArrayLike
>
Defined in: generated/impute/IterativeImputer.ts:271
Get output feature names for transformation.
get_feature_names_out(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.input_features? |
any |
Input features. |
Promise
<any
>
Defined in: generated/impute/IterativeImputer.ts:313
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
get_metadata_routing(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.routing? |
any |
A MetadataRequest encapsulating routing information. |
Promise
<any
>
Defined in: generated/impute/IterativeImputer.ts:353
Initializes the underlying Python resources.
This instance is not usable until the Promise
returned by init()
resolves.
init(py: PythonBridge): Promise<void>;
Name | Type |
---|---|
py |
PythonBridge |
Promise
<void
>
Defined in: generated/impute/IterativeImputer.ts:146
Set output container.
See Introducing the set_output API for an example on how to use the API.
set_output(opts: object): Promise<any>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.transform? |
"default" | "pandas" |
Configure output of transform and fit\_transform . |
Promise
<any
>
Defined in: generated/impute/IterativeImputer.ts:392
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.
transform(opts: object): Promise<ArrayLike>;
Name | Type | Description |
---|---|---|
opts |
object |
- |
opts.X? |
ArrayLike [] |
The input data to complete. |
Promise
<ArrayLike
>
Defined in: generated/impute/IterativeImputer.ts:429
boolean
=false
Defined in: generated/impute/IterativeImputer.ts:23
boolean
=false
Defined in: generated/impute/IterativeImputer.ts:22
PythonBridge
Defined in: generated/impute/IterativeImputer.ts:21
string
Defined in: generated/impute/IterativeImputer.ts:18
any
Defined in: generated/impute/IterativeImputer.ts:19
Names of features seen during fit. Defined only when X
has feature names that are all strings.
feature_names_in_(): Promise<ArrayLike>;
Promise
<ArrayLike
>
Defined in: generated/impute/IterativeImputer.ts:572
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\_
.
imputation_sequence_(): Promise<any>;
Promise
<any
>
Defined in: generated/impute/IterativeImputer.ts:491
Indicator used to add binary indicators for missing values. undefined
if add\_indicator=False
.
indicator_(): Promise<any>;
Promise
<any
>
Defined in: generated/impute/IterativeImputer.ts:626
Imputer used to initialize the missing values.
initial_imputer_(): Promise<any>;
Promise
<any
>
Defined in: generated/impute/IterativeImputer.ts:464
Number of features seen during fit.
n_features_in_(): Promise<number>;
Promise
<number
>
Defined in: generated/impute/IterativeImputer.ts:545
Number of features with missing values.
n_features_with_missing_(): Promise<number>;
Promise
<number
>
Defined in: generated/impute/IterativeImputer.ts:599
Number of iteration rounds that occurred. Will be less than self.max\_iter
if early stopping criterion was reached.
n_iter_(): Promise<number>;
Promise
<number
>
Defined in: generated/impute/IterativeImputer.ts:518
py(): PythonBridge;
PythonBridge
Defined in: generated/impute/IterativeImputer.ts:133
py(pythonBridge: PythonBridge): void;
Name | Type |
---|---|
pythonBridge |
PythonBridge |
void
Defined in: generated/impute/IterativeImputer.ts:137
RandomState instance that is generated either from a seed, the random number generator or by np.random
.
random_state_(): Promise<any>;
Promise
<any
>
Defined in: generated/impute/IterativeImputer.ts:653