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:
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.
Outside cross-validation by just imputing over the whole dataset.
Which is the right way to go?