Package smile.feature.imputation
Class SimpleImputer
java.lang.Object
smile.feature.imputation.SimpleImputer
- All Implemented Interfaces:
Serializable
,Function<Tuple,
,Tuple> Transform
Simple algorithm replaces missing values with the constant value
along each column.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionApplies this transform to the given argument.static SimpleImputer
Fits the missing value imputation values.static SimpleImputer
Fits the missing value imputation values.static boolean
hasMissing
(Tuple x) Return true if the tuple x has missing values.static double[][]
impute
(double[][] data) Impute the missing values with column averages.toString()
-
Constructor Details
-
SimpleImputer
Constructor.- Parameters:
values
- the map of column name to the constant value.
-
-
Method Details
-
hasMissing
Return true if the tuple x has missing values.- Parameters:
x
- a tuple.- Returns:
- true if the tuple x has missing values.
-
apply
-
apply
Description copied from interface:Transform
Applies this transform to the given argument. -
toString
-
fit
Fits the missing value imputation values. Impute all the numeric columns with median, boolean/nominal columns with mode, and text columns with empty string.- Parameters:
data
- the training data.columns
- the columns to impute. If empty, impute all the applicable columns.- Returns:
- the imputer.
-
fit
Fits the missing value imputation values. Impute all the numeric columns with the mean of values in the range [lower, upper], boolean/nominal columns with mode, and text columns with empty string.- Parameters:
data
- the training data.lower
- the lower limit in terms of percentiles of the original distribution (e.g. 5th percentile).upper
- the upper limit in terms of percentiles of the original distribution (e.g. 95th percentile).columns
- the columns to impute. If empty, impute all the applicable columns.- Returns:
- the imputer.
-
impute
public static double[][] impute(double[][] data) Impute the missing values with column averages.- Parameters:
data
- data with missing values.- Returns:
- the imputed data.
- Throws:
IllegalArgumentException
- when the whole row or column is missing.
-