Binary indicators for missing values.
Note that this component typically should not be used in a vanilla Pipeline consisting of transformers and a classifier, but rather could be added using a FeatureUnion or ColumnTransformer.
Read more in the User Guide.
Added in version 0.20.
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.
Whether the imputer mask should represent all or a subset of features.
'missing-only' (default), the imputer mask will only represent features containing missing values during fit time.'all', the imputer mask will represent all features.Whether the imputer mask format should be sparse or dense.
'auto' (default), the imputer mask will be of same type as input.True, the imputer mask will be a sparse matrix.False, the imputer mask will be a numpy array.If True, transform will raise an error when there are features with missing values that have no missing values in fit. This is applicable only when features='missing-only'.
The features indices which will be returned when calling transform. They are computed during fit. If features='all', features_ is equal to range(n_features).
Number of features seen during fit.
Added in version 0.24.
n_features_in_,)
Names of features seen during fit. Defined only when X has feature names that are all strings.
Added in version 1.0.
See also
SimpleImputerUnivariate imputation of missing values.
IterativeImputerMultivariate imputation of missing values.
>>> import numpy as np
>>> from sklearn.impute import MissingIndicator
>>> X1 = np.array([[np.nan, 1, 3],
... [4, 0, np.nan],
... [8, 1, 0]])
>>> X2 = np.array([[5, 1, np.nan],
... [np.nan, 2, 3],
... [2, 4, 0]])
>>> indicator = MissingIndicator()
>>> indicator.fit(X1)
MissingIndicator()
>>> X2_tr = indicator.transform(X2)
>>> X2_tr
array([[False, True],
[ True, False],
[False, False]])
Fit the transformer on X.
Input data, where n_samples is the number of samples and n_features is the number of features.
Not used, present for API consistency by convention.
Fitted estimator.
Generate missing values indicator for X.
The input data to complete.
Not used, present for API consistency by convention.
The missing indicator for input data. The data type of Xt will be boolean.
Get output feature names for transformation.
Input features.
input_features is None, then feature_names_in_ is used as feature names in. If feature_names_in_ is not defined, then the following input feature names are generated: ["x0", "x1", ..., "x(n_features_in_ - 1)"].input_features is an array-like, then input_features must match feature_names_in_ if feature_names_in_ is defined.Transformed feature names.
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
A MetadataRequest encapsulating routing information.
Get parameters for this estimator.
If True, will return the parameters for this estimator and contained subobjects that are estimators.
Parameter names mapped to their values.
Set output container.
See Introducing the set_output API for an example on how to use the API.
Configure output of transform and fit_transform.
"default": Default output format of a transformer"pandas": DataFrame output"polars": Polars outputNone: Transform configuration is unchangedAdded in version 1.4: "polars" option was added.
Estimator instance.
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.
Estimator parameters.
Estimator instance.
Generate missing values indicator for X.
The input data to complete.
The missing indicator for input data. The data type of Xt will be boolean.
© 2007–2025 The scikit-learn developers
Licensed under the 3-clause BSD License.
https://scikit-learn.org/1.6/modules/generated/sklearn.impute.MissingIndicator.html