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

Last updated 5 November 2026

  • OOB (out-of-bag) error assumes each row is unseen by the trees predicting it. When a row is OOB, its duplicate is still in-bag about 63% of the time, so the tree has effectively memorized the answer.

  • Deep, unpruned RF trees act like nearest-neighbor lookups, so near-duplicates and grouped data (repeated patients, overlapping time windows) leak the same way.

  • Fix it by deduplicating, bootstrapping by group or using GroupKFold or time-based splits, and confirming on a properly separated hold-out set.

  • https://medium.com/@jonghajeon1990/ml-13-out-of-bag-error-is-free-pessimistic-when-small-and-blind-to-copies-4ba5eef3283f
  • https://edukatesg.com/2026/10/25/how-ai-works-out-of-bag-estimates-bootstrap-trees-unseen-votes-validation/
  • https://metricgate.com/blogs/how-to-interpret-random-forest-variable-importance/
All Random Forests interview questions