Can I use Train AND Test data for Imputation?
The philosophy behind splitting data into training and test sets is to have the opportunity of validating the model through fresh(ish) data, right?
So, by using the same imputer on both train and test sets, you are somehow spoiling the test data, and this may cause overfitting.
You CAN use the same approach to impute the missing data on both sets (in your case, the decision tree), however, you should instantiate two different models, and fit each one with its own related data.
Interestingly, I see a lot of different answers about this both on stackoverflow and other sites:
While working on my training data set, I imputed missing values of a certain column using a decision tree model. So here's my question. Is it fair to use ALL available data (Training & Test) to make a model for imputation (not prediction) or may I only touch the training set when doing this? Also, once I begin work on my Test set, must I use only my test set data, impute using the same imputation model made in my training set, or can I use all the data available to me to retrain my imputation model?
I would think so long as I didn't touch my test set for prediction model training, using the rest of the data for things like imputations would be fine. But maybe that would be breaking a fundamental rule. Thoughts?