DATASCI 447 Lecture 5: Why Local Methods Fail (a.k.a. The Curse of Dimensionality)

Kevin McAlister

January 27, 2026

Administrative Stuff

ML is Geometry

Introductory ML materials present ML as minimizing loss

  • Not training error - true loss

  • Regularization as a method that creates a tuning knob that allows models to vary between high bias/low variance to low bias/high variance and use CV methods to find the setting that best generalizes (bias/variance tradeoff)

This definition is fine, but complex models and data types don’t fit cleanly in this bucket

  • What is the true loss?

  • How do I regularize when I have 1 million tuning parameters?

  • What can I do when using CV is too expensive to figure it out?

ML is Geometry

Probabilistic ML allows us to begin to think about this process less as a hand-wavy mechanical one and more through the lens of probability theory and model geometry

Minimizing the negative log likelihood (NLL) is equivalent to minimizing the loss.

  • If we directly minimize the NLL for a model with infinite capacity (no limit to flexibility), what solution will it find?

Regularization is a way to restrict the space of functions that can be recovered by a learning method by placing priors on the function space

  • If we add a Ridge penalty to a loss function, how does the regularization constant \(\lambda\) restrict the function space? How does this relate to restricting model capacity/flexibility?

ML is Geometry

To jointly find \(\mathbf M\) and \(\bbeta\) that are most generalizable over all possible models within our model class:

\[ \{\hat{\mathbf M}, \hat{\bbeta} \} = \max_{\mathbf M} \int \limits_{\btheta} P(\mathbf y | \mathbf X, \bbeta , \mathbf M) P(\bbeta | \mathbf M) d \bbeta \]

\[ \{\hat{\mathbf M}, \hat{\bbeta} \} = \max_{\mathbf M} E_{\bbeta} \left[ P(\mathbf y | \mathbf X, \bbeta , \mathbf M) \right] \]

  • Find the arrangement of \(\mathbf M\) and \(\bbeta\) that maximize the likelihood that we would’ve seen our observed data accounting for our prior structural constaints

  • Also can think of it as maximize the expected value of the likelihood taken w.r.t. \(\bbeta\)

ML is Geometry

Solving this integral is going to be critical for creating good generative models

  • It’s the only way that we’ll be able to train machines that can generate new images!

But we’ve glossed over something fundamental:

  • We’ve been assuming we have a model class worth considering
  • Where does the model class come from?
  • What makes a model class “good”?

Today: What properties should a model class have, and when do those properties actually help us?

The Practical Goal of ML

In practice, we want learning methods that:

  1. Generalize well to unseen data
  2. Can be estimated and tuned with minimal human intervention
  3. Scale to problems where hand-tuning is impossible

This isn’t just theoretical preference — it’s practical necessity

The Practical Goal of ML

Medical Imaging: Millions of scans across diverse populations

  • Can’t hand-tune a model for each patient
  • Need methods that automatically adapt to signal in data

Recommendation Systems: Billions of user-item interactions

  • Continuous retraining as preferences shift
  • No human could manually specify the relevant features

Fraud Detection: Adversarial, non-stationary environment

  • Patterns change as adversaries adapt
  • Must learn new structure without manual intervention

The Practical Goal of ML

Language Models: Trillions of tokens of text

  • No human could write rules for grammar, reasoning, knowledge
  • Must extract structure directly from data

Autonomous Vehicles: Safety-critical, must work across conditions

  • Rain, snow, night, construction zones
  • Can’t enumerate all scenarios manually

Common thread: We need methods that automatically find good solutions across diverse problems without requiring domain-specific engineering for each new task

What Do We Need From a Model Class?

Given this goal, what properties should our model class \(\mathcal{F}\) have?

Property 1: Should be able to capture complex, nonlinear relationships

  • Real-world functions are rarely simple linear mappings

Property 2: Should have a “complexity knob” we can tune

  • Trade off flexibility against overfitting
  • Let the data tell us how complex to be

