A Gaussian process (GP) is a regression model that predicts a value together with an error bar. Exact GPs cost cubic time in the number of training points, which makes them impractical for large datasets. The most scalable recent recipe sidesteps this by predicting each test point from only its few nearest training points. That recipe is only as good as its notion of "nearest," and today "nearest" means plain Euclidean distance or one global rescaling of the inputs. On data whose relevant directions change from region to region, such a single global distance, called a global metric, picks the wrong neighbors. Metric learning has long had tools for region-specific distances, but those tools stumble when distances from different regions must be compared. This note argues that nearest-neighbor GP prediction is the setting where that comparison problem mostly disappears. Every prediction only ever compares points inside one small neighborhood, so each prediction can use a single distance tied to its test point.
The second part of the proposal concerns what the distances are trained on. Current practice fits GP settings with one objective, a marginal likelihood computed on a random subsample, and then deploys a different predictor, the neighbor-restricted GP. We propose to train the local distances directly on the leave-one-out predictive score of the neighbor GP that will actually be used at test time. In two sentences: learn a smoothly varying family of distances, and have each test point pick its neighbors and compute its GP prediction in the distance attached to its own location. Fit that family by making the deployed nearest-neighbor predictor score well on held-out training points, not by a likelihood surrogate the predictor never uses.
Core Claim
The base method is GP Nearest Neighbors (GPnn), from Leveraging Locality and Robustness to Achieve Massively Scalable Gaussian Process Regression. GPnn estimates kernel hyperparameters on a small subsample and predicts each test point from its $m$ nearest training neighbors. It fits $1.6\times10^6$ points in about 30 seconds on a laptop, which the authors report as roughly $100\times$ faster than sparse and distributed GP baselines. The same authors note two weaknesses. Neighbor search degrades as input dimension grows, and calibration needs a post-hoc correction of the noise level. We claim that both weaknesses are largely a global-metric problem, and that the following model fixes them at close to GPnn's cost.
Each test point $x$ gets its own positive semidefinite matrix $$M(x)=\sum_{k=1}^{K} w_k(x)\,B_k,$$ where $B_1,\dots,B_K$ are a small shared set of learned low-rank "basis metrics" and $w_k(x)\ge 0$ are smooth, softmax-normalized weights over $K$ anchor locations. This parameterization comes from the basis-metric line of local metric learning, Kalousis et al. and Yeung et al.. Those papers blend a shared set of anchored metrics so that nearby points get similar distances.
The prediction at $x$ proceeds in two steps. First, it retrieves neighbors under the Mahalanobis distance defined by $M(x)$. Second, it runs an ordinary stationary GP on those $m$ neighbors with inputs transformed by $M(x)^{1/2}$, together with a local noise variance $\sigma^2(x)$ produced by a similar anchor blend.
This construction avoids the comparison gap without extra machinery. Weinberger et al. documented that gap: independent per-region metrics make cross-region distances ill-defined. In our model, every kernel matrix ever formed uses one metric, so it is a valid covariance by construction. We never need a globally consistent embedding. Coordinated Local Metric Learning (CLML) builds exactly such an embedding by lifting points into a space of dimension $K\times D$, where $D$ is the input dimension. Metric Learning as Convex Combinations of Local Models (C2LM) instead blends all $K$ local models for every pair of points. We need neither.
The training objective is the deployed score. Let $\hat p_{-i}$ denote the neighbor-GP predictive distribution for training point $x_i$, computed from its $m$ neighbors with $x_i$ itself excluded. We minimize $$\mathcal{L}(B,w,\sigma)=\frac{1}{|S|}\sum_{i\in S} s\big(\hat p_{-i},\,y_i\big),$$ where $S$ is a minibatch and $s$ is the evaluation score the user cares about. For a Gaussian predictive distribution, $s$ can be negative log likelihood (NLL), mean squared error (MSE), or the continuous ranked probability score (CRPS), a smooth score that rewards both accuracy and calibrated spread. Each term costs one $m\times m$ solve, so one step costs $O(|S|\,m^3)$ regardless of $n$.
The link to surrogate misalignment is direct. Approximation-Aware Bayesian Optimization showed that the standard training bound for sparse GPs, which rewards global posterior fidelity, wastes capacity relative to the downstream task. We apply the same diagnosis to hyperparameter and metric fitting in local GPs. GPnn itself fits by one objective and deploys another. Scalable Deep Basis Kernel Gaussian Processes (DBK) adds a warning: expressive low-rank kernels trained by marginal likelihood collapse to rank-1 solutions. That is a concrete reason not to train a flexible metric family by marginal likelihood.
Research Program
The build has three pieces.
The first is the parameterization. We use $K$ anchors placed by $k$-means, low-rank basis metrics $B_k=L_kL_k^\top$ with rank $r\ll D$, and anchor weights computed from a Gaussian softmax in a fixed low-dimensional projection. Anchor positions are refined jointly with the metrics. This addresses the fixed-partition limitation of both CLML and C2LM, which neither method optimizes end to end.
The second is neighbor search. Exact retrieval under a different metric for every query would be expensive. We therefore retrieve a candidate pool of $c\cdot m$ points from a single approximate nearest-neighbor index built on one shared low-rank projection, then re-rank the pool under $M(x)$. The index is rebuilt every few epochs, in the spirit of periodic hard-example mining. We will measure how often the re-ranked neighbor set differs from exact retrieval under $M(x)$, so that this approximation is quantified and not assumed away.
The third is analysis. The GPnn paper proves that its prediction error is asymptotically robust to kernel misspecification as $n\to\infty$. That result appears to argue against learning a metric at all, so we address it head on. The robustness concerns the kernel applied to a given neighbor set. A learned metric changes which points are neighbors, which matters at finite $n$ and high $D$, the regime the GPnn authors flag.
This leads to a falsifiable scaling prediction. At fixed dimension, the advantage of learned local metrics over GPnn should shrink as $n$ grows. At fixed $n$, it should grow with the gap between the ambient dimension and the local relevant dimension. We will also characterize the regularization needed on the anchor weights and noise field so that the leave-one-out objective does not overfit. Our starting point is the smoothness penalty C2LM uses, for which it proves generalization bounds via algorithmic robustness.
A secondary strand tests misalignment between scores. We will train with each of NLL, MSE, and CRPS and evaluate with all three, plus 90% interval coverage. The goal is to show whether the choice of training score matters for the local predictor, following the kind of cross-metric regret that Regret Analysis for Performance Metrics in Multi-Label Classification proves in the multi-label setting.
Baselines
The naive reference point is GPnn as published. It uses a stationary kernel with per-dimension length scales fit by marginal likelihood on a subsample, Euclidean neighbor retrieval, and its global post-hoc noise calibration. Both methods get the same $m$, the same subsample size for any likelihood-based fitting, and the same train/test splits. Beating it means lower test NLL and CRPS at matched or better MSE, with 90% interval coverage closer to nominal. The file gives GPnn's speed on HouseElectric, $1.6\times10^6$ points in about 30 seconds and roughly $100\times$ faster than sparse and distributed GPs. It reports no per-dataset MSE or NLL values: no reported result found on Lacuna for GPnn's scalar accuracy on individual UCI datasets. We will therefore rerun it ourselves.
The strongest existing method for heteroskedastic, non-stationary regression at this scale is DBK trained with its dPPGP objective. That objective targets the predictive distribution and adds trace regularization to prevent rank collapse. It is the closest competitor because it also learns a flexible, non-stationary covariance, also trains on a predictive objective, and scales linearly to about 100,000 points. The file reports improvements in MAE, NLL, CRPS, and coverage on UCI and on mobile-internet speed prediction, but no scalar values: no reported result found on Lacuna for DBK's numbers on any of these datasets. We will run DBK with its released settings where available. Its feature network gets a wall-clock and tuning budget equal to ours, with the same number of hyperparameter configurations searched for each method. Beating it means better NLL and CRPS on a majority of datasets at comparable training time, and in particular better behavior on the heteroskedastic mobile-internet data.
We also include a sparse variational GP, which uses a small set of learned "inducing points" to summarize the data and is trained by the standard evidence lower bound. It represents the default scalable GP and has the known over-smoothing failure.
Three ablations isolate our ingredients. The first is the key one: a single learned global low-rank metric trained with the identical leave-one-out objective. It tests whether locality matters or whether the training objective does all the work. The second keeps our local metric family but fits it by marginal likelihood on a subsample, as GPnn fits its hyperparameters. It isolates the effect of the objective. The third uses independent per-cluster metrics, where each test point takes its nearest anchor's metric with hard assignment and no blending. It tests whether smooth coordination matters when each prediction already uses a single metric. A further variant keeps GPnn's Euclidean neighbors but adds our local noise field. It tests whether local noise calibration alone explains the gains.
Why not just…?
Why not just learn one global metric, or a deep feature map, and run GPnn on it? This is the most serious threat. A deep network can warp space nonlinearly, and a global projection trained on the right objective may recover most of the benefit. There is evidence against it: CLML reported about 75% mean average precision versus about 68% for global LDML on LFW face retrieval, where LDML is a global metric learned with a logistic loss on labeled pairs. That comparison involves a different task and model, so it is not decisive here. Our first ablation settles the question directly. If the global leave-one-out metric matches the local one on the synthetic heterogeneous data and on UCI, we will report that the contribution is the objective, not locality, and narrow the claim accordingly.
Why not just calibrate noise locally and keep Euclidean neighbors? Much of GPnn's calibration trouble may be heteroskedastic noise, not wrong neighbors. The local-noise-only variant tests exactly this. We expect it to fix coverage but not MSE in high dimension, because it cannot change which points are neighbors. If it also closes the MSE gap, the metric component is unnecessary.
Why not just use a scalable global non-stationary GP such as DBK or a focused sparse GP? DBK already learns non-stationary structure. It pays with a feature network and a regularizer that exists specifically to prevent rank collapse. FocalBO, which weights its sparse-GP training loss toward one active search region, localizes around a single region of interest. That design fits optimization, not uniform-quality regression over all inputs. The head-to-head DBK comparison at equal budget decides this. The honest outcome may be that DBK wins on moderate-$n$ smooth problems while our method wins at million-point scale, where GPnn-style prediction is cheaper.
Proposed Experiments
The first check is a controlled synthetic study. Inputs have ambient dimension $D\in\{10,50,200\}$, and the data form regions in which the response depends on different low-dimensional subspaces with different noise levels. We sweep $n$ from $10^4$ to $10^6$. This directly tests the scaling prediction: the gain over GPnn should grow with $D$ and shrink with $n$. We will also report the fraction of neighbors that match the true within-region neighbors.
The second is the UCI regression suite used by GPnn and DBK: Kin40K, Protein, Poletele, Bike, Ctslice, Road3D, Song, and HouseElectric. We report MSE, NLL, CRPS, 90% coverage, training time, and per-query latency. Ctslice and Song are the high-dimensional cases where GPnn's authors expect degradation.
The third is the mobile-internet quality datasets for Georgia and New Mexico from DBK. They test heteroskedastic noise with real spatial structure.
The decisive checks are three. The local leave-one-out model must beat the global leave-one-out ablation on the synthetic heterogeneous data and on at least the high-dimensional UCI sets. The leave-one-out objective must beat marginal-likelihood fitting of the same local family. The whole pipeline must stay within a small constant factor of GPnn's wall-clock time on HouseElectric; we set the bar at 5×.
If locality helps only on synthetic data, the idea fails on real data and we will say so. If the objective helps but locality does not, the paper becomes a narrower, still useful result about aligning local-GP fitting with the deployed predictor.
References
- Leveraging Locality and Robustness to Achieve Massively Scalable Gaussian Process Regression
- Parametric Local Metric Learning for Nearest Neighbor Classification
- Locally Smooth Metric Learning with Application to Image Retrieval
- Fast solvers and efficient implementations for distance metric learning
- Coordinated Local Metric Learning
- Metric Learning as Convex Combinations of Local Models with Generalization Guarantees
- Approximation-Aware Bayesian Optimization
- Scalable Deep Basis Kernel Gaussian Processes
- Regret Analysis for Performance Metrics in Multi-Label Classification: The Case of Hamming and Subset Zero-One Loss
- Scalable Bayesian Optimization via Focalized Sparse Gaussian Processes