2
$\begingroup$

I'm using k-nearest neighbour imputation method for missing values. This method has two tuning parameters: k and the distance metric. I see two options for applying this imputation method:

  1. Inside nested cross-validation. Applying the imputation method separately to the training and testing set. If I'm using leave-one-out cross-validation this will not work because my test set only contains one data point.

  2. Outside cross-validation by just imputing over the whole dataset.

Which is the right way to go?

$\endgroup$
1
$\begingroup$

You should fit your imputer on the training set only. This way the imputation on the test set will be based only on the knowledge of the training set. If you impute missing data on the whole dataset, you will loose training/test set separation as some information from the test set would leak to training.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.