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

| improve this answer | |
$\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.