0
$\begingroup$

[Beginner here] If dataset contains - both ordinal, nonordinal (few categories) & nonordinal (multiple categories > 30). Is one supposed to pick one to encapsulate of all such situations or preprocess each type with different encoders?

End goal is to train a ML model.

$\endgroup$

1 Answer 1

0
$\begingroup$

I would suggest to use different encoders for different types of columns. Lets suppose you have 10 categorical features where 5 of them are ordinal and 5 are nominal. If you one hot encode all of them, you will destroy the sense of order that was in the ordinal features and hence this will affect the performance of the model. Also your dimensionality would increase marginally.

Instead you should use one hot encoder on the nominal features and ordinal encoding techniques on your ordinal features. This will have 2 advantages:-

1.) The sense of order in your data will remain preserved.

2.) Dimensionality will also be less compared to the case where you one hot encode all of them (although that depends on your data).

I would suggest divide your data into different data frames based on the type of features it has and then perform OHE on the nominal feature data frame, Ordinal Encoding on the ordinal feature data frame and then finally concatenate them.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.