betaFeedback

WorksComputer Science

Reliable Risk Estimation with Kernel Mean Matching under Dependent Sampling

Abstract

Kernel Mean Matching (KMM) estimates risk under covariate shift by reweighting labelled source samples so that their kernel mean embedding matches that of unlabeled target samples. Existing finite-sample guarantees are usually stated for independent samples, although many applications involve temporal, spatial, or clustered dependence. We give a finite-sample KMM analysis under dependent sampling by replacing nominal sample sizes with effective sample sizes in the concentration steps used by the classical proof. The approach uses Bernstein inequalities for geometrically strongly mixing processes and derives a model-based effective sample size. The resulting bound separates overlap, dependence, and smoothness effects with specific constants derived under a Gaussian process assumption. This analysis yields an additional tradeoff: smoother losses preserve more input dependence and therefore reduce effective sample size, while also reducing function complexity and empirical-to-population risk gaps. Applying the result to prediction yields confidence intervals that achieve near-nominal coverage in synthetic experiments and substantially reduce undercoverage on real monitoring data.

Introduction

Machine learning models often face distribution shift: labelled training samples come from a source distribution, while predictions are required under a different target distribution. This mismatch complicates reliable evaluation, particularly in scientific domains where observations are collected along spatial transects, temporal monitoring campaigns, or clustered sampling schemes [21]. Specifically, under covariate shift, the conditional response law remains unchanged, while the marginal covariate distribution changes. In ecological and geospatial modelling, spatial transects and temporal monitoring campaigns produce structured observations, while uneven sampling may leave labelled source data systematically unrepresentative of the deployment region [10].

A standard approach to estimating target risk from labelled source samples and unlabelled target covariates is to reweight source losses by the ratio of target to source covariate densities [23, 25]. Estimating this ratio can be unstable when overlap is poor, source observations are sparse in high-ratio regions, or the ratio model is misspecified [11]. Kernel Mean Matching (KMM) provides an alternative to explicit density-ratio estimation: it computes source weights that align the empirical source and target kernel mean embeddings in a reproducing kernel Hilbert space (RKHS) [8, 7, 22].

Despite KMM’s practical success, its standard finite-sample theory relies on independent observations (Yu and Szepesvári, 2012). This assumption is routinely violated in real-world settings characterized by temporal persistence, spatial autocorrelation, environmental gradients, or cluster sampling. For these dependent regimes, treating the data as independent leads to overconfidence, as the nominal sample size substantially overstates the true amount of statistical information.

This paper develops a dependent-sampling foundation for KMM risk-estimation guarantees. The guiding principle of our approach is that the standard i.i.d. proof structure remains valid if standard concentration inequalities are replaced by their dependent counterparts, substituting the nominal sample size nn with an effective sample size neffn_{\mathrm{eff}}. Although neffn_{\mathrm{eff}} is a long-standing cornerstone for diagnosing correlation in Markov Chain Monte Carlo [9, 28], bounding weight degradation in importance sampling [13], and estimating spatial degrees of freedom [3], our work formally integrates this concept into non-parametric RKHS generalization bounds [6] for domain adaptation. This allows us to derive risk-estimation bounds under covariate shift and non-i.i.d. sampling that decompose the distinct roles of distribution overlap, data dependence, and function smoothness. Furthermore, our theoretical analysis reveals an important underlying tradeoff: smoother target or loss functions have lower statistical complexity, but when evaluated along a correlated covariate sequence, they preserve more dependence, which inherently reduces the effective sample size.

Specifically, our main contributions are as follows:

  1. We formulate an effective-concentration condition, based on a Bernstein inequality for strongly β\beta-mixing sequences, under which the classical finite-sample KMM guarantee naturally extends to dependent data.

  1. We explicitly decompose the generalization bottleneck into three components: independent noise, density-ratio overlap, and dependent sampling-sequence persistence.

  1. We characterize how covariate dependence and response smoothness determine effective sample size, deriving a closed-form GP-induced neffn_{\mathrm{eff}} that yields a practical dependence correction for KMM risk estimation.

  1. We validate the GP-induced effective-size mechanism in controlled synthetic experiments and evaluate the resulting confidence correction on three real-world monitoring datasets, where it consistently reduces empirical undercoverage relative to the i.i.d. interval.

