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.
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.
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.