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

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

Abstract

Random Fourier Features (RFF) are a cornerstone of scalable kernel methods, providing low-dimensional approximations of high-dimensional feature maps. While RFF is known to provide strong additive error guarantees, its ability to preserve relative error—essential for tasks like $k$-means clustering and nearest neighbor search—has remained poorly understood. This paper identifies a fundamental "analyticity gap": RFF achieves efficient relative error guarantees for kernels that are analytic at the origin (e.g., Gaussian), but fails for non-analytic kernels (e.g., Laplacian). To address this, we introduce "New-Lap," a novel data-oblivious dimension-reduction technique for Laplacian kernels that achieves relative error guarantees where standard RFF cannot.

Introduction

Kernel methods allow machine learning models to identify complex patterns by implicitly mapping data into high-dimensional feature spaces. However, the computational cost of $O(n^2)$ for $n$ data points often limits their scalability. Random Fourier Features (RFF) revolutionized this field by providing an explicit, low-dimensional mapping that approximates the kernel function.

Traditionally, RFF research has focused on additive error. However, many downstream applications, such as $k$-means clustering, require relative error guarantees to preserve the underlying geometry of the data, especially when distances between points are small. If the distance between two points is minimal, even a small additive error can result in a massive relative error, potentially distorting the results of sensitive algorithms. This paper investigates the conditions under which RFF can guarantee small relative error and proposes solutions for cases where it fails.

The Analyticity Gap

The core theoretical contribution of this work is the discovery that the smoothness of a kernel at the origin determines the success of RFF.

1. Success for Analytic Kernels

Using complex analysis—specifically Taylor expansions and Cauchy’s integral formula—the authors bound the moments of RFF. They prove that for any shift-invariant kernel that is analytic at the origin (such as the Gaussian kernel), RFF achieves $\epsilon$-relative error using only $poly(\epsilon^{-1} \log n)$ dimensions. This confirms that for smooth kernels, RFF is highly efficient for preserving relative distances.

2. Failure for Non-Analytic Kernels

Conversely, the authors establish a "no-go" theorem for kernels that are not differentiable at the origin, such as the Laplacian kernel ($K(x,y) = \exp(-\|x-y\|_1)$). For these kernels, RFF requires an impractical number of dimensions—$\Omega(poly(\Delta/\rho))$, where $\Delta/\rho$ represents the aspect ratio or precision of the dataset—to maintain a constant relative error. This variance explosion makes standard RFF unsuitable for Laplacian-based tasks requiring high precision.

The New-Lap Algorithm

To overcome the limitations of RFF on Laplacian kernels, the authors propose a multi-step, data-oblivious embedding called "New-Lap." This method bypasses the direct application of RFF to the Laplacian kernel through a sophisticated transformation process:

  1. Isometric Mapping: The $\ell_1$ metric space is mapped into a squared $\ell_2$ space isometrically.
  2. Gaussian Reduction: The Laplacian kernel problem is reduced to a Gaussian kernel problem within this new space.
  3. RFF Application: Standard RFF is then applied to the resulting Gaussian version, where it is known to be effective.
  4. Computational Efficiency: To ensure this mapping is computable in polynomial time relative to input precision, the authors utilize Pseudorandom Generators (PRGs), specifically Nisan’s PRG.

Unlike previous assumptions that Laplacian kernels might require data-dependent methods (like Nyström) for relative error, this work proves that a data-oblivious, randomized mapping is both possible and efficient.

Experimental Results

The authors evaluated their findings using a synthesized dataset of 100 points with 60 dimensions, generated i.i.d. from a Gaussian distribution. They compared RFF (on Gaussian kernels) and the New-Lap method (on Laplacian kernels) against the popular Nyström method and the theoretically optimal Johnson-Lindenstrauss (JL) transform.

Key findings include:

  • Relative Error Preservation: Both RFF (for analytic kernels) and New-Lap (for Laplacian kernels) significantly outperformed the Nyström method in preserving relative error.
  • Competitive Performance: The proposed methods performed as well as, and occasionally better than, the JL transform applied to explicit features, despite the JL transform being a theoretical benchmark for dimensionality reduction.
  • Scalability for Clustering: The paper demonstrates that for kernel $k$-means, the required dimension depends on the number of clusters ($k$) rather than the number of points ($n$), offering significant scalability benefits for massive datasets.

Limitations and Future Work

While the New-Lap algorithm provides a breakthrough for Laplacian kernels, it introduces a dependence on the "precision" of the input data ($\log \Delta/\rho$). Although this dependence is logarithmic and generally manageable, it is a constraint not found in standard RFF for Gaussian kernels.

Furthermore, while the Laplacian case is solved, a general framework for all non-analytic shift-invariant kernels remains an open challenge. Future research may also focus on hardware optimization; while RFF is prized for its simple "dot product and cosine" operations, the PRG-based constructions in New-Lap are more complex and may require specialized implementation to match the efficiency of standard RFF on modern GPUs.

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