Related Work

Kernel Mean Matching (KMM) was originally introduced as a non-parametric approach to correct for sample selection bias and covariate shift [8, 7]. More broadly, learning and evaluation under covariate shift are typically addressed via importance-weighted likelihoods, cross-validation schemes, and adapted risk estimators [23, 25, 11]. The foundational finite-sample analysis by Yu and Szepesvári (2012) demonstrates that KMM effectively bounds the target expectation error, provided the regression function lies within the RKHS and the source and target samples are independent. Our theoretical analysis adopts a similar proof structure but generalises it by replacing standard independent concentration steps with effective concentration inequalities for dependent data.

Dependence is ubiquitous in environmental and geospatial data, where nearby observations in space or time often carry substantially less independent information than their nominal sample size suggests. Ignoring this structure can lead to overly optimistic evaluation and confidence estimates, motivating dependence-aware validation and transfer procedures [21] (Koldsbasayeva and Zaytsev 2025). Recent work has also investigated KMM directly under spatial distribution shift, showing empirically that dependence and source–target mismatch can jointly affect transfer-risk estimation [22]. Our contribution complements this empirical line of work by providing a finite-sample analysis of how dependent sampling modifies the KMM risk-estimation guarantee and by making the resulting loss of information explicit through an effective sample size.

The dependent-data component of our framework builds upon concentration inequalities for strongly mixing processes [19, 20, 2], specifically leveraging a Bernstein bound for geometrically β\beta-mixing sequences [15]. We translate these bounds into an effective sample size (neffn_{\mathrm{eff}}) perspective, creating a bridge to other fields where data dependence is a central challenge. For instance, in Markov Chain Monte Carlo (MCMC), neffn_{\mathrm{eff}} is the canonical diagnostic for chain convergence [9, 28]. While the MCMC literature has explored multivariate ESS for finite-dimensional outputs [27], our work extends this concept by defining effective sample sizes for infinite-dimensional RKHS embeddings. Furthermore, KMM shares conceptual roots with Importance Sampling (IS), where weight degradation due to distribution discrepancy is actively quantified via ESS [13]; in our KMM bound, the domain overlap penalty BB formally captures this identical discrepancy bottleneck.

Finally, Gaussian-process models provide a convenient probabilistic framework for relating dependence in the inputs to dependence in a smooth response function [18, 24]. We use this connection to obtain an explicit, model-based effective sample size for KMM risk estimation. Rather than treating neffn_{\mathrm{eff}} as an abstract concentration parameter, the GP construction expresses it in terms of the correlation structure of the covariates and the smoothness scale of the response. This provides a practical link between the dependent-data concentration analy-

ReferenceSettingRelation to Ours
[8, 7]Covariate shift KMMIntroduces KMM objective
(Yu and Szepesvári, 2012)Finite-sample boundi.i.d. proof template
[21, 10]Spatio-temporal CVDependence motivation
[15]β\beta-mixing processesScalar concentration tools
This paperDependent KMMExplicit bounds via neffn_{\mathrm{eff}}

sis and the confidence correction evaluated in our experiments.

tbl:1 summarizes our positioning relative to this diverse theoretical landscape.

Theory

Problem Setup