Property 3: Should be able to fit any reasonable target function given enough capacity

  • Don’t want to limit ourselves by an arbitrary choice of function class

What Do We Need From a Model Class?

Property 3 has a name: Universal Approximation

Spoiler: Universal approximation tells us the answer is “in there somewhere”

It does not tell us we can find it with finite data

  • We can’t escape the curse of dimensionality…

Universal Approximation: Formal Definition

Definition: A class of functions \(\mathcal{F}\) is a universal approximator on a compact domain \(\mathcal{X} \subseteq \mathbb{R}^p\) if for any continuous function \(f^*: \mathcal{X} \to \mathbb{R}\) and any \(\epsilon > 0\), there exists \(f \in \mathcal{F}\) such that:

\[\sup_{x \in \mathcal{X}} |f(x) - f^*(x)| < \epsilon\]

In words: For any continuous target function and any desired precision, there exists a function in our class that gets uniformly close to the target everywhere on the domain.

Removing nerd speak: it can learn any function

Universal Approximation: Formal Definition

What this definition says:

  • The function class \(\mathcal{F}\) is “rich enough” to approximate anything continuous
  • The approximation is uniform — we can get close everywhere simultaneously
  • There are no “blind spots” where our function class fundamentally cannot reach

What this definition does NOT say:

  • Nothing about whether we can find the right \(f \in \mathcal{F}\) from data
  • Nothing about how many samples we need
  • Nothing about computational tractability
  • Nothing about what happens with noise

Formulation 1: Density in Function Space

\(\mathcal{F}\) is a universal approximator if it is dense in the space of continuous functions

Intuition: No matter what continuous function you pick, you can find members of \(\mathcal{F}\) arbitrarily close to it

There are no “gaps” in what \(\mathcal{F}\) can represent

  • Pick any target function
  • There’s always something in \(\mathcal{F}\) nearby
  • Get as close as you want by searching harder in \(\mathcal{F}\)

Formulation 2: The Complexity Path

A model class is a universal approximator if it admits a complexity path — a nested sequence:

\[\mathcal{F}_{\lambda_1} \subseteq \mathcal{F}_{\lambda_2} \subseteq \cdots \subseteq \mathcal{F}\]

such that:

  1. Base case: \(\mathcal{F}_{\lambda_1}\) contains simple functions (e.g., constants)

  2. Monotonic expressivity: Higher complexity \(\lambda\) = larger function class

  3. Limiting completeness: \(\bigcup_\lambda \mathcal{F}_\lambda\) is dense in continuous functions

Intuition: Universal approximators come with a “knob” we can turn from simple to arbitrarily complex

Formulation 3: The Interpolation View

For finite data \(\{(x_i, y_i)\}_{i=1}^n\) with distinct \(x_i\), a universal approximator can achieve:

\[\hat{f}(x_i) = y_i \quad \text{for all } i = 1, \ldots, n\]

That is: zero training error is always achievable with sufficient complexity

Often the most practically relevant formulation: “Can we at least fit the training data?”

Which Methods Are Universal Approximators?

What methods do you know that have this property?

Which Methods Are Universal Approximators?

Method Complexity Parameter How It Achieves Universality
Polynomial regression Degree \(d\) Stone-Weierstrass theorem
KNN \(1/K\) \(K=1\) interpolates
Decision trees Depth / leaves One leaf per point
Kernel methods (RBF) \(1/\lambda\) Kernel interpolation
Neural networks Width and/or depth Cybenko (1989), Hornik (1991)

Key Point: Universal approximation is NOT unique to neural networks!

The theorems for neural networks get all the attention, but this property is shared by many classical methods

Implication 1: Expressivity is Not the Bottleneck

If \(\mathcal{F}\) is a universal approximator, then the true function \(f^*\) (assuming it’s continuous) is in the closure of \(\mathcal{F}\)

What this means:

We’re not limiting ourselves by our choice of function class

The “right answer” is in there somewhere

What this doesn’t mean:

We can actually find it

Implication 2: Zero Training Error is Achievable

With sufficient complexity, we can always fit the training data perfectly

This sounds good:

If we can’t even fit the training data, we certainly can’t generalize

But it’s also dangerous:

Interpolating noisy data means memorizing noise

Zero training error \(\neq\) zero test error

Implication 3: We Can Recover the Truth…

Universal approximation combined with consistency results tells us:

\[\hat{f}_n \xrightarrow{P} f^* \quad \text{as } n \to \infty\]

What this says: With infinite data, we can recover the truth

What this leaves open:

  • How fast?
  • How does the rate depend on the problem?
  • What happens when \(n\) is finite (i.e., always)?

The Approximation Guarantee

What universal approximation gives us:

With enough data and capacity, this learner could learn the true function

This is a statement about existence

  • There exists a good approximation in our function class
  • The answer is “in there”

The Learning Problem

What we actually face:

Given finite, noisy samples \(\{(x_i, y_i)\}_{i=1}^n\) where \(y_i = f^*(x_i) + \epsilon_i\)

Find \(\hat{f} \in \mathcal{F}\) such that \(\hat{f} \approx f^*\)

The gap: Universal approximation tells us \(f^*\) can be approximated by some \(f \in \mathcal{F}\)

It does NOT tell us:

  1. Which \(f \in \mathcal{F}\) is the right one
  2. How to find that \(f\) from finite data
  3. How much data we need to find it reliably

The Bias-Variance Tradeoff

How do we navigate a universal approximator in practice?

We use the complexity path: tune from simple to complex

The fundamental tradeoff:

\[\text{True Risk} = \underbrace{\sigma^2}_{\text{Irreducible}} + \underbrace{\text{Bias}^2}_{\text{Approximation Error}} + \underbrace{\text{Variance}}_{\text{Estimation Error}}\]

How do each of these terms change as we increase the complexity of our models?

The Bias-Variance Tradeoff

Bias — decreases with complexity: \[\text{Bias}^2 = O\left(\lambda\right)\]

  • Simple models (small \(\lambda\)): Can’t capture the true function → high bias
  • Complex models (large \(\lambda\)): Can approximate \(f^*\) well → low bias

Variance — increases with complexity, decreases with sample size: \[\text{Variance} = O\left(\frac{\lambda}{N}\right)\]

  • More complexity → more parameters to estimate → higher variance
  • More samples → better estimates → lower variance
  • The ratio \(\lambda / N\) is what matters

The Bias-Variance Tradeoff

Cross-Validation Finds the Best on the Path

How do we find the optimal complexity \(\lambda^*\) in practice?

Cross-validation estimates the true risk at each complexity level:

\[\widehat{R}_{CV}(\lambda) \approx \text{True Risk}(\lambda)\]

CV then selects:

\[\hat{\lambda}_{CV} = \arg\min_\lambda \widehat{R}_{CV}(\lambda)\]

The guarantee: With enough data and folds, CV converges to the best complexity among models on the path

Cross-Validation Finds the Best on the Path

This is exactly what CV is supposed to do — and it does it well!

But there’s a critical assumption hidden here:

We’re assuming the path actually passes through a good region

What if the best model on the path is still bad?

When the Path Floats

The ideal scenario: Path dips close to optimal

CV finds the minimum, and it’s close to the best possible

When the Path Floats

The problematic scenario: Entire path floats high

CV finds the minimum of the path — but that minimum is still far from good

Why Does the Path Float?

Is it possible to know how far the path is going to float above the optimum?

  • What conditions do you think lead there to be a big gap between the “best” and the best?

Stone’s Minimax Theorem

Theorem (Stone, 1982): For nonparametric regression in \(\mathbb{R}^P\) with \(f^*\) having smoothness \(S\) (the number of continuous derivatives for the function):

\[ \inf_{\hat{f}} \sup_{f^* \in \mathcal{C}^s} \mathbb{E}\|\hat{f} - f^*\|^2 = \mathcal O\left(\frac{1}{N^{\frac{2S}{2S+P}}}\right) \]

What this says:

  • The \(\inf\) is over ALL possible estimators (best case over all possible learning methods)
  • The \(\sup\) is over all functions with smoothness \(s\) (worst possible true function of smoothness \(s\))
  • This is the best achievable rate — no method can do better

Stone’s Minimax Theorem

\[ \mathcal O\left(\frac{1}{N^{\frac{2S}{2S+P}}}\right) \]

Goal: Make as small as possible. What should we make big? What should we make small?

This is where dimension enters!

The effective “smoothness-to-complexity” ratio depends on:

  • \(S\): how smooth the true function is (fixed)
  • \(N\): how many training examples we have (fixed)
  • \(P\): the dimensionality of the feature space

The Curse of Dimensionality

\[\text{Optimal Rate} = O\left(N^{-\frac{2S}{2S+P}}\right)\]

As dimension \(P\) increases:

  • The exponent \(\frac{2S}{2S+P}\) gets smaller
  • The rate gets slower
  • We need more samples to achieve the same error
Dimension \(p\) Rate (with \(s=1\)) Samples for 1% error
1 \(N^{-2/3}\) ~\(10^{3}\)
5 \(N^{-2/7}\) ~\(10^{5}\)
10 \(N^{-1/6}\) ~\(10^{12}\)
50 \(N^{-1/26}\) ~\(10^{52}\)
100 \(N^{-1/51}\) ~\(10^{102}\)

The Curse of Dimensionality

Same sample size, vastly different achievable error rates

The Curse is Fundamental

Key insight: Stone’s theorem is a lower bound

This isn’t a statement about any particular method:

  • Not about KNN being bad
  • Not about trees being bad
  • Not about polynomials being bad

It says: No method can escape this rate

The curse of dimensionality is not a failure of our algorithms

It’s a fundamental property of high-dimensional learning problems

The Floating Path

\[R(\hat{f}_{\lambda^*}) = \sigma^2 + O\left(N^{-\frac{2S}{2S+P}}\right)\]

When \(P\) is small relative to \(N\):

  • The rate is fast (e.g., \(N^{-2/3}\) for \(p=1\))
  • The path dips close to \(\sigma^2\)
  • CV finds a good model

When \(P\) is large relative to \(N\):

  • The rate is glacially slow (e.g., \(N^{-1/51}\) for \(p=100\))
  • The path floats high above \(\sigma^2\)
  • CV finds the best on the path… which is still bad

The Floating Path

A truth:

No learning algorithm can beat this rate!

  • Most algorithms don’t even get close to this rate! It requires an essentially optimal learner to get there.

But, how bad can it really be?

  • You’ve seen methods work amazingly in some settings and return extremely low CV error

Different Problems, Different Performance

Different Problems, Different Performance

Loading CIFAR-10 dataset...
Dataset size: 50000 images
Image shape: 32×32×3 = 3,072 dimensions
Number of classes: 10

Dimensionality: 3,072 features (32×32×3 RGB pixels)
Training samples: 50000 images

Contender 1: Polynomial Regression

Suppose we have \(P\) features, we can implement a degree \(d\) polynomial in \(P\) dimensions with all interactions

\[ y = \beta_0 + \beta_1 x_1 + \beta_2 x_1^2 + \beta_3 x_2 + \beta_4 x_2^2 + ... \]

Stone-Weierstrass theorem proves that the path of \(d \in (0,1,2,...,\infty)\) is a universal approximator

  • Main gist: If I have \(N\) points, there is always some polynomial expansion that will have at least \(N\) terms and exactly interpolate the data

Even though polynomial regression has the universality property, why do you think that it is quickly going to crash and burn?

Contender 1: Polynomial Regression

The \(P\) to \(N\) ratio is going to get out of control very quickly!

For a degree \(d\) model with \(P\) features, there will be:

\[ \frac{(P + d)!}{P!d!} \]

parameters

