On The Relative Error of Random Fourier Features for Preserving Kernel Distance

Kuan Cheng, Shaofeng H.-c. Jiang, Luojian Wei, Zhide Wei

Introduction

Kernel methods are a cornerstone of machine learning, enabling models to operate in high-dimensional feature spaces and capture complex, non-linear patterns. However, they suffer from a well-known scalability bottleneck: calculating the full kernel matrix requires $O(n^2)$ time and memory. The Random Fourier Features (RFF) method, introduced in Rahimi and Recht's seminal 2007 paper, elegantly addressed this by providing a low-dimensional "sketch" of the data.

While RFF has become a staple for approximating high-dimensional kernels, recent research reveals a significant blind spot. This paper demonstrates that RFF fails to preserve "kernel distance" with small relative error for non-analytic kernels, such as the widely used Laplacian kernel. To address this, the authors provide a rigorous theoretical framework defining exactly when RFF succeeds and introduce a novel, data-oblivious embedding that finally brings efficient relative-error guarantees to Laplacian kernels.

The Shortcoming of Additive Error

Most existing research on RFF focuses on additive error guarantees (e.g., ensuring $|K(x,y) - \hat{K}(x,y)| < \epsilon$). However, many downstream geometric algorithms—including $k$-means clustering, nearest neighbor search, and locality-sensitive hashing (LSH)—rely on the distance between points in the kernel space. For these algorithms to maintain their theoretical accuracy, they require relative error guarantees, not just additive ones.

This paper investigates whether RFF can provide these strict relative error guarantees. Surprisingly, for some of the most popular shift-invariant kernels, standard RFF falls short.

Theoretical Insights: Analyticity is the Deciding Factor

The authors utilize complex analysis (specifically Cauchy’s integral formula) and Taylor expansions to analyze the moments of RFF. Their key insight is the discovery that the smoothness of a kernel at its origin—its analyticity—determines RFF's success.

  • Analytic Kernels (e.g., Gaussian or Cauchy): The authors prove that for analytic shift-invariant kernels, RFF successfully preserves kernel distance with $\epsilon$-relative error using only $D \approx \epsilon^{-2} \log n$ dimensions. Furthermore, for specific applications like kernel $k$-means, the required dimension depends only on $\log k$ (the number of clusters) rather than $\log n$, making the method highly scalable for massive datasets.
  • Non-Analytic Kernels (e.g., Laplacian): If a kernel's derivative at zero is non-zero, RFF requires an impractically high number of dimensions to keep relative error low. Specifically, preserving constant relative error for the Laplacian kernel ($K(x,y) = \exp(-\|x-y\|_1)$) requires dimensions proportional to the dataset's "aspect ratio" ($\Delta/\rho$), which can be astronomically large. The authors note a fundamental rule: for a dimension-reduction mapping to work on non-analytic kernels, the mapping itself must be non-differentiable.

A Novel Algorithm for Laplacian Kernels

Because standard RFF fails for the non-analytic Laplacian kernel, the authors design a new "data-oblivious" embedding to bypass this limitation. Their innovative method involves:

  1. Embedding the $\ell_1$ metric into a squared $\ell_2$ space.
  2. Utilizing a binary tree structure to efficiently generate Gaussian random variables.
  3. Applying space-bounded Pseudo-Random Generators (PRGs) to reduce the computational complexity from being linear in the data's range to merely logarithmic.

Experimental Validation

While the paper is heavily theoretical, the authors validate their findings using synthesized datasets (100 points with 60 dimensions generated from a Gaussian distribution). They compare their new methods against the Johnson-Lindenstrauss (JL) transform (the gold standard for worst-case dimension reduction) and Singular Value Decomposition (SVD, acting as a proxy for Nyström methods).

In simulations, the authors' new Laplacian algorithm ("New-Lap") and RFF applied to Gaussian kernels performed as well as, or better than, the JL transform. Crucially, they significantly outperformed SVD/Nyström methods. The authors demonstrate that Nyström methods are largely incapable of preserving relative error because they frequently collapse small distances to zero.

Limitations and Future Work

The proposed solutions, while groundbreaking, come with a few limitations:

  • Input Precision Dependency: The complexity of the new Laplacian embedding depends on the precision of the input data ($\log(\Delta/\rho)$). Although this dependency is logarithmic, it still requires the dataset to be reasonably bounded.
  • Strictly Shift-Invariant: The current theoretical framework is focused entirely on shift-invariant kernels. Extending these relative error guarantees to non-shift-invariant kernels, such as Polynomial or Sigmoid kernels, remains an open challenge.
  • Real-World Benchmarks: The theoretical bounds are tight and simulation results are promising, but testing the "New-Lap" algorithm on large-scale, real-world genomic or imaging datasets—where Laplacian kernels are frequently deployed—is a necessary next step for practical adoption.

Summary updated

BibTeX
@inproceedings{cheng2023relative,
  author = {Kuan Cheng and Shaofeng H.-C. Jiang and Luojian Wei and Zhide Wei},
  title = {{On The Relative Error of Random Fourier Features for Preserving Kernel Distance}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=qs2YCziX2o-},
}
Figure