EasyDeepLearn

What is frequency (count) encoding?

easy

Answer

  • Replace each category with its count (or frequency) in the training set.
  • Works well for tree models: high-frequency categories often behave differently from rare ones, and this captures that in one column instead of one-hot's thousands.
  • Doesn't leak the target so it's safer than target encoding for high-cardinality categoricals.
  • Downside: two categories with the same count get the same encoding, so it's information-losing — often combined with other encodings.
Check yourself — multiple choice
  • Replace category with the target mean
  • Replace with the category's count/frequency in training — safe, tree-friendly, but collision-prone
  • One-hot encode every category
  • Drop rare categories only

Frequency encoding: category → count. Safe, useful for trees, but two categories with the same count collide.

#encoding#features

Practise Supervised Learning

215 interview questions in this topic.

Related questions