1
$\begingroup$

I've been given 2 datasets , and there are missing values in both the test and training data set. Do I need to pre-process test.csv also or is it only for train.csv?

$\endgroup$
1
  • $\begingroup$ yes. fit on train, transform on train and test $\endgroup$ Oct 17 at 18:30
2
$\begingroup$

Preprocessing is needed for both train and test sets. But you should be aware of data leakage, meaning no information from the test set should be used to preprocess the training set.

For example, if you are trying to apply One-Hot encoding to your classification labels you should train the encoder (e.g. sklearn.preprocessing.OneHotEncoder) on training set and apply the trained encoder to get the labels for test set.

Or if you want to normalize a feature, calculate the mean and standard deviation from the training set and use it to normalize both training and test sets.

$\endgroup$
0
$\begingroup$

The main reason for data preprocessing is to ensure that the datasets are formatted in such a way that the data they contain can be interpreted and parsed by the machine learning algorithms.

As you train the machine learning models with training data and predict with machine learning models with the test data. Data preprocessing has to be applied to both train and test data

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