liveBook · Manning

Curse of dimensionality

As explained in Advanced Algorithms and Data Structures

The curse of dimensionality is the set of effects that make data analysis and algorithmic search increasingly difficult as the number of dimensions grows.

Suppose an image-search system represents each image as a point and uses a k-d tree to find similar images. As the number of dimensions grows, the tree’s nearest-neighbor search becomes exponentially more expensive. Around 30 dimensions, a k-d tree may offer no advantage over brute-force search. This deterioration is one form of the curse of dimensionality. section 10.1

The problem is not limited to tree traversal. Under certain data-distribution assumptions, distances become less useful for distinguishing neighbors: in sufficiently high dimensions, the ratio of nearest-neighbor to farthest-neighbor distance approaches 1. In k-means, this can make assignment to the nearest centroid inaccurate and slow convergence. DBSCAN faces a similar problem when it uses Euclidean distance. section 12.2.2 section 12.3.4

Why a spherical cluster can be a poor fit

Imagine data spread uniformly through a high-dimensional hypercube. A sphere small enough to fit inside the cube excludes most points; a sphere large enough to contain them wastes an amount of space that grows exponentially with dimension. Spherical cluster boundaries can therefore overlap substantially even when they appear to be a reasonable approximation at lower dimensions. section 12.2.2

Choose a response according to what the application can sacrifice:

  • For similarity search, project objects into fewer dimensions using PCA or a Discrete Fourier Transform, if the projection preserves enough distinguishing information. This is less effective for dynamic datasets. section 10.4.3
  • If exact matches are not essential, prune search branches more aggressively or stop when the current result is good enough. Both can speed queries at the cost of accuracy. section 10.4.3
  • For DBSCAN, consider a metric other than Euclidean distance; changing the metric does not remove the separate difficulty of choosing suitable ε and minPoints across varying densities. section 12.3.4

Tree design can mitigate, but not erase, the search problem. SS-trees use spherical bounding envelopes rather than the single-axis splits of k-d trees; R-trees use rectangular envelopes. Which envelope fits better depends on the data distribution. Even with a balanced k-d tree, the listed nearest-neighbor cost is O(2^k + log n) for n points in k dimensions, so increasing k can dominate the search cost. section 10.5.1

Table 10.1 Operations provided by k-d tree, and their cost on a balanced k-d tree with n elements (view table figure)

Operation

k-d tree

R-tree

SS-tree

Search

O(log(n))

O(n)

O(n)

Insert

O(log(n))

O(n)

O(n)

Remove

O(n1-1/k)a

O(n)

O(n)

nearestNeighbor

O(2k + log(n))a

O(n)

O(n)

pointsInRegion

O(n)

O(n)

O(n)

Compare the listed operation costs, particularly the dimension-dependent nearest-neighbor cost for a balanced k-d tree. section 10.5.1

How Advanced Algorithms and Data Structures covers it

How deep it goes
Explains search-cost growth and geometric and distance effects through examples, without deriving the high-dimensional distance result.
Examples
Uses high-dimensional hypercubes, spherical bounds, nearest-neighbor distances, and a tree-operation cost table.
What it assumes
Assumes familiarity with points, dimensions, distances, and the basic roles of search trees and clustering algorithms.
What you can do after
Evaluate/understand when to prefer approximate search, dimensionality reduction, or a different DBSCAN distance metric.
How it connects
Connects k-d trees, R-trees, SS-trees, nearest-neighbor search, k-means, DBSCAN, and dimensionality reduction.

Also explained in

Compare how 7 books explain curse of dimensionality →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Advanced Algorithms and Data Structures. The section links point to the parts of the book it draws on.