# On k-nearest-neighbor regression in metric spaces

Researchers show when k-nearest-neighbor regression stays consistent in metric spaces

László Györfi, Vladimir G. Pestov, Harro Walk, Roi Weiss · arXiv · 2026-10-30

- **Problem** Stone's domination check is hard to verify for k-NN, because each query uses its own neighborhood. Separability alone does not guarantee mean squared consistency in general metric spaces.
- **Method** The authors track how neighbor selection reshapes the feature distribution, encoding it as a neighbor-selection density. They bound that density in L2 norms instead of checking Stone's domination directly.
- **Results** With a finite fourth response moment and finite F\_2, k-NN regression is mean squared consistent when k\_n tends to infinity and k\_n/n tends to zero. Sigma-finite Nagata dimension does not guarantee this for unbounded responses.

## Why ordinary k-NN can fail in metric spaces

Ordinary k-NN regression predicts at a query by averaging the responses of its k\_n nearest sample points. The open question is whether that average drives the mean integrated squared error to zero in a general separable metric space. Separability alone is not enough, because the rule can stay inconsistent on some feature laws in the infinite-dimensional Hilbert space ℓ2.

Those counterexamples use deterministic binary responses and hold for every sequence satisfying (3). Locality of the selected neighbors therefore does not settle estimation of an arbitrary measurable conditional mean. The failure is a property of this estimator, not an impossibility of learning in those spaces.

Stone's domination condition is the usual way to guarantee consistency of local averaging, because it limits how far the weights move the feature mass. For ordinary k-NN this check is harder, because every query uses its own neighborhood. The partition-based Proto-NN rule gets domination without any dimension bound. Its cell-average weights are zero on empty cells, which keeps the inequality intact even for unbounded regression.

Pointwise convergence of local averages does not by itself give convergence of the mean integrated squared error. For bounded responses with \|Y\| at most L, the bounded convergence theorem closes this gap. Stone's criterion in Theorem 1 covers this case through its domination condition (S) and the moment assumption E Y squared below infinity.

## Neighbor-selection densities as the key object

The key idea is to track where neighbor selection moves the feature distribution μ, and to encode that movement as a density f\_n relative to μ. The authors call this density the neighbor-selection density, because it describes which points get picked as neighbors. Each f\_n is the density of an observation chosen uniformly among the k\_n nearest neighbors of an independent query X.

The paper's question is whether a bound on these densities can replace the direct check of Stone's domination.

A point z is selected for a query x when at most k\_n − 1 of the other observations are closer to x. The probability of this event is written g\_n(x,z), and it is taken over the other sample points X\_2 to X\_n. Averaging g\_n over the query x and multiplying by n/k\_n gives f\_n. The factor n/k\_n reflects that exactly k\_n observations are selected, while each of the n sample indices contributes equally.

Ties have probability zero under the assumption (9), which the authors need for the exchangeability argument.

Lemma 1 turns the neighbor average of a nonnegative function φ into the integral of φ f\_n against μ. The density satisfies 0 ≤ f\_n ≤ n/k\_n and integrates to one against μ, so it is a genuine density. Under this identity, Stone's condition is equivalent to F\_∞ being finite, because a uniform bound on f\_n is exactly the domination inequality.

The same identity holds for signed functions in L1(μ), which the authors use in the proofs.

The mean integrated squared error splits into a noise term I\_{n,2} and an approximation term J\_{n,2}, with R\_{n,2} = I\_{n,2} + J\_{n,2}. The noise term equals A\_n(σ²) divided by k\_n, so the density decides which conditional variances get averaged. The factor 1/k\_n captures the averaging of independent response noise. Theorem 2 then turns these pieces into a criterion on the norms F\_p and D\_{q,2}.

## The quadratic criterion and its moment conditions

The quadratic criterion turns mean squared consistency into two norm conditions on the neighbor-selection density f\_n, one on its supremum and one on its scaled norms. The density norms are F\_p, the supremum of the p-norms of f\_n, and D\_{q,2}, the supremum of the q-norms of f\_n divided by k\_n. Theorem 2 says that, for 1 \< p ≤ q ≤ ∞ with F\_p finite, D\_{q,2} finite is necessary and sufficient for R\_{n,2} to tend to zero.

The required moments are m in L^{2p'} and σ² in L^{q'}, where p' and q' are the conjugate exponents.