Degree \(d\) \(P = 10\) \(P = 50\) \(P = 100\)
1 11 51 101
2 66 1,326 5,151
3 286 23,426 176,851
4 1,001 316,251 4,598,126

Contender 1: Polynomial Regression

I didn’t run this one for CIFAR because it quickly gets computationally unruly

This presents us with the main reason that we avoid explicitly parameterized models:

  • The number of coefficients needed to effectively capture nonlinearity and dependencies explodes quickly!

Note: Kernelized methods (like SVMs) get around this issue by using implicit representations of high degree feature spaces. However, they always have \(P = N\). With reasonable \(N\), the gap between the “best” and the best will be quite large. Also, a computational nightmare!

Contender 2: KNN

The Setup

For a test point, \(\mathbf x_0\), compute \(y_0\) as:

  • The average of the \(y_i\) associated with the \(K\) nearest \(\mathbf x_i\) in the training set (continuous outcomes)

  • The most common \(y_i\) associated with the \(K\) nearest \(\mathbf x_i\) in the training set (categorical outcomes)

Complexity Path

  • \(K = N\): Global mean/mode (max bias)
  • \(K = 1\): Interpolation (zero training error)

Choose \(K\) that minimizes CV error.

Contender 2: KNN

Why do you think that KNN is going to crash and burn as \(P\) gets larger?

Beyer et al, 1999: As \(P\) gets larger

\[ \frac{\max_{i,j} \|\mathbf x_i - \mathbf x_j\|}{\min_{i,j} \|\mathbf x_i - \mathbf x_j\|} \overset{P}{\longrightarrow} 1 \]

  • As \(P\) increases, every point has equal distance!

  • Nearest neighbor means very little

Contender 2: KNN

Contender 2: KNN

KNN quickly degrades in high dimensions

  • Performance is quite bad

  • Computational nightmare too

Contender 3: Trees

The Setup

Recursively partition feature space with axis-aligned splits

  • At each node, find the feature and threshold that best separates the data
  • Predict constant value (mean/mode) in each leaf

Complexity Path

  • Stump (depth 1): Single split (max bias)
  • Full tree: One leaf per observation (interpolation)

Choose depth/leaves that minimizes CV error

Contender 3: Trees

Why do you think that trees are going to crash and burn as \(P\) gets larger?

Axis-aligned splits are inefficient

  • To capture a diagonal boundary like \(x_1 = x_2\), need a “staircase” of splits
  • Number of splits grows exponentially with precision needed

High variance

  • Small changes in data → completely different tree structure
  • Greedy splitting amplifies noise

Contender 3: Trees

But wait — what about Random Forests and XGBoost?

These are the workhorses of modern ML on tabular data!

Random Forests (Bagging):

  • Train many trees on bootstrap samples
  • Average predictions → reduces variance

Gradient Boosting (XGBoost, LightGBM):

  • Sequentially fit trees to residuals
  • Each tree corrects errors of the ensemble

Do these escape the curse?

Contender 3: Trees

How ensembles help:

  • Variance reduction through averaging (RF) or gradual fitting (boosting)
  • Implicit regularization through randomization
  • Often the best “off-the-shelf” methods for tabular data

Why ensembles don’t fully escape the curse:

  • Still working in ambient dimension \(P\)
  • Each base learner still suffers from curse of dimensionality
  • Ensembling reduces variance but cannot reduce bias
  • Cannot overcome fundamental sample complexity requirements

Stone’s bound still applies — just with better constants

The Common Thread

All these methods share the same failure mode:

They work in the ambient feature space \(\mathbb{R}^P\)

  • KNN: Computes distances in \(\mathbb{R}^P\)
  • Trees: Partitions \(\mathbb{R}^P\) with axis-aligned splits
  • Ensembles: Aggregates over partitions of \(\mathbb{R}^P\)

They rely on locality in that space

  • Nearby points should have similar outputs
  • Can carve up space into meaningful regions

When \(P\) is large: Locality breaks down, and all methods struggle

The Problem is Not the Methods

Important reframe:

