Contextual Bandits for Unbounded Context Distributions

Puning Zhao, Jiafei Wu, Zhe Liu, Huiwen Wu · DOI

Introduction

Nonparametric contextual bandits provide a robust framework for sequential decision-making where an agent learns to select actions (arms) based on observed features (contexts). While most existing theoretical work assumes that contexts are drawn from a bounded support, real-world data in domains like finance and healthcare often exhibit heavy-tailed distributions. In such cases, the probability of observing extreme contexts is non-negligible, leading to data sparsity in the "tails" of the distribution. This paper introduces an adaptive $k$-nearest neighbor (kNN) algorithm designed to achieve minimax optimal regret in these unbounded settings.

Addressing the Tail: Adaptive kNN-UCB

The primary challenge in unbounded context spaces is the simultaneous management of the exploration-exploitation and bias-variance tradeoffs across regions of varying data density. Standard algorithms with fixed smoothing parameters (like a fixed number of neighbors $k$) struggle: a large $k$ reduces variance in high-density regions but introduces significant bias in sparse regions where neighbors are far apart.

The proposed Adaptive kNN-UCB algorithm solves this by dynamically selecting $k$ for each new context $X_t$. By matching the estimated bias (derived from the distance to the $k$-th neighbor) with the estimated variance (proportional to $1/\sqrt{k}$), the algorithm "zooms in" on high-density data and "zooms out" in the tails. This local adaptation ensures that the reward estimates remain accurate regardless of where the context falls in the distribution.

Comparison of Adaptive kNN-UCB against various fixed-$k$ baselines over 5000 steps, illustrating the benefit of dynamic parameter selection.

Theoretical Optimality

A key contribution of this work is the establishment of a minimax lower bound for regret in the unbounded context setting. The authors prove that the Adaptive kNN-UCB algorithm achieves an expected regret of $\tilde{O}(T^{1-\min\{\frac{(\alpha+1)\beta}{\alpha+(d+2)\beta}, \beta\}})$, where $\beta$ characterizes the tail of the distribution. This rate matches the lower bound, demonstrating that the adaptive approach is theoretically optimal.

Empirical Evaluation

The effectiveness of the adaptive approach is validated through extensive simulations on synthetic distributions (Uniform, Gaussian, $t_4$, and Cauchy) and the MNIST handwritten digit dataset.

Cumulative regret across different context distributions. The adaptive method consistently outperforms baselines, especially in heavy-tailed scenarios like the Cauchy distribution.

As illustrated in the results, the adaptive method significantly outperforms non-adaptive baselines such as UCBogram and fixed-kNN variants. In heavy-tailed scenarios like the Cauchy distribution, where data sparsity is most acute, the adaptive algorithm's ability to reduce bias in the tails leads to a substantial reduction in cumulative regret. On the MNIST dataset, the algorithm successfully handles high-dimensional image contexts, further proving its practical utility.

Conclusion

This research breaks new ground by removing the restrictive assumption of bounded context support in nonparametric bandits. The Adaptive kNN-UCB algorithm provides a principled, data-driven way to handle heavy-tailed distributions, achieving both theoretical minimax optimality and superior empirical performance. Future work could explore extensions to more general smoothness classes or non-stationary environments.

Summary updated

Abstract

Nonparametric contextual bandit is an important model of sequential decision making problems. Under $\alpha$-Tsybakov margin condition, existing research has established a regret bound of $\tilde{O}\left(T^{1-\frac{\alpha+1}{d+2}}\right)$ for bounded supports. However, the optimal regret with unbounded contexts has not been analyzed. The challenge of solving contextual bandit problems with unbounded support is to achieve both exploration-exploitation tradeoff and bias-variance tradeoff simultaneously. In this paper, we solve the nonparametric contextual bandit problem with unbounded contexts. We propose two nearest neighbor methods combined with UCB exploration. The first method uses a fixed $k$. Our analysis shows that this method achieves minimax optimal regret under a weak margin condition and relatively light-tailed context distributions. The second method uses adaptive $k$. By a proper data-driven selection of $k$, this method achieves an expected regret of $\tilde{O}\left(T^{1-\frac{(\alpha+1)\beta}{\alpha+(d+2)\beta}}+T^{1-\beta}\right)$, in which $\beta$ is a parameter describing the tail strength. This bound matches the minimax lower bound up to logarithm factors, indicating that the second method is approximately optimal.
BibTeX
@inproceedings{zhao2025contextual,
  author = {Puning Zhao and Jiafei Wu and Zhe Liu and Huiwen Wu},
  title = {{Contextual Bandits for Unbounded Context Distributions}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=gGY9TNVYs3},
}
Figure