Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

embedding of categorical variables #37

Closed
lhq12 opened this issue Sep 4, 2022 · 3 comments
Closed

embedding of categorical variables #37

lhq12 opened this issue Sep 4, 2022 · 3 comments

Comments

@lhq12
Copy link

lhq12 commented Sep 4, 2022

Hi Yury,

Thank you for your excellent work. I get a problem when handling categorical features. Do I need to pre-train the embedding layer when applying it to the data processing or just to attach the embedding layer to the model and train it with the model.

@Yura52
Copy link
Collaborator

Yura52 commented Sep 4, 2022

Hi @lhq12 , pretraining is not needed. The embedding layer is just a module, so it should be a part of the model and should be trained with the model.

Could you clarify, please, is your question related to the rtdl library or is it about one of the papers?

@lhq12
Copy link
Author

lhq12 commented Sep 5, 2022

Yes, this is related to "Revisiting Deep Learning Models for Tabular Data". I am confused about the details of embedding categorical features, that is why I am here reading rtdl.

I still have a question, without pretraining, embeddings of those categories unseen at training stage are just random noises. Are there any tricks to handle this or we don't care about this?

@Yura52
Copy link
Collaborator

Yura52 commented Sep 5, 2022

unseen at training stage

This is an important detail :) I can think of several possible strategies, it depends on your specific problem what will work better:

  1. Replace unseen categories with the most popular known category.
  2. During evaluation, for unseen categories, use the average of embeddings of the known categories.
  3. Same as 2, but use weighted average by taking the distribution of categories into account.
  4. introduce a new category "<RARE>" and replace the least frequent categories with "<RARE>" before the training. During evaluation, unseen categories should be replaced with the new "<RARE>" category.
  5. introduce a new category "<UNKNOWN>" and replace categories during the training with "<UNKNOWN>" with a probability unknown_rate. During evaluation, unseen categories should be replaced with the new "<UNKNOWN>" category. Ideally, unknown_rate should be equal to the rate of unseen categories that you expect during evaluation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants