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

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

TL;DR

While Random Fourier Features (RFF) are a staple for scaling up kernel methods, this paper reveals a significant limitation: they fail to preserve kernel distances with small relative error for non-analytic kernels like the Laplacian. The authors provide a rigorous theoretical framework for when RFF works, improve bounds for kernel $k$-means, and introduce a novel, data-oblivious embedding specifically for Laplacian kernels that overcomes RFF's shortcomings.

What Problem Does This Paper Address?

Kernel methods are powerful because they implicitly map data into high-dimensional feature spaces where complex patterns become linear. However, calculating these mappings explicitly is computationally expensive ($O(n^2)$). Random Fourier Features (RFF) solved this by providing a low-dimensional, explicit approximation.

Most existing research on RFF focuses on additive error—ensuring the approximate distance is within a fixed constant of the true distance. But for many geometric algorithms (like $k$-means clustering or nearest neighbor search), we need relative error guarantees (e.g., being within 5% of the true distance). Relative error is much harder to maintain, especially when distances are small. This paper asks: When can RFF actually guarantee small relative error, and what do we do when it can't?

Methods

The authors employ a mix of high-level mathematical analysis and algorithmic design:

  • Moment Analysis: They use Taylor expansions and Cauchy’s integral formula for multivariate functions to bound the moments of RFF. This allows them to determine exactly how many dimensions are needed to keep the relative error in check.
  • Isometric Embedding: To handle the Laplacian kernel (which RFF fails to approximate well), they propose a new method. They leverage the fact that $\ell_1$ metrics can be embedded into squared $\ell_2$ metrics.
  • Algorithmic Efficiency (PRGs): A naive implementation of their Laplacian embedding would be too slow. To fix this, they use a binary tree construction combined with Nisan’s Pseudorandom Generator (PRG). This allows them to simulate the necessary randomness in poly-logarithmic space and time, making the method practical for large-scale data.

Datasets

The paper primarily uses simulated datasets to validate its theoretical findings:

  • Synthesized Gaussian Data: 100 points in 60 dimensions generated i.i.d. from a Gaussian distribution.
  • Benchmarks: They compare their methods against two "idealized" baselines:
  • SVD (Singular Value Decomposition): A proxy for the best possible Nyström-style (data-dependent) low-rank approximation.
  • JL (Johnson-Lindenstrauss): The gold standard for dimension reduction, applied directly to the high-dimensional feature space.

Key Insights and Ideas

  • The "Smoothness" Requirement: The biggest "aha" moment is that RFF's success for relative error depends on the kernel being analytic at the origin. Gaussian and Cauchy kernels are "smooth" (analytic), so RFF works beautifully. Laplacian kernels have a "kink" at the origin (they aren't differentiable there), which causes RFF's variance to explode relative to the distance.
  • Lower Bounds Matter: They prove a "hard" lower bound showing that for Laplacian kernels, RFF requires a massive number of dimensions—proportional to the data's range and resolution—to achieve constant relative error.
  • Data-Oblivious is Better: Unlike Nyström methods, which need to see the data to build a mapping, the authors' "New-Lap" method is data-oblivious. This makes it much more suitable for streaming data or distributed computing environments.
  • The Non-Differentiability Paradox: Their findings suggest that to preserve relative error for kernels like the Laplacian, the mapping function must be non-differentiable—a fundamental departure from the standard RFF approach.

Key Results

  • RFF Success: For analytic kernels, RFF achieves $\epsilon$-relative error using only $poly(\epsilon^{-1} \log n)$ dimensions.
  • Kernel $k$-means: They improved the dimension bound for kernel $k$-means to $poly(\epsilon^{-1} \log k)$, making the complexity independent of the number of data points $n$.
  • New-Lap Performance: In experiments on Laplacian kernels, their "New-Lap" method significantly outperformed SVD-based methods, which were "largely incapable" of preserving relative error. Their method performed nearly as well as the theoretically optimal (but computationally heavier) JL transform.

Limitations and Future Work

  • Bounded Data: The current "New-Lap" construction assumes data is $(\Delta, \rho)$-bounded (meaning it has a finite range and a minimum resolution). While this covers most digital data, extending this to unbounded settings is a theoretical challenge.
  • Implementation Complexity: Using Nisan’s PRG makes the algorithm theoretically efficient, but it is more complex to implement than standard RFF.
  • Broader Kernel Support: The paper focuses heavily on Gaussian and Laplacian kernels. Future work could explore how these relative error guarantees apply to a wider variety of shift-invariant kernels used in specialized domains.

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