For sufficiency, the authors split the conditional variance at a level L in (18), which bounds the noise by L over k\_n plus D\_{q,2} times the tail norm of σ² above L. Letting n grow and then L grow makes the noise vanish, so the variance moment needed depends on q. A larger q needs a weaker variance moment, but it demands a stronger density norm in exchange.

The approximation term is controlled by replacing m with a bounded Lipschitz function and using Hölder's inequality with F\_p.

The simplest case takes p = q = 2: if F\_2 is finite and E Y^4 is finite, then R\_{n,2} tends to zero. Conditional Jensen's inequality places m in L4 and σ² in L2, and those are the moments the criterion needs.

A second corollary keeps F\_2 finite and needs only a finite second moment, provided m is in L4. It then needs either an essentially bounded conditional variance or a finite value of sup over n of the ∞-norm of f\_n divided by k\_n. Additive noise with finite variance falls under the bounded-variance case, so no fourth moment of the noise is required.

## Fixed-mass neighborhoods and noiseless responses

A second route defines neighborhoods by fixed feature mass u rather than by a fixed radius. The fixed-mass density f\*\_u(z) is one over u times the μ-mass of query centres whose ball reaches z while holding at most u of the feature probability. Because H\_x(ρ(x,Z)) is uniform on \[0, 1\] when Z ∼ μ, Tonelli's theorem gives ∫ f\*\_u dμ = 1. The beta-mixture identity (21) writes f\_n as the expectation of f\*\_V, where V is beta-distributed with parameters k\_n + 1 and n − k\_n.

The authors check that the beta density of U\_n, rescaled by n/k\_n, equals the density of Beta(k\_n + 1, n − k\_n).

Under the fixed-mass condition (22), the authors bound the square integrals of f\*\_u uniformly for small u. Together with a bounded second-moment term for σ², this gives F\_2 ≤ M\_2 and a noise term of order M\_σ / k\_n. Condition (23) controls the noise through the fixed-mass weights of σ². If E Y^4 is finite, Cauchy–Schwarz gives the variance condition, so the same fixed-mass condition yields R\_{n,2} tending to zero for every law with E Y^4 finite.

Lemma 2 sandwiches f\_n between a quarter of f\*\_{k\_n/(2n)} and twice f\*\_{2k\_n/n} plus an exponentially small term. The lower bound holds for every n ≥ 2, while the upper bound needs 2k\_n \< n. The exponential term uses the constant c\_0 = 1 − log 2 in its bound. For Euclidean space, Lemma 3 bounds the fixed-mass densities uniformly by a constant γ\_d that depends only on d.

The proof covers the cone geometry and the radial initial segments, which bound the mass of the query centres.

For noiseless responses Y = m(X) with m in L4, the fixed-mass condition gives R\_{n,2} tending to zero without requiring k\_n to tend to infinity. Corollary 5 covers 1-NN and every other fixed number of neighbors, once n exceeds that number. The proof uses the bound on f\*\_u in L2 to get F\_2 ≤ M, and the law of large numbers to show locality when k\_n/n tends to zero.

The authors don't need k\_n to tend to infinity, because noiseless responses have no noise term to average away.

## Nagata dimension: when global geometry helps and when it fails

Nagata dimension is a covering property on balls centred in a subspace, and the global version applies one bound to balls of every radius. The subspace A has Nagata dimension at most δ in X on scale s when every finite family of closed balls with centres in A and radii below s admits a subfamily of multiplicity at most δ+1 that covers all the centres.

The global notion is written dim\_Nag(X), and a finite scale restricts the covering to small balls only. Because the multiplicity is counted throughout the ambient space X, an intrinsic dimension bound on A doesn't establish the required relative bound. A metric space is sigma-finite dimensional when it is a countable union of subspaces, each with finite Nagata dimension on some scale, and the scales may differ.

If the global dimension is at most δ, the covering count bounds each f\_n by δ+1, so Stone's condition holds with C = δ+1. The proof counts the selected observations: each retained ball contains the target Z\_j, so at most k(δ+1) observations are selected. That uniform bound F\_∞ ≤ δ+1 makes weak L2 consistency follow for every law with E Y² finite.

The compactness argument for the fixed-mass bound uses the same covering idea, applied to a countable dense subset of a compact set.

The porcupine is a countable bouquet of unit intervals, called spines, joined at a common root o. Two points on the same spine are at distance \|a−b\|, and on different spines at distance a+b. Mass p\_i = c/(i(log i)²) sits on spine i, with the constant c chosen so the masses sum to one. Each spine has Nagata dimension one relative to the whole space, yet the porcupine has infinite Nagata dimension at every positive scale.

The response is m(o) = 0 and m((i,a)) = \[log(e/a)\]^3, which has every finite moment. The averaged neighbor response A\_n(m) grows without bound as n grows, so the expected integrated error diverges for every finite moment order r. This one fixed law works for every sequence with k\_n/n tending to zero, and each fixed-n risk is finite.

The failure also appears on a closed subset X0 of the countable ℓ1 tree, which has finite Nagata dimension on scale 1/2. Distinct interval components are at distance at least one, so balls of radius below 1/2 stay inside one component. On this subset the hub and branches get masses, and the response is m = \[log(e/a)\]^3 on the hub segment, with m = 0 on far branches.

Even there, one fixed response with all finite moments makes the k-NN error diverge, so a finite dimension bound at one positive scale doesn't supply the density bounds.

## Smoothness gives rates

The generalized Lipschitz condition measures smoothness through feature mass rather than through the radius of a neighborhood. Here h is nondecreasing with h(0) = 0, and h(u) tends to zero as u goes to zero. The difference of m at two points x and z is bounded by h of the mass of the ball joining them, H\_x(ρ(x,z)). Because the condition uses mass, it doesn't need bounded feature support, which the authors contrast with the modified Lipschitz condition of Döring et al.

\[10\].

Proposition 2 assumes this condition together with conditional variance bounded by K almost everywhere. When g = h² is concave, the mean squared error is at most K over k\_n plus h evaluated at k\_n over (n + 1), squared. The proof splits the error into a noise part, bounded by K over k\_n, and an approximation part. For the approximation part, the probability integral transform makes the neighbor masses uniform order statistics, with mean k\_n over (n + 1).

Jensen's inequality for the neighbor average, followed by concavity of g, then gives the bound on the approximation error. Monotonicity of h lets the same bound be written with k\_n over n instead of k\_n over (n + 1).

For h(u) = c0 u^a with 0 \< a ≤ 1/2, the bound becomes K over k\_n plus c0 squared times (k\_n over (n + 1)) to the power 2a. Choosing k\_n of order n to the power 2a over (2a+1) gives a rate of order n to the minus 2a over (2a+1). On d-dimensional Euclidean space with a = 1/d and d ≥ 2, the order is n to the minus 2 over (d+2) under this mass-based smoothness condition.

The authors note that Euclidean geometry alone does not imply that smoothness condition.

## Limitations of the analysis and the counterexamples

The paper leaves several questions open, and its support is analytic: theorems, lemmas, corollaries and two counterexample constructions. Sigma-finite Nagata dimensionality is known to ensure universal consistency of k-NN classification, but the authors show it doesn't ensure mean squared consistency with unbounded responses. Their porcupine construction gives one fixed noiseless response with all finite moments whose mean squared error diverges for every sequence with k\_n/n tending to zero.

The finite-scale counterexample in Remark 1 shows that a dimension bound on balls of radius below one fixed scale doesn't rescue consistency either. The authors state that neither sigma-finite nor one-scale finite Nagata dimension guarantees the uniform L^p bounds on the densities.

The density analysis assumes distance ties have probability zero, which the paper builds into condition (9). Whether the fixed-mass condition (22) holds for specific functional-data laws is left open. The paper raises this question for continuous curves viewed as elements of L2(\[0,1\]), without answering it. The counterexamples don't use the fixed-mass condition, so they say nothing about whether (22) can hold on those spaces.

The rate result in Section 4 requires the generalized Lipschitz condition (25), which the authors don't derive from the metric alone. The paper says Euclidean geometry alone does not imply this smoothness condition. The rate example uses h(u) = c0 u^a with 0 \< a ≤ 1/2, which the authors state as a special case. For the Euclidean example with a = 1/d and d ≥ 2, the order is O(n^(-2/(d+2))) under the stated mass-based condition.

## Paper info

- **Authors**: László Györfi, Vladimir G. Pestov, Harro Walk, Roi Weiss
- **Venue**: arXiv · Preprint
- **First published**: 2026-10-30
- **Added**: 2026-11-7
- **Updated**: 2026-10-30
- **Version**: v1
- **arXiv**: 2610.41896
- **Category**: cs.LG
- **Original paper terms**: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
- **What we show**: Paper info, commentary and permitted figures from the original paper

