Smoothed Target Encoding

medium
Unit 15 · Interpretability II0/2 to milestone

High-cardinality categories (city, product id) are too many for one-hot encoding. Target encoding replaces each category with the average target value for that category, but categories with few examples are noisy, so we smooth towards the global mean:

Pro problem

Unlock this and every premium problem across all tracks — plus hidden-test grading, advanced AI engineering modules and new content every week.

Start 7-day free trial
solution.py · Python 3.13
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Smoothed Target Encoding · TechGradify