class sklearn.preprocessing.Imputer(missing_values=’NaN’, strategy=’mean’, axis=0, verbose=0, copy=True) [source]
Imputation transformer for completing missing values.
Read more in the User Guide.
| Parameters: |
missing_values : integer or “NaN”, optional (default=”NaN”) The placeholder for the missing values. All occurrences of strategy : string, optional (default=”mean”) The imputation strategy.
axis : integer, optional (default=0) The axis along which to impute.
verbose : integer, optional (default=0) Controls the verbosity of the imputer. copy : boolean, optional (default=True) If True, a copy of X will be created. If False, imputation will be done in-place whenever possible. Note that, in the following cases, a new copy will always be made, even if
|
|---|---|
| Attributes: |
statistics_ : array of shape (n_features,) The imputation fill value for each feature if axis == 0. |
axis=0, columns which only contained missing values at fit are discarded upon transform.axis=1, an exception is raised if there are rows for which it is not possible to fill in the missing values (e.g., because they only contain missing values).
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’, axis=0, verbose=0, copy=True) [source]
fit(X, y=None) [source]
Fit the imputer on X.
| Parameters: |
X : {array-like, sparse matrix}, shape (n_samples, n_features) Input data, where |
|---|---|
| Returns: |
self : Imputer Returns self. |
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: |
X : numpy array of shape [n_samples, n_features] Training set. y : numpy array of shape [n_samples] Target values. |
|---|---|
| Returns: |
X_new : numpy array of shape [n_samples, n_features_new] Transformed array. |
get_params(deep=True) [source]
Get parameters for this estimator.
| Parameters: |
deep : boolean, optional If True, will return the parameters for this estimator and contained subobjects that are estimators. |
|---|---|
| Returns: |
params : mapping of string to any Parameter names mapped to their values. |
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: | self : |
|---|
transform(X) [source]
Impute all missing values in X.
| Parameters: |
X : {array-like, sparse matrix}, shape = [n_samples, n_features] The input data to complete. |
|---|
sklearn.preprocessing.Imputer
© 2007–2017 The scikit-learn developers
Licensed under the 3-clause BSD License.
http://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.Imputer.html