2
$\begingroup$

I have a dataset which have both categorical features with high cardinality (>8000) and low cardinality (4 or 5). Would that be ok to encode the high cardinality ones with one encoder (target encoder, for example) and the others with low cardinality with another encoder (one hot encoder) and put everything together to train a model? Is this wrong and should apply the same encoder to all the features regardless of their cardinality?

Many thanks for your inputs!

$\endgroup$

1 Answer 1

1
$\begingroup$

It is perfectly fine. When you encode you want to extract the most information possible. You can apply one encoding to each feature, or even two.

Also you can encode numerical variables or bin them and then encoding.

For different encoding techniques, I recommend Category Encoders.

Be aware that some encodings can make your model decrease its performance, so you should select features somehow, not by adding more encodings your model will perform better.

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