Overfitting or the Wrong Problem?

Decide what you would do from the brief alone, including whether you would change anything at all. Everything below it is available, but the exercise stops working if you open it first.

The brief you were given

A logistic regression on 3,000 one-hot-encoded features overfits: training log loss is tiny, validation is poor. The proposal is "add L2 and grid-search the strength". Data: 8,000 examples from a customer database where many of the features are near-unique identifiers such as postcode and company name.

The trap — the fix that moves the metric and is not the fix

Grid-searching the L2 strength until validation log loss is minimised, and shipping. The validation number improves — regularisation does reduce variance — and the search is tidy and reproducible. The model still contains a coefficient per postcode and per company; the coefficients are just smaller. A new company or postcode at serving time maps to an all-zero one-hot row and gets the intercept, which is the average customer, so the model is confidently uninformative on exactly the new customers the business is trying to score. The grid search made the memorisation quieter; it did not make the model generalise.

Read this even if you are confident. It is here rather than behind a button because it is the answer most teams actually ship, it passes review, and its cost arrives weeks later when the labels do.