[Original paper ↗](https://arxiv.org/abs/2610.41896v1) · [PDF ↗](https://arxiv.org/pdf/2610.41896v1)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Abstract

We study mean squared consistency of k-nearest-neighbor regression for metric space valued features. For a fixed feature distribution mu with atomless distance distributions, we describe how neighbor selection redistributes probability through the density of a uniformly chosen neighbor of an independent query. This gives separate conditions for the approximation error and the conditional response variance, and weakens Stone's domination condition when stronger response moments are available. In particular, when k\_n tends to infinity and k\_n/n tends to zero, a uniform L2(mu) bound on the selection densities suffices under a finite fourth response moment. We give a corresponding condition in terms of neighborhoods of fixed population mass and recover the Euclidean density bound. Finite global Nagata dimension gives Stone's domination. While sigma-finite Nagata dimensionality is known to ensure universal consistency of k-NN classification in complete separable spaces, we show that this is not the case for mean squared consistency with unbounded responses: we construct a space in this class on which one fixed noiseless response with all finite moments has diverging mean squared error.

## Quote from the paper

László Györfi, Vladimir G. Pestov, Harro Walk, Roi Weiss (2026). On k-nearest-neighbor regression in metric spaces. arXiv:2610.41896v1. https://arxiv.org/abs/2610.41896v1

**BibTeX**

```
@misc{gyrfi2026nearest,
  title = {{On k-nearest-neighbor regression in metric spaces}},
  author = {László Györfi and Vladimir G. Pestov and Harro Walk and Roi Weiss},
  year = {2026},
  eprint = {2610.41896},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2610.41896v1}
}
```

## Other paper commentary

- [How many sorted projections determine n points in k dimensions?](https://refivu.com/en/papers/56ddc92f-406c-48d0-903d-def2129a08e3-how-many-sorted-projections-determine-n-points-in.md)
- [A Reduction of Imitation Learning and Structured Prediction to No-Regret Online Learning](https://refivu.com/en/papers/08306129-4598-48b6-baf3-9d1af09e03a6-a-reduction-of-imitation-learning-and-structured-prediction.md)
- [NICE: Non-linear Independent Components Estimation](https://refivu.com/en/papers/f56da4f3-4308-4b66-a0bf-e0d6e495195a-nice-non-linear-independent-components-estimation.md)
- [Gaussian Error Linear Units (GELUs)](https://refivu.com/en/papers/264fd129-ba49-4e4c-ac1f-59466a4e43ea-gaussian-error-linear-units-gelus.md)
- [Towards Learning Universal, Regional, and Local Hydrological Behaviors via Machine-Learning Applied to Large-Sample Datasets](https://refivu.com/en/papers/c1ee1227-dd45-4aef-9943-a760b7a45dbc-towards-learning-universal-regional-and-local-hydrological.md)
- [The Look-Elsewhere Effect in Searches for New Physics: from Classical Methods to Machine Learning](https://refivu.com/en/papers/40749a33-958c-4352-8394-19db350aef80-the-look-elsewhere-effect-in-searches-for-new.md)
- [MemU-Bench: Benchmarking GUI Agents on Long-Horizon User Interactions](https://refivu.com/en/papers/04d81424-d9d1-4a88-8852-ad3790e5a7bd-memu-bench-benchmarking-gui-agents-on-long-horizon.md)
- [Unsatz: Evaluating Scientific Discovery Without a Given Ansatz](https://refivu.com/en/papers/b143d872-0d21-4ae2-af14-070fdb4b449f-unsatz-evaluating-scientific-discovery-without-a-given.md)
- [From Natural Images to Medical Scans: Transferability of Diffusion Models for Medical Image Generation](https://refivu.com/en/papers/1c7517ae-6cfe-4649-8d27-3bcb27c3fdd7-from-natural-images-to-medical-scans-transferability-of.md)
- [Reasoning-Trace Overflow in Code Generation: An Empirical Study of Explicit Reasoning Models](https://refivu.com/en/papers/341947d7-6234-48fc-bf19-74e8c2056166-reasoning-trace-overflow-in-code-generation-an-empirical.md)
- [A Circuit for In-Context Learning](https://refivu.com/en/papers/b4e6d6ca-00f5-4939-8c04-a01635eef882-a-circuit-for-in-context-learning.md)
- [From AutoResearch to Continual AutoResearch: Do Agents Learn Across Tasks?](https://refivu.com/en/papers/9dffba31-2edb-48c7-8770-8675f1f716c3-from-autoresearch-to-continual-autoresearch-do-agents-learn.md)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/b2afe947-e002-422f-aeb8-4b45afe4c8ac-on-k-nearest-neighbor-regression-in-metric-spaces)
