How do duplicate or near-duplicate rows across folds cause data leakage?

Quick Overview

Asks how duplicate and near-duplicate rows shared between training and validation folds leak information into cross-validation. Tests whether you can name the usual sources, explain the inflated scores and biased model selection, and fix the split with deduplication and group-aware folds.

How do duplicate or near-duplicate rows across folds cause data leakage?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

How do duplicate or near-duplicate rows across folds cause data leakage? Explain where such rows come from, what they do to a cross-validation estimate, and how you would set up the split to prevent the problem. ```hint What validation estimates Ask what a validation score is supposed to measure, then count how many validation rows have a twin, or a sibling from the same user, sitting in the training folds. ``` ### What a Strong Answer Covers - The mechanism: shared or near-identical examples let the model score well on content it has already seen. - Common sources of exact and near duplicates. - The effect on the CV score and on model selection, especially for high-capacity models. - Fixes: deduplication, group-aware splitting, resampling and augmentation inside training folds, and time-aware splits. ### Follow-up Questions - How would you detect near-duplicates in a large image or text dataset? - If the deployed model scores users who were already in the training data, is a group split always the right choice? - How do you combine group splitting with stratification on a rare label? - How large a gap would you leave between training and validation windows in a time-series split, and why?

Overview: Asks how duplicate and near-duplicate rows shared between training and validation folds leak information into cross-validation. Tests whether you can name the usual sources, explain the inflated scores and biased model selection, and fix the split with deduplication and group-aware folds.

General logo
General
Nov 25, 2026
mediumMachine Learning EngineerOtherMachine Learning
0
0

How do duplicate or near-duplicate rows across folds cause data leakage?

Explain where such rows come from, what they do to a cross-validation estimate, and how you would set up the split to prevent the problem.

What a Strong Answer Covers Guidance

  • The mechanism: shared or near-identical examples let the model score well on content it has already seen.
  • Common sources of exact and near duplicates.
  • The effect on the CV score and on model selection, especially for high-capacity models.
  • Fixes: deduplication, group-aware splitting, resampling and augmentation inside training folds, and time-aware splits.

Follow-up Questions Guidance

  • How would you detect near-duplicates in a large image or text dataset?
  • If the deployed model scores users who were already in the training data, is a group split always the right choice?
  • How do you combine group splitting with stratification on a rare label?
  • How large a gap would you leave between training and validation windows in a time-series split, and why?