Consider a labelled source sequence {(Xitr,Yitr)}i=1ntr\{(X_i^{\mathrm{tr}},Y_i^{\mathrm{tr}})\}_{i=1}^{n_{\mathrm{tr}}} with joint distribution PtrP_{\mathrm{tr}} over X×Y\mathcal{X}\times\mathcal{Y}, having covariate marginal PtrXP_{\mathrm{tr}}^{X}, and an unlabeled target sequence {Xjte}j=1nte\{X_j^{\mathrm{te}}\}_{j=1}^{n_{\mathrm{te}}} with marginal PteP_{\mathrm{te}} over X⊂Rd\mathcal{X}\subset\mathbb{R}^{d}. The covariate space X\mathcal{X} is compact and measurable, and responses are normalized to Y∈[0,1]Y\in[0,1].

Assumption 1 (Covariate Shift). The conditional response law is invariant across domains: Ptr(dy∣x)=Pte(dy∣x)P_{\mathrm{tr}}(dy\mid x)=P_{\mathrm{te}}(dy\mid x).

Under Assumption 1, we define the invariant regression function m(x):=E[Y∣X=x]m(x):=\mathbb{E}[Y\mid X=x]. Our objective is to estimate the target expectation μte:=EPte[Y]=∫Xm(x) Pte(dx)\mu_{\mathrm{te}}:=\mathbb{E}_{P_{\mathrm{te}}}[Y]=\int_{\mathcal{X}}m(x)\,P_{\mathrm{te}}(dx).

Assumption 2 (Conditionally Independent Residuals). Conditional on all observed covariates (Xtr,Xte)(X^{\mathrm{tr}},X^{\mathrm{te}}), the residual errors ϵi=Yitr−m(Xitr)\epsilon_i=Y_i^{\mathrm{tr}}-m(X_i^{\mathrm{tr}}) are mutually independent, mean-zero random variables.

Remark 1 (Scope of Residual Independence). Assumption 2 isolates the structural challenge of covariate shift from idiosyncratic label noise. It allows us to prove Theorem 1 at the nominal parametric rate. While this is a standard theoretical abstraction in non-parametric regression under dependent designs [2] (Yu and Szepesvári 2012), real-world spatial datasets may contain unobserved confounders causing the residuals to exhibit their own autocorrelation.

Assumption 3 (Bounded Density Ratio and Compact Support). The covariate space X⊂Rd\mathcal{X}\subset\mathbb{R}^{d} is compact and measurable. The derivative ω∗(x)=(dPte/dPtrX)(x)\omega^{*}(x)=\left(dP_{\mathrm{te}}/dP_{\mathrm{tr}}^{X}\right)(x) exists and satisfies 0≤ω∗(x)≤B<∞0\leq\omega^{*}(x)\leq B<\infty for all x∈Xx\in\mathcal{X}.

Assumption 4 (Moderate-Deviation Sample Size). For a given failure probability δ∈(0,1)\delta\in(0,1), the source sample size ntrn_{\mathrm{tr}} is sufficiently large relative to the sequence mixing rate to satisfy the moderate-deviation condition:

ntr(log⁡ntr)4≥B2K222K1σv,∞2log⁡6δ,(1)\frac{n_{\mathrm{tr}}}{(\log n_{\mathrm{tr}})^{4}}\geq\frac{B^{2}K_{2}^{2}}{2K_{1}\sigma_{v,\infty}^{2}}\log\frac{6}{\delta}, \tag*{(1)}

where K1,K2>0K_{1},K_{2}>0 and σv,∞2\sigma_{v,\infty}^{2} are defined in Appendix B.

Main Dependent KMM Bound

