Top-n encoding controls categorical feature growth by preserving the most frequent values and collapsing the remainder into an Other category before one-hot encoding. It keeps common categories interpretable while avoiding a separate column for every distinct value. section 4.5.4
A practical encoding workflow is:
- Separate feature columns from the target label. section 4.5.4
- Identify categorical columns that must become numeric for model training. section 4.5.4
- Keep the top n values unchanged, map all remaining values to an Other group, and one-hot encode the resulting groups. section 4.5.4
Salt_Name with the top 50 values
For Salt_Name, retain the 50 most frequent values such as Paracetamol or Ibuprofen, place every remaining value in Other_Salt, and create one-hot features for the resulting groups. section 4.5.4
