MoonSay /Tutorials/Machine Learning Interview #10
Contents
  1. 01Introduction
  2. 02The space explodes
  3. 03Your neighbors drift away
  4. 04The orange is all peel
  5. 05More features, worse model
  6. 06Why machine learning still works
  7. 07Common misconceptions
  8. 08Interview questions and model answers
  9. 09Summary
  10. References
Machine Learning Interview #10 · Tutorial

The Curse of DimensionalityWhy More Features Can Hurt

Why more features can make a model worse, and why machine learning still works

A tutorial companion to the video Machine Learning Interview #10: The Curse of Dimensionality: Why More Features Can Hurt PDF

01Introduction

1.1The question

“What is the curse of dimensionality, and why can adding features hurt a model?” Interviewers ask it because the answer tests geometric intuition rather than a memorized formula. More features look like more information. But every new feature adds a dimension, and the space a model must cover grows exponentially with the number of dimensions while the training set stays the same size. Data that looked dense in two dimensions become a few lonely points in a vast space, neighborhoods stop being local, and distances lose their meaning. Methods that reason by similarity, such as k-nearest neighbors and kernel methods, suffer first.

1.2Prerequisites and notation

Prerequisites. Volumes of cubes and balls, expectation and variance, and the k-nearest neighbors classifier. Episode 2 (the bias–variance tradeoff) and Episode 4 (L1 and L2 regularization) are helpful.

Notation. d is the number of features (the dimension), and N the number of training points. Unless stated otherwise the data are uniform in the unit cube [0,1]^d or the unit ball \{x:\|x\|\le1\}. \|x-y\| is the Euclidean distance; D_{\min} and D_{\max} are the distances from a query point to its nearest and farthest data point. \E and \Var denote expectation and variance.

1.3A short history

Bellman (1957) coined the phrase in the preface of Dynamic Programming: to solve a control problem on a grid, the number of grid points grows exponentially with the number of state variables, and he called this the “curse of dimensionality”; he returned to it in Bellman (1961). Hughes (1968) observed that, with a fixed training set, the accuracy of a classifier first rises as measurements are added and then falls, the peaking phenomenon. Stone (1982) proved that the best possible error rate of nonparametric regression gets exponentially slower in d. Beyer et al. (1999) showed that under broad conditions the nearest and farthest neighbors become equally far, and Aggarwal et al. (2001) studied which distance norms suffer least. The textbook treatments used here are Hastie et al. (2009, §2.5), Bishop (2006, §1.4), Goodfellow et al. (2016, §5.11) and Murphy (2022, §16.1.2, §20.4.2); Domingos (2012) gives the practitioner’s view. All numbers in this tutorial were computed for this tutorial with the same data and seeds as the companion video.