1
$\begingroup$

In machine learning when I impute missing values which of the following I perform :

1-Impute data set and then split it? 2-Split dataset to Training and testing datasets and then Impute each datasets separately.

$\endgroup$
1
  • $\begingroup$ Ideally, you "learn" the imputation on the training data and then apply it to test. Whether this is possible/necessary depends on the use case. We don't know anything about it, so you can't really expect good help. $\endgroup$
    – Michael M
    Commented Dec 8, 2023 at 22:17

1 Answer 1

1
$\begingroup$

First split, then impute missing data on the training set using information from the training set only. Anything else leaks data from the testing set to the training data.

After that, whether you want to impute for the test set using the test set only or the whole dataset depends on your situation. Usually, you will want to impute using the whole set; after all, you are also applying the model you learned from the training data to the test data. However, there might be situations where you can only "transfer" the model from the training set to the test set, not any other information, e.g., for privacy reasons. In such a case, it might make more sense to impute on the test set using the test set only.

I personally am not a big fan of imputation... it usually makes you feel too sure of your conclusions and predictions.

$\endgroup$

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