Frequency Encoding
It is a way to utilize the frequency of the categories as labels. In the cases where the frequency is related somewhat with the target variable, it helps the model to understand and assign the weight in direct and inverse proportion, depending on the nature of the data. Replace the categories with the count of the observations that show that category in the dataset. Similarly, we can replace the category by the frequency -or percentage- of observations in the dataset.
Advantages of Count or Frequency encoding
It can help if frequency correlates with the target and also, it can help the model to understand that smaller categories are less trustworthy than bigger ones, especially when frequency encoding is used parallel with other types of encoding.
Advantages of Count or Frequency encoding
- Straightforward to implement.
- Does not expand the feature space.
- Can work well with tree-based algorithms.
Limitations of Count or Frequency encoding
Limitations of Count or Frequency encoding
- Does not handle new categories in the test set automatically.
- We can lose valuable information if there are two different categories with the same amount of observations count—this is because we replace them with the same number.