Optimal Transport in NN Methods
- Optimal Transport is a geometric framework that measures differences between distributions, enhancing nearest neighbor methods with deformation-aware metrics used in image analysis.
- It employs both discrete linear programming and PDE formulations to compute the Wasserstein distance, leading to improved classification accuracy as demonstrated on MNIST.
- The approach also facilitates the construction of adaptive neighborhood graphs through a quadratically-regularized optimization, outperforming traditional kNN methods in manifold learning.
Optimal transport (OT) provides a rigorous geometric framework for measuring differences between probability distributions, endowing nearest neighbor (NN) methods with a robust, deformation-aware notion of similarity. The use of OT, and specifically the Wasserstein distance, in NN-based algorithms has informed both classification (notably in image domains) and the construction of adaptive, sparse neighborhood graphs. These developments rely on both discrete linear programming and partial differential equation (PDE) formulations of OT, leading to metrics that account for spatial rearrangement of mass. This article examines the mathematical foundations, computational methodologies, and empirical performance of NN methods informed by optimal transport, describing their advantages over classical approaches and situating them in the context of recent academic work.
1. Mathematical Foundations of Optimal Transport for Nearest Neighbor Distances
Optimal transport-based NN methods adopt a cost-minimizing formulation to compare distributions (or images), replacing classical ℓ₂ or correlation-based metrics. In the classical discrete OT setting, given two histograms representing mass distributions over fixed supports (e.g., pixel centers for images), the Monge–Kantorovich problem seeks a transport plan such that the marginals match the input histograms: With squared-Euclidean costs , the primal linear program is
The LP dual introduces potentials with constraint .
The continuous counterpart, via the Monge–Ampère equation, interprets images as strictly positive probability densities , on and seeks a map pushing onto . The Monge–Ampère PDE reads: The -Wasserstein distance is then
This formulation results in a metric space over distributions, allowing for comparisons that respect underlying geometric distortions (Snow et al., 2018, Snow et al., 2016).
2. Embedding Wasserstein Distance into 1-Nearest Neighbor Classification
To employ OT in 1-NN classification, each sample (e.g., an image) is preprocessed into a normalized distribution (e.g., pixel intensities normalized to sum to 1, possibly regularized with a small constant to avoid zeros). For each test sample, the distance is computed between the query and all stored training samples—each distance corresponding to the cost of optimally rearranging the query's mass to match each training distribution.
For discrete measures, the process involves:
- Flattening each image to a probability vector .
- Forming the cost matrix .
- Solving the OT linear program (LP) or the Monge–Ampère PDE for each test/train pair.
- Assigning the test sample to the class of its transport-minimizing neighbor.
Naive computational cost is for train and pixels, motivating the use of specialized OT solvers or approximation heuristics (Snow et al., 2018, Snow et al., 2016). The PDE approach, leveraging Newton–Raphson methods with careful discretization, scaling as per pair, was empirically found practical for moderate resolutions.
3. Empirical Results and Geometric Advantages in Image Domains
Empirical evaluation on MNIST shows 1-NN classification with OT-based distances systematically outperforming conventional metrics. For example, with 210 training images (21 per digit), average 1-NN accuracy is approximately 81.4% for the discrete Kantorovich OT, 82.6% for the PDE OT, compared to 75.5% for Euclidean and 80.6% for Tangent Space distances (Snow et al., 2018, Snow et al., 2016). The improvement is especially pronounced in regimes with limited training data.
The Wasserstein metric penalizes mass displacement quadratically, conferring robustness to small image deformations (translations, thickness changes, fragmentation), which traditional distances exaggerate. NN boundaries under OT reflect the geometry of shape variations, leading to semantically meaningful decision regions that better respect inherent class structure in data manifolds.
4. OT-based Neighborhood Graph Construction and the Quadratically-Regularized Approach
Beyond pairwise classification, OT also informs the construction of adaptive neighborhood graphs. The quadratically-regularised OT (QOT) method formulates graph construction as a single-parameter optimization problem: subject to
The parameter interpolates between a trivial identity graph () and a fully connected uniform graph (), with moderate yielding adaptive sparsity. The unique KKT structure yields a closed-form thresholding: where is chosen so that row sums normalize to 1.
QOT graphs automatically adapt to local data density and noise, unlike NN or -neighborhood graphs, which require tuning additional parameters (Matsumoto et al., 2022). The semismooth Newton method enables efficient computation and exact sparsity in the edge matrix, favoring robust downstream learning tasks.
5. Comparisons with Classical Nearest Neighbor Approaches
Classical NN graphs connect each data point to its closest neighbors, irrespective of sampling density. In irregular or noisy datasets, this may induce spurious edges or oversmooth dense regions. -neighborhood graphs require precise tuning to avoid under- or over-connection. In contrast, QOT provides a principled, continuous interpolation—from highly localized to nearly all-to-all connectivity—through a single regularization parameter.
Empirical studies demonstrate that QOT graphs yield superior spectral embeddings in manifold learning, maintain local geometry under heteroskedastic noise, and outperform traditional graphs in semi-supervised learning scenarios (e.g., label propagation). In applications such as single-cell RNA sequencing, QOT enables high-quality imputations without the need for per-sample bandwidth tuning (Matsumoto et al., 2022).
6. Limitations, Computational Scalability, and Modeling Considerations
The main computational limitation of OT-based NN methods is the cost of solving high-dimensional transport problems, which, despite algorithmic advances (e.g., network-flow solvers, PDE accelerations), remains significantly higher than direct vector-based distances. PDE-based methods require careful numerical implementation, including the management of boundary conditions and tuning of damping parameters, and generally assume strictly positive density support. The absence of convergence guarantees for some solvers (such as for the Monge–Ampère PDE) is noted empirically rather than proven theoretically.
Approximate solvers, coarse-to-fine hierarchies, and restriction of admissible transport arcs offer avenues for further computational gains. Nonetheless, the modeling fidelity achieved by embedding OT geometry into nearest neighbor frameworks yields metrics and neighborhood structures with better invariance to nuisance variability and which more faithfully reflect latent data structure (Snow et al., 2018, Snow et al., 2016, Matsumoto et al., 2022).