Code RoomData leakage in cross-validation
MediumPrep Room Coding #4215

Data leakage in cross-validation

Vibe & agenticAlgorithms & data structuresMid–Senior~16 min

An AI assistant wrote this scikit-learn churn pipeline. Cross-validation reports a stellar 0.94 ROC-AUC, but production accuracy is far worse. Find the flaw.

Implement
standardize_within_fold(values: list[float], fold_ids: list[int], fold: int) → list[float]
Examples
in[[2,4,6,8],[0,0,1,1],1]out[3,5]
in[[2,4,6,8],[0,0,1,1],0]out[-5,-3]
in[[2,4,6,8],[0,0,0,0],0]out[]
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.

0:00 of about 16 min

Vibe & agentic: describe the solution in plain language (or narrate it) and the coach grades your approach.

Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.