0
$\begingroup$

I'm just getting started with ML and am busy with my first Kaggle competition (the titanic one).

I was just wondering what would be the best way to organise the data to avoid redundancy with the following steps:

  • Feature Selection
  • Account for gaps in data(Imputing)
  • One hot encoding to allow non numerical features
  • Split data into training and validation sets
  • Then proceed to fit and predict with the model.

My main query is whether it is better to split the data before encoding it, or to only do the split after completing the encoding?

$\endgroup$
1
$\begingroup$

The same encoding needs to happen on both the train and the test set. So, encode before splitting.

$\endgroup$
0
$\begingroup$
  1. One hot encoding to allow non numerical features on all data.
  2. Split data into training and validation sets. Preferably stratify the sets for the outcome distribution.
  3. Account for gaps in data(Imputing) based on the training set only and apply the same imputation on validation set. Imputation procedures can be seen as parts of a machine learning model.
  4. Feature selection/algorithm selection/hyperparameter tuning in the training set.
  5. Then proceed to fit on the training set and evaluate performance on the validation set.
$\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.