0
$\begingroup$

I have a dataset that has many different features such as categorical, ordinal and continuous ones.

Categorical Features
I have great difficulty understanding how should I apply label encoding to categorical features, because I have read that it should be done after or before splitting into train and test set, but sincerely I would do it by creating a custom encoder for each one because I do already know each feature possible outcome. I consider that encoding before split is not a problem, or there could still be a leakage into different splits?
I also know that the ML model for these features would not receive any different value from the ones considered in a deployment phase, so I could encode by using pre-defined dictionary.

Continuous Features
How should I treat the numerical continuous features, knowing that in deployment phase the variables could get greater or smaller values from the ones that I'm observing in the dataset? What is the best normalization technique that I should apply and when? Before or after the train-test split? Or even not considering to apply a normalization and maybe transform the variable into a categorical feature? (thinking about: value < x, x < value < y, y < value)

I consider that a min-max normalization or standardization could suffer both from unseen observations during deployment phase because is based only on observed data; am I wrong?

Ordinal Features how to deal with features representing order? (such as priority for example)
Could I still use an encoding technique used for categorical data or does the order matter between labelled econded outcomes?

However, if I'm using Cross Validation it would be correct to make these features transformations on the whole dataset?

Sorry if those are dumb questions but it's the first time I have to deal with deployment, it's all roses and flowers when dealing with online courses and internet examples that do not consider this critical phase.

$\endgroup$
1
  • $\begingroup$ Pretend the test set doesn’t exist when you train your model. After all, if you’re Apple making Siri, you want to interpret speech that has yet to be uttered! $\endgroup$ – Dave Feb 11 at 11:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.