Kernel Mean Matching (KMM). Let H\mathcal{H} be an RKHS equipped with a feature map Φ:X→H\Phi:\mathcal{X}\to\mathcal{H}, and assume the features are uniformly bounded: sup⁡x∈X∥Φ(x)∥H≤C\sup_{x\in\mathcal{X}}\|\Phi(x)\|_{\mathcal{H}}\leq C. Rather than explicitly estimating ω∗(x)\omega^{*}(x), KMM [8] (Yu and Szepesvári 2012) computes weights w^=(w^1,…,w^ntr)T\widehat{\mathbf{w}}=(\widehat{w}_{1},\ldots,\widehat{w}_{n_{\mathrm{tr}}})^{\mathsf{T}} aligning the empirical RKHS means μ^Φtr(w):=1ntr∑i=1ntrwiΦ(Xitr)\widehat{\mu}_{\Phi}^{\mathrm{tr}}(\mathbf{w}):=\frac{1}{n_{\mathrm{tr}}}\sum_{i=1}^{n_{\mathrm{tr}}}w_i\Phi(X_i^{\mathrm{tr}}) and μ^Φte:=1nte∑j=1nteΦ(Xjte)\widehat{\mu}_{\Phi}^{\mathrm{te}}:=\frac{1}{n_{\mathrm{te}}}\sum_{j=1}^{n_{\mathrm{te}}}\Phi(X_j^{\mathrm{te}}):

w^=arg min⁡w∈[0,B]ntr∥μ^Φtr(w)−μ^Φte∥H.(2)\widehat{\mathbf{w}}=\underset{\mathbf{w}\in[0,B]^{n_{\mathrm{tr}}}}{\operatorname{arg\,min}}\left\|\widehat{\mu}_{\Phi}^{\mathrm{tr}}(\mathbf{w})-\widehat{\mu}_{\Phi}^{\mathrm{te}}\right\|_{\mathcal{H}}. \tag*{(2)}

The reweighted target mean estimator is then given by:

μ^KMM=1ntr∑i=1ntrw^iYitr.(3)\widehat{\mu}_{\mathrm{KMM}}=\frac{1}{n_{\mathrm{tr}}}\sum_{i=1}^{n_{\mathrm{tr}}}\widehat{w}_{i}Y_i^{\mathrm{tr}}. \tag*{(3)}

For YY being a loss function we obtain a risk estimate.

The classical KMM guarantee (Yu and Szepesvári, 2012) relies on Hoeffding bounds for independent samples. To adapt this to dependent sampling, we distill the Bernstein inequality for geometrically β\beta-mixing processes [15] into a deviation-independent effective sample size nefftrn_{\mathrm{eff}}^{\mathrm{tr}} (detailed in Appendix B). To control the empirical RKHS feature-matching error, we apply Berbee's coupling [1] and Pinelis' inequality [17] to derive a Hilbert-space concentration bound governed by a blocked effective sample size neff,RKHSn_{\mathrm{eff,RKHS}} (derived in Appendix C). As a result, we decompose the KMM target estimation error into three distinct operational components.

Theorem 1 (Non-Asymptotic Dependent KMM Bound). *Suppose Assumptions 1–3 hold, and Assumption 4 is satisfied for a given failure probability δ∈\delta\in

(0, 1). Assume the source and target covariate sequences are strictly stationary and geometrically β\beta-mixing. Let the invariant regression function satisfy m∈Hm \in\mathcal{H}, and let v(x)=ω∗(x)m(x)v(\mathbf{x}) = \omega^{*}(\mathbf{x})m(\mathbf{x}) have a long-run variance proxy σv,∞2\sigma^{2}_{v,\infty}.

Then, with probability at least 1−δ1-\delta:

∣μ^KMM−μte∣≤Blog⁡(6/δ)2ntr+Blog⁡(6/δ)2nefftr+O(∥m∥H(Bneff,RKHStr+1neff,RKHSte)),(4)\left|\hat{\mu}_{\mathrm{KMM}}-\mu_{\mathrm{te}}\right| \le B\sqrt{\frac{\log(6/\delta)}{2n_{\mathrm{tr}}}} + B\sqrt{\frac{\log(6/\delta)}{2n_{\mathrm{eff}}^{\mathrm{tr}}}} + \mathcal{O}\left(\lVert m\rVert_{\mathcal{H}}\left(\frac{B}{\sqrt{n_{\mathrm{eff,RKHS}}^{\mathrm{tr}}}}+\frac{1}{\sqrt{n_{\mathrm{eff,RKHS}}^{\mathrm{te}}}}\right)\right), \tag*{(4)}

