arXiv:2611.07209stat.MLNov 2026

Manuscript Offprint

arXiv:2611.07209

Task-Calibrated Random Features via Influence-Based Error Cancellation

Shinto Eguchi

Abstract

Random features approximate kernel integrals by Monte Carlo, yet only selected frequency-sampling errors affect a downstream task. We propose Task-Calibrated Random Features (TCRF), which balance frequency moments constructed from task-specific influence using weights shared across kernel entries. Closed-form weights coincide with classical minimum-distance calibration; the contribution is a reusable, task-derived calibration space. We show that first-order variance equals the residual variance after projection onto this space. For kernel ridge regression, complete cancellation yields a non-Gaussian second-order limit. For kernel Stein discrepancy, a subset identity and disjoint-block variance decomposition eliminate the linear component of pilot noise. Positive exponential-tilting weights preserve the positive-semidefinite feature representation and support higher feasible calibration ranks. Paired experiments show improved approximation to exact kernel ridge regression at larger frequency budgets and to the exact empirical Stein discrepancy under a fixed alternative, even after accounting for a frequency-equivalent pilot budget. Gains are smaller with cross-validated ridge, landmark pilots require conservative rank selection, and near the Stein null allocating the pilot budget to additional ordinary frequencies is preferable.

1 Introduction

Random Fourier features replace a shift-invariant kernel integral by a finite Monte Carlo average over sampled frequencies (Rahimi and Recht, 2007). Their computational appeal is clear, but the approximation error is not equally important in every direction. The error that propagates to a downstream task often occupies only a few of the directions in which a finite frequency sample deviates from its spectral law. This paper asks whether those task-relevant directions can be identified in advance and cancelled directly on the sampled frequencies, without changing the sampling distribution. The baseline construction uses a closed-form weight and no inner optimisation; a positive exponential-tilting extension is investigated separately.

Our point of departure is the estimated-sampler phenomenon of Henmi et al. (2007). There, even when the true sampling distribution of an importance sampler is known, re-estimating its nuisance parameter on the same Monte Carlo sample reduces the variance, because the score equation removes the component of the target fluctuation that lies in the score space. If the target fluctuation lies entirely in the span of the score, the first-order asymptotic variance is zero. We use this zero- and near-zero-variance geometry as a design principle for random features, but we do not estimate a sampler parameter. What we retain is the projection: the space onto which the Monte Carlo fluctuation is projected can be designed, and when it is designed from the downstream task it removes precisely the error that the task sees.

We propose Task-Calibrated Random Features (TCRF). Here calibration means exact moment balancing of the sampled frequencies, not probabilistic calibration of predictive probabilities. Given a few frequency functions with known mean zero, the closed-form version assigns each sampled frequency one weight, shared by all kernel entries and test points, so that the empirical moments vanish exactly. The weights require only a sample mean and covariance. The first-order error is the task fluctuation projected onto the orthogonal complement of the calibration space, so complete containment yields zero first-order variance and approximate containment yields near-zero variance. We also consider KL-based exponential tilting (ET), which maintains positive weights on feasible calibration problems and can enlarge the practically usable calibration space.

In kernel ridge regression the relevant frequency-wise quantity is the contribution of a single frequency to the prediction error, not the error of an isolated kernel entry. We construct a low-rank calibration space from the principal directions of this prediction influence, show that it minimises the residual variance at a given rank, and derive the second-order regime that remains when the first-order influence is cancelled completely: the error then decreases in inverse proportion to the number of frequencies, rather than its square root, and its limit is a signed quadratic form in Gaussian kernel errors. In the kernel Stein discrepancy the frequency integral is itself the computational target. A subset identity shows that the centred integrand of a random subset of the data recovers, in expectation, the full-data zero-variance direction up to a single isotropic scale term. Disjoint-block pilots remove the linear component of subset noise exactly; under a fixed alternative, the subset size required for fixed relative precision need not grow with the sample size, so the pilot cost scales linearly with that size.

