  We derive high-probability finite-sample uniform rates of consistency for
$k$-NN regression that are optimal up to logarithmic factors under mild
assumptions. We moreover show that $k$-NN regression adapts to an unknown lower
intrinsic dimension automatically. We then apply the $k$-NN regression rates to
establish new results about estimating the level sets and global maxima of a
function from noisy observations.
