smile.imputation
Class KNNImputation
- java.lang.Object
-
- smile.imputation.KNNImputation
-
- All Implemented Interfaces:
- MissingValueImputation
public class KNNImputation extends java.lang.Object implements MissingValueImputation
Missing value imputation by k-nearest neighbors. The KNN-based method selects instances similar to the instance of interest to impute missing values. If we consider instance A that has one missing value on attribute i, this method would find K other instances, which have a value present on attribute 1, with values most similar (in term of some distance, e.g. Euclidean distance) to A on other attributes without missing values. The average of values on attribute i from the K nearest neighbors is then used as an estimate for the missing value in instance A. In the weighted average, the contribution of each instance is weighted by similarity between it and instance A.
-
-
Constructor Summary
Constructors Constructor and Description KNNImputation(int k)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidimpute(double[][] data)Impute missing values in the dataset.
-
-
-
Constructor Detail
-
KNNImputation
public KNNImputation(int k)
Constructor.- Parameters:
k- the number of neighbors used for imputation.
-
-
Method Detail
-
impute
public void impute(double[][] data) throws MissingValueImputationExceptionDescription copied from interface:MissingValueImputationImpute missing values in the dataset.- Specified by:
imputein interfaceMissingValueImputation- Parameters:
data- a data set with missing values (represented as Double.NaN). On output, missing values are filled with estimated values.- Throws:
MissingValueImputationException
-
-
DataMelt 3.0 © DataMelt by jWork.ORG