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

02The space explodes

2.1Counting cells

The simplest way to see the curse is to divide every feature into 10 bins, as a histogram or a lookup table would. One feature gives 10 cells, two features give 10\times10=100, three give 1{,}000, and in general

\text{number of cells}=10^d. \tag{1}

Ten features already make 10^{10} cells, ten billion, more than the number of people on Earth. Any method that needs data in every cell, such as a histogram density estimate or a lookup-table classifier, needs exponentially many examples (Bishop, 2006, §1.4).

Worked example 1 (The same 100 customers). Take 100 customers described by three features scaled to [0,1]: age, income and a third score. With age alone, the 10 bins hold 13, 12, 8, 13, 9, 13, 9, 7, 10 and 6 customers: every bin is full (Figure 1a). With age and income, only 64 of the 100 cells are occupied, so 36 are empty (Figure 1b). With all three features, only 95 of 1{,}000 cells are occupied: 90.5\% of the space has never been seen. A new customer who lands in an empty cell has no training example to learn from.

The same 100 customers with 10 bins per feature. (a) One feature: all 10 bins are occupied; the numbers are the counts. (b) Two features: 64 of 100 cells are occupied (shaded). (c) The share of empty cells: expected value (2) (line) and these customers (circles). Computed for this tutorial, with the same data and seed as the companion video.
Figure 1. The same 100 customers with 10 bins per feature. (a) One feature: all 10 bins are occupied; the numbers are the counts. (b) Two features: 64 of 100 cells are occupied (shaded). (c) The share of empty cells: expected value (2) (line) and these customers (circles). Computed for this tutorial, with the same data and seed as the companion video.
Try itFill the space with data

Choose the number of features and the number of data points. Each feature is cut into 10 bins, so there are 10^d cells, and the points are thrown in uniformly. Left: the cells, blue if at least one point landed there. Right: the share of empty cells, expected from equation (2) (line) and in this draw (dot).

How many cells should we expect to be empty? With M=10^d cells and N points thrown in uniformly, a given cell misses all N points with probability (1-1/M)^N, so

\E[\text{share of empty cells}]=\Bigl(1-\frac1M\Bigr)^{N}\approx e^{-N/M}. \tag{2}

For N=100 this is 36.6\% for d=2 (close to e^{-1}=0.368), 90.5\% for d=3 (e^{-0.1}=0.905) and 99\% for d=4. The expected numbers of occupied cells, 63.4 and 95.2, match the 64 and 95 we observed. Once M\gg N, the share of occupied cells is about N/M: almost every point sits alone in its own cell.

2.2How much data would we need?

To keep the same density of points per cell we must multiply N by 10 for every new feature. Hastie et al. (2009, §2.5) put it this way: the sampling density is proportional to N^{1/d}, so if N_1=100 points are a dense sample for one input, the same density in 10 inputs needs N_{10}=100^{10}=10^{20} points. Domingos (2012) gives the binary version: with 100 Boolean features there are 2^{100}\approx1.27\times10^{30} possible inputs, so even a trillion training examples cover only 10^{12}/2^{100}\approx7.9\times10^{-19} of the input space, “about 10^{-18}” in his words.

Pause and think. A table of conditional probabilities P(y\mid x) with 10 bins per feature has to be estimated from one million examples. Above how many features are most of its cells empty?

Show the answer

Most cells are empty once 10^d exceeds the number of examples by a clear margin: by (2) the empty share is e^{-1}=37\% at d=6 (10^6 cells) and e^{-0.1}=90\% at d=7. A million examples support only six or seven binned features, which is why such tables give way to models that share information across cells.