Why can out-of-bag error be over-optimistic when duplicate or near-duplicate records exist in the training set?

Quick Overview

Explain why random forest out-of-bag error can look too good when the training set holds duplicate or near-duplicate records. Tests the bootstrap probability argument, why deep trees memorize copies, and how grouped splits or deduplication restore an honest estimate.

Why can out-of-bag error be over-optimistic when duplicate or near-duplicate records exist in the training set?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: hard

Interview Round: Other

Why can out-of-bag (OOB) error be over-optimistic when duplicate or near-duplicate records exist in the training set? Assume a standard random forest with bootstrap sampling and fully grown trees, and that the OOB score is being used in place of a separate validation set. ```hint Count the overlap For a tree where a given row is out-of-bag, work out the chance that an exact copy of that row is in the tree's bootstrap sample. ``` ```hint What the tree does with a copy Think about what a fully grown tree predicts for a point that sits exactly on top of one of its training points. ``` ### What a Strong Answer Covers - The assumption that OOB estimation depends on and how a duplicate breaks it - The probability argument for how often a copy is in-bag when its twin is out-of-bag - Why deep, unpruned trees turn that overlap into near-perfect predictions - How near-duplicates, repeated measurements and overlapping time windows cause the same leak - Practical fixes and how to confirm the estimate is trustworthy ### Follow-up Questions - If every record appears three times, how often is at least one copy in-bag for a tree where the record is out-of-bag? - Would raising `min_samples_leaf` or limiting tree depth remove the bias, and what would it cost? - How would you implement a group-level bootstrap for a random forest? - Does random k-fold cross-validation suffer from the same problem?

Overview: Explain why random forest out-of-bag error can look too good when the training set holds duplicate or near-duplicate records. Tests the bootstrap probability argument, why deep trees memorize copies, and how grouped splits or deduplication restore an honest estimate.

General logo
General
Nov 24, 2026
hardMachine Learning EngineerOtherMachine Learning
0
0

Why can out-of-bag (OOB) error be over-optimistic when duplicate or near-duplicate records exist in the training set?

Assume a standard random forest with bootstrap sampling and fully grown trees, and that the OOB score is being used in place of a separate validation set.

What a Strong Answer Covers Guidance

  • The assumption that OOB estimation depends on and how a duplicate breaks it
  • The probability argument for how often a copy is in-bag when its twin is out-of-bag
  • Why deep, unpruned trees turn that overlap into near-perfect predictions
  • How near-duplicates, repeated measurements and overlapping time windows cause the same leak
  • Practical fixes and how to confirm the estimate is trustworthy

Follow-up Questions Guidance

  • If every record appears three times, how often is at least one copy in-bag for a tree where the record is out-of-bag?
  • Would raising min_samples_leaf or limiting tree depth remove the bias, and what would it cost?
  • How would you implement a group-level bootstrap for a random forest?
  • Does random k-fold cross-validation suffer from the same problem?