The closed-form weights themselves are not new. They are exactly the minimum-distance calibration weights of the regression or generalised regression form of Deville and Särndal (1992), and for a scalar Monte Carlo target the TCRF estimator is algebraically identical to a same-sample regression control-variate estimator (Lavenberg et al., 1982; Nelson, 1990; Davidson and MacKinnon, 1992; Portier and Segers, 2019). Our contribution is to design the controls from downstream learning influence and to reuse the resulting common weights as a random-feature representation. When the selected weights are nonnegative, they can be absorbed into the feature coordinates, so the weighted kernel remains positive semidefinite with unit diagonal and the squared Stein discrepancy remains nonnegative. The ET extension enforces positive weights on feasible instances, at an additional numerical optimisation cost, and is therefore a complementary implementation rather than a change to the projection theorems. It is related to exponential-tilting calibration in survey sampling and entropy balancing in observational studies (Kim, 2010; Hainmueller, 2012), but balances sampled frequencies rather than survey or treatment groups. A generic signed correction applied after the fact need not preserve these structures, a representational issue already highlighted in the moment-matching literature (Shen et al., 2017).

A substantial literature reduces random-feature error by changing the frequency design. Moment matching removes low-order empirical frequency fluctuations (Shen et al., 2017); orthogonal random features replace independent Gaussian directions by suitably scaled orthogonal ones (Yu et al., 2016); and quasi-Monte Carlo constructions use low-discrepancy sequences (Yang et al., 2014; Huang et al., 2024). These methods improve the spectral design without using the downstream influence that is central here. Kernel quadrature and random feature expansions are linked by Bach (2017), and Rudi and Rosasco (2017) study learning guarantees for random features; our focus is conditional Monte Carlo error in a fixed downstream computation. A second line of work adapts the sampling distribution to the learning problem: Avron et al. (2017) analyse random features for kernel ridge regression through spectral approximation and leverage-based sampling, and Li et al. (2019) develop a unified risk analysis with a data-dependent scheme based on ridge leverage scores. These methods change which frequencies are sampled, whereas TCRF reweights a given frequency sample so as to annihilate selected task-relevant moments; the two approaches are complementary. On the downstream side, Yao et al. (2023) estimate how random-feature error propagates into particular learning tasks and use this information for adaptive computation; we instead cancel the first-order influence directly. For the Stein discrepancy, random-feature and importance-sampling approximations were studied by Huggins and Mackey (2018), while Jitkrittum et al. (2017) design features for a linear-time goodness-of-fit test. Our construction targets the frequency-integration error of the existing empirical discrepancy, rather than a new discrepancy or test.

The zero-variance principle has a broader history in variance-reduced Monte Carlo computation, including zero-variance estimators for quantum Monte Carlo and Markov chain Monte Carlo (Assaraf and Caffarel, 1999; Mira et al., 2013) and control-functionals integration (Oates et al., 2017). Those works modify an estimator for a specified integration target; our emphasis is on extracting a downstream learning influence to construct common frequency weights that retain the random-feature representation. Closely related frequency-adaptive approaches include data-driven Stein-effect shrinkage of Fourier-feature weights (Chang et al., 2017), data-dependent compression or selection of random features (Agrawal et al., 2019), and learning kernels through their random-feature distributions (Sinha and Duchi, 2016). Unlike these approaches, the central construction here imposes exact balance on prespecified, analytically centred task directions without learning a new spectral law; ET changes only the calibration divergence and finite-sample positive-weight implementation.

Section 2 recalls the estimated-sampler geometry and introduces the two downstream computations. Section 3 develops the closed-form calibration principle and presents two central results: the second-order limit for kernel ridge regression and the disjoint-block variance decomposition for the kernel Stein discrepancy. Section 4 reports paired Monte Carlo experiments, and Section 5 discusses the scope and limitations of the method. Additional proofs and derivations appear in the Appendix, while additional numerical results are given in Appendix D.

References (58)