class sklearn.impute.SimpleImputer(missing_values=nan, strategy=’mean’, fill_value=None, verbose=0, copy=True)
[source]
Imputation transformer for completing missing values.
Read more in the User Guide.
Parameters: |
|
---|---|
Attributes: |
|
Columns which only contained missing values at fit
are discarded upon transform
if strategy is not “constant”.
>>> import numpy as np >>> from sklearn.impute import SimpleImputer >>> imp_mean = SimpleImputer(missing_values=np.nan, strategy='mean') >>> imp_mean.fit([[7, 2, 3], [4, np.nan, 6], [10, 5, 9]]) ... SimpleImputer(copy=True, fill_value=None, missing_values=nan, strategy='mean', verbose=0) >>> X = [[np.nan, 2, 3], [4, np.nan, 6], [10, np.nan, 9]] >>> print(imp_mean.transform(X)) ... [[ 7. 2. 3. ] [ 4. 3.5 6. ] [10. 3.5 9. ]]
fit (X[, y]) | Fit the imputer on X. |
fit_transform (X[, y]) | Fit to data, then transform it. |
get_params ([deep]) | Get parameters for this estimator. |
set_params (**params) | Set the parameters of this estimator. |
transform (X) | Impute all missing values in X. |
__init__(missing_values=nan, strategy=’mean’, fill_value=None, verbose=0, copy=True)
[source]
fit(X, y=None)
[source]
Fit the imputer on X.
Parameters: |
|
---|---|
Returns: |
|
fit_transform(X, y=None, **fit_params)
[source]
Fit to data, then transform it.
Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.
Parameters: |
|
---|---|
Returns: |
|
get_params(deep=True)
[source]
Get parameters for this estimator.
Parameters: |
|
---|---|
Returns: |
|
set_params(**params)
[source]
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter>
so that it’s possible to update each component of a nested object.
Returns: |
|
---|
transform(X)
[source]
Impute all missing values in X.
Parameters: |
|
---|
sklearn.impute.SimpleImputer
© 2007–2018 The scikit-learn developers
Licensed under the 3-clause BSD License.
http://scikit-learn.org/stable/modules/generated/sklearn.impute.SimpleImputer.html