where nefftrn_{\mathrm{eff}}^{\mathrm{tr}} is the scalar effective sample size evaluated for v(X)v(\mathbf{X}) derived in Appendix § 8. The quantities neff,RKHStrn_{\mathrm{eff,RKHS}}^{\mathrm{tr}} and neff,RKHSten_{\mathrm{eff,RKHS}}^{\mathrm{te}} scale as O(n/log⁡n)\mathcal{O}(n/\log n) and denote the RKHS effective sample sizes arising from the geometric blocking penalty. The exact non-asymptotic constants for EMMD\mathcal{E}_{\mathrm{MMD}} are detailed in Appendix § 10. If the sample size is too small to satisfy Assumption 4, the bound remains valid by substituting the deviation-dependent effective sample size nefftr(t)n_{\mathrm{eff}}^{\mathrm{tr}}(t) shown in Appendix § 8.

Interpretation and The Bottleneck of Dependence. Theorem 1 isolates the three fundamental challenges of risk estimation under covariate shift. This decomposition reveals how these error terms interact under strong data dependence (nefftr≪ntrn_{\mathrm{eff}}^{\mathrm{tr}} \ll n_{\mathrm{tr}}):

  1. Independent Noise (Enoise\mathcal{E}_{\mathrm{noise}}): From Assumption 2, the conditionally independent idiosyncratic label noise concentrates at nominal rate O(1/ntr)\mathcal{O}(1/\sqrt{n_{\mathrm{tr}}}). Under strong spatial or temporal dependence, this noise averages out rapidly and becomes statistically negligible compared to the other terms.

