Code Room
Vibe codingHardvc-g272
Subject Ai code reviewLevel Senior–Staff~19 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

An AI added target encoding for a high-cardinality categorical (10k zip codes) before splitting. Holdout AUC is great; production drifts down immediately. Pinpoint the leakage and the right encoding.

python
# encode each zip by the mean target for that zipzip_means = df.groupby('zip')['converted'].mean()df['zip_te'] = df['zip'].map(zip_means)X_tr, X_te, y_tr, y_te = train_test_split(    df[['zip_te', 'age', 'income']], df['converted'], test_size=0.2)model.fit(X_tr, y_tr)
What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it — tests, edge cases, reading critically — and how you’d re-prompt or decompose to get it right.

Describe your solution

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.