Fit nonlinear response functions through a regularized kernel matrix. A two-observation example explains the coefficients, shrinkage and loss-normalization convention.
Kernel ridge regression
Kernel ridge regression (KRR) fits a response function by minimizing squared prediction errors plus a penalty on its size in a kernel-defined function space. It extends ridge regression to nonlinear relationships without explicitly building every transformed feature. A quant could use it to model execution cost from order size, spread and volatility; the kernel determines which combinations of those inputs the model treats as similar. Nonlinear flexibility does not itself establish predictive value. scikit-learn, §1.3
A fit expressed through training observations
Given training pairs (xi,yi), choose a real symmetric kernel k. It must generate a positive semidefinite matrix for every finite collection of inputs, not merely assign plausible similarity scores. Write Kij=k(xi,xj). This is the training Gram matrix; it can be rank deficient, for example when feature representations repeat. Rasmussen and Williams, §4.1
Let Hk be the kernel's reproducing kernel Hilbert space (RKHS): the function space with a norm compatible with evaluating functions through k. Here the objective is
The loss is an unaveraged sum and there is no separate unpenalized intercept. The norm measures function size according to the chosen kernel; it is not generally the squared Euclidean norm of the kernel coefficients. The representer theorem reduces the fit to
f(x)=i=1∑nαik(xi,x),(K+λIn)α=y.
For this representation, ∥f∥Hk2=α⊤Kα. Replacing that term by α⊤α changes the problem. A positive λ makes K+λIn positive definite even when K is singular. The displayed system gives a unique coefficient vector; for singular K, other coefficient representations can describe the same fitted function. Rasmussen and Williams, §§6.1–6.2.2
Check the normalization before copying a penalty setting. If the objective instead uses n−1∑i(yi−f(xi))2+λ∥f∥Hk2, its system is (K+nλIn)α=y. Keeping the same fit therefore requires dividing the unaveraged-loss penalty by n. Multiplying the entire objective by a constant changes no minimizer; scaling only one term does.
Two observations, one coupled solution
Take fictional, unitless responses and a valid kernel matrix:
K=(10.50.51),y=(10),λ=0.5.
Its eigenvalues are 1.5 and 0.5, both positive. One explicit feature construction is ϕ(x1)=(1,0)⊤ and ϕ(x2)=(0.5,0.75)⊤, using k(x,z)=ϕ(x)⊤ϕ(z). Their inner products reproduce K, so the example can also be checked by ordinary ridge regression in these two features.
The kernel system is
1.5α1+0.5α20.5α1+1.5α2=1,=0,α=(0.75−0.25).
The fitted training values are not the coefficients:
y=Kα=(0.75−0.1250.375−0.25)=(0.6250.125).
The negative second coefficient offsets the positive similarity between observations. These coefficients are not probabilities or portfolio weights. At a new input x∗, prediction requires its similarities to the training inputs: f(x∗)=k∗⊤α, where (k∗)i=k(xi,x∗). The training matrix alone does not specify every future prediction.
Fictional unitless responses 1 and 0 become fitted values 0.625 and 0.125 at penalty 0.5. Kernel eigenvalues 1.5 and 0.5 retain 75 percent of the common-response component and 50 percent of the contrast component.
Original deterministic example, with no separate intercept. The two observations are categories, not positions on a fitted curve. The right panel shows the fraction retained along each kernel eigenvector.
Why do the responses move this way? For an eigenvector of K with eigenvalue d, the training smoother K(K+λIn)−1 retains the fraction d/(d+λ) of that response component. Here the common direction (1,1)⊤ retains 75%, while the contrast direction (1,−1)⊤ retains 50%. Thus
y=0.5(11)+0.5(1−1)⟶y=0.375(11)+0.25(1−1).
This is joint regularization, rather than the normalized local average used in Nadaraya–Watson kernel regression. KRR need not have nonnegative response weights or weights summing to one. With no separate intercept, even a constant response component can shrink, as the common direction does here.
What a financial prediction still needs
For a distance-based kernel such as a radial basis function kernel, feature units and scale affect similarity. Fit preprocessing on each training fold, apply that fitted transformation to its validation data, and select kernel parameters and the penalty within the training portion of the evaluation design. Leave the final test period untouched by selection. These steps prevent the preprocessing and tuning forms of look-ahead bias. scikit-learn, §§12.1–12.2.1
For financial time series, preserve forecast chronology and ensure training labels are available at the forecast origin; overlapping future-return labels can require purging around validation boundaries. Use cross-validation that reflects the intended deployment. The small training calculation above measures neither future forecast error nor returns after trading costs.
KRR supplies a point prediction, not an uncertainty band. A zero-mean Gaussian process regression model has the same posterior mean when its covariance kernel matches k, its independent Gaussian observation-noise variance equals this unaveraged-loss λ, and the data transformations match. That correspondence does not establish calibrated uncertainty for actual market data. Rasmussen and Williams, §2.2, equations 2.25–2.27
For a dense exact implementation, storing the Gram matrix takes O(n2) memory and a standard factorization takes O(n3) work. Solve the regularized linear system, for example by Cholesky factorization, rather than explicitly forming an inverse. A new prediction generally uses all n kernel evaluations; this is not ordinarily a sparse model. Rasmussen and Williams, Algorithm 2.1, scikit-learn, §1.3