References

  1. [1]Berbee, H. C. P. (1979). Random walks with stationary increments and renewal theory. 112.
  2. [2]Bosq, D. (2012). Nonparametric statistics for stochastic processes: estimation and prediction. Springer Science & Business Media.
  3. [3]Bretherton, C. S., Widmann, M., Dymnikov, V. P., Wallace, J. M., and Bladé, I. (1999). The effective number of spatial degrees of freedom of a time-varying field. Journal of climate, 12(7):1990–2009.doi.org/10.1175/1520-0442(1999)012<1990:tenosd>2.0.co;2
  4. [4]Chen, S. (2017). Beijing Multi-Site Air Quality. UCI Machine Learning Repository. DOI: https://doi.org/10.24432/C5RK5G.
  5. [5]Gibbs, M. N. (1997). Bayesian gaussian processes for regression and classification.
  6. [6]Gretton, A., Borgwardt, K. M., Rasch, M. J., Schölkopf, B., and Smola, A. (2012). A kernel two-sample test. The journal of machine learning research, 13:723–773.DOI
  7. [7]Gretton, A., Smola, A., Huang, J., Schmittfull, M., Borgwardt, K., Schölkopf, B., et al. (2009). Covariate shift by kernel mean matching. Dataset shift in machine learning, 3(4):5.DOI
  8. [8]Huang, J., Gretton, A., Borgwardt, K., Schölkopf, B., and Smola, A. (2006). Correcting sample selection bias by unlabeled data. Advances in neural information processing systems, 19.DOI
  9. [9]Kass, R. E., Carlin, B. P., Gelman, A., and Neal, R. M. (1998). Markov chain monte carlo in practice: a roundtable discussion. The American Statistician, 52(2):93–100.DOI
  10. [10]Koldasbayeva, D. and Zaytsev, A. (2025). Foundation for unbiased cross-validation of spatio-temporal models for species distribution modeling. Ecological Informatics, page 103521.DOI
  11. [11]Kouw, W. M. and Loog, M. (2019). A review of domain adaptation without target labels. IEEE transactions on pattern analysis and machine intelligence, 43(3):766–785.DOI
  12. [12]Kuznetsov, V. and Mohri, M. (2015). Learning theory and algorithms for forecasting non-stationary time series. In Cortes, C., Lawrence, N., Lee, D., Sugiyama, M., and Garnett, R., editors, Advances in Neural Information Processing Systems, volume 28. Curran Associates, Inc.
  13. [13]Martino, L., Elvira, V., and Louzada, F. (2017). Effective sample size for importance sampling based on discrepancy measures. Signal Processing, 131:386–401.DOI
  14. [14]Menne, M. J., Durre, I., Vose, R. S., Gleason, B. E., and Houston, T. G. (2012). An overview of the global historical climatology network-daily database. Journal of atmospheric and oceanic technology, 29(7):897–910.DOI
  15. [15]Merlevède, F., Peligrad, M., and Rio, E. (2009). Bernstein inequality and moderate deviations under strong mixing conditions. In High dimensional probability V: the Luminy volume, volume 5, pages 273–293. Institute of Mathematical Statistics.
  16. [16]Mohri, M. and Rostamizadeh, A. (2008). Rademacher complexity bounds for non-i.i.d. processes. In Koller, D., Schuurmans, D., Bengio, Y., and Bottou, L., editors, Advances in Neural Information Processing Systems, volume 21. Curran Associates, Inc.
  17. [17]Pinelis, I. (1994). Optimum bounds for the distributions of martingales in banach spaces. The Annals of Probability, pages 1679–1706.arxiv.org/abs/1208.2200
  18. [18]Rasmussen, C. E. (2003). Gaussian processes in machine learning. In Summer school on machine learning, pages 63–71. Springer.DOI
  19. [19]Rio, E. (1993). Covariance inequalities for strongly mixing processes. In Annales de l’IHP Probabilités et statistiques, volume 29, pages 587–597.
  20. [20]Rio, E. (1999). Théorie asymptotique du processus aléatoires faiblement dépendants, volume 31. Springer Science & Business Media.
  21. [21]Roberts, D. R., Bahn, V., Ciuti, S., Boyce, M. S., Elith, J., Guillera-Arroita, G., Hauenstein, S., Lahoz-Monfort, J. J., Schröder, B., Thuiller, W., et al. (2017). Cross-validation strategies for data with temporal, spatial, hierarchical, or phylogenetic structure. Ecography, 40(8):913–929.DOI
  22. [22]Serov, E., Koldasbayeva, D., and Zaytsev, A. (2026). Kernel mean matching enhances risk estimation under spatial distribution shifts. Scientific Reports, 16(1):6921.DOI
  23. [23]Shimodaira, H. (2000). Improving predictive inference under covariate shift by weighting the log-likelihood function. Journal of statistical planning and inference, 90(2):227–244.
  24. [24]Srinivas, N., Krause, A., Kakade, S. M., and Seeger, M. (2009). Gaussian process optimization in the bandit setting: No regret and experimental design. arXiv preprint arXiv:0912.3995.DOI
  25. [25]Sugiyama, M., Krauledat, M., and Müller, K.-R. (2007). Covariate shift adaptation by importance weighted cross validation. Journal of Machine Learning Research, 8(5).
  26. [27]Vats, D., Flegal, J. M., and Jones, G. L. (2019). Multivariate output analysis for markov chain monte carlo. Biometrika, 106(2):321–337.arxiv.org/abs/1512.07713
  27. [28]Vehtari, A., Gelman, A., Simpson, D., Carpenter, B., and Bürkn er, P. (2019). Rank-normalization, folding, and localization: An improved r-hat for assessing convergence of mcmc. arxiv preprint arxiv: 190308008.DOI
  28. [29]Winkler, R. L. (1972). A decision-theoretic approach to interval estimation. Journal of the American Statistical Association, 67(337):220–225.DOI

Paper details

vlnc:W_8zf8phku
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 1

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

generative AI tools

View statement
Looking for related papers…
Contents