yandex-research / rtdl

Research on Tabular Deep Learning: Papers & Packages
Apache License 2.0
888 stars 98 forks source link

embedding of categorical variables #37

Closed lhq12 closed 2 years ago

lhq12 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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.