P32Feature EngineeringAdvancedDiagnose18 min
Leakage-Safe Target Encoding
Encode a high-cardinality category without letting each row learn from its own target.
#target-encoding#leakage#cross-validation#high-cardinality
Scenario
A conversion model uses merchant_id with thousands of values. Raw one-hot encoding is too sparse, so the team considers target encoding.
Problem statement
Explain the leakage risk and describe an out-of-fold encoding strategy.
Your Task
- Identify why full-dataset target means leak information.
- Build encodings using training folds only.
- Define a fallback for unseen merchants.
Related Concepts
High cardinalityCross-validationSmoothing
Ready to count this problem?
Mark it complete when you have reasoned through the solution in your own words.