These methods aren’t bad — they’re doing exactly what they should!

  • KNN achieves near-optimal rates for its complexity class
  • Trees/forests are provably consistent
  • XGBoost is extremely well-engineered and consistently is the top performer on tabular data (even relatively high dimensional tabular data)

Stone’s theorem tells us: No method working in \(\mathbb{R}^P\) can do better than \(O(N^{-2S/(2S+P)})\)

The problem isn’t the algorithms

The problem is the feature space

Reframing the Problem

Reframing the Problem

Instead of trying to make our learning methods better in \(\mathbb R^P\), what if we focused on reducing \(P\)?

  • Decrease the dimensionality of the feature space

Do you know of any methods that try to do this in a principled way?

Reframing the Problem

Goal: Reduce the dimensionality of the feature space from \(P\) to \(K\) where \(K << P\).

But doesn’t that result in information loss?

Answer: It depends on whether or not the data has underlying structure

  • Specifically if it can be well represented by a lower dimensional structure.

Reframing the Problem

The Manifold Hypothesis: Real high-dimensional data doesn’t fill the ambient feature space!

Loading MNIST dataset...

MNIST images: 28×28 = 784 dimensions
Random images also: 784 dimensions
But only MNIST lives on a low-dimensional manifold!

Reframing the Problem

The Manifold Hypothesis: Real high-dimensional data doesn’t fill the ambient feature space!

  • Random words \(\neq\) sentences

  • Thousands of frequency bins, but random combinations aren’t speech

  • Thousands of genes, but cells occupy limited phenotypic states

Reframing the Problem

The Hypothesis:

High dimensional data lies on or near a low dimensional manifold \(\mathcal M^K\) embedded in \(\mathbb R^P\)

  • An object within the \(P\) space that locally looks like \(\mathbb R^K\)

Reframing the Problem

Reframing the Problem

How do we know that this is the case for images, text, and sound?

Loading MNIST dataset...

Reframing the Problem

Loading MNIST dataset...

Reframing the Problem

Compression is Possible!

  • JPEGs reduce image size by 10-20x with minimal loss

  • MP3 compresses audio dramatically

If we can compress, then we can represent the object in lower dimensional spaces

Reframing the Problem

Feature dependence is high

  • In images: the color of a nearby pixel is largely the same as its surrounding pixels (we’re smooth color collections, not chaos)

  • In text: word co-occurrences follow strong patterns

Reframing the Problem

Data Type Ambient Dimension \(P\) Estimated Intrinsic Dimension \(K\)
MNIST 784 ~10-15
CIFAR-10 3,072 ~20-30
ImageNet 150,528 ~40-50
Natural images (generic) varies ~100-200
English text (word embeddings) 50,000+ ~100-300

The gap between \(P\) and \(K\) is enormous!

Reframing the Problem

The methods aren’t bad…

  • We’re applying \(P\)-dimensional toolkits to a \(K\)-dimensional problem!

If data lies on \(\mathcal M^K \subset \mathbb R^P\):

  • There exists a mapping \(\phi\): \(\mathbb R^P \rightarrow \mathbb R^K\) that captures the manifold structure

Working in \(K\) space instead of \(P\) space drastically reduces the gap of our best learners to the optimal solution

Reframing the Problem

\[ \mathcal O\left(N^{- \frac{2s}{2s + k}}\right) \text{ vs. } \mathcal O\left(N^{- \frac{2s}{2s + P}}\right) \]

To get the interior to .1:

  • 30 dimensions requires 32k samples (CIFAR 10 has 60k!)

  • 3072 requires around \(10^{154}\)!!!!

One is achievable, the other is not.

Next Time

We have a candidate tool for learning a data optimal mapping from \(\mathbb R^P \rightarrow \mathbb R^K\) - PCA

  • Finds directions of max variance

  • Finds the best \(K\)-dimensional linear subspace

Good if our mapping can be linear

  • But this isn’t usually the case…

  • Learnable, non-linear projections are needed (a.k.a. neural networks)