Previous: linear classifiers and SVMs · Course overview

Source: Lectures 17-23, pp. 63-90.

Part 3 showed that an SVM can work entirely through feature-space inner products. This part asks which functions represent such inner products, how they define spaces of predictors, and how the same kernels describe random functions. The course ends by calibrating prediction sets.

1. Kernels and their basic constructions

Lecture 17; pp. 63-65.

A real function is a positive semidefinite kernel if, for every finite collection , its Gram matrix

is symmetric and positive semidefinite: for every . The requirement concerns every finite collection, not just the current training sample.

Inner products define kernels

If , symmetry follows from the inner product. Moreover,

Thus every feature map supplies a valid kernel.

Closure properties

The lecture uses several ways to construct new kernels.

Nonnegative sums. If are kernels and , then is a kernel because

Scaling by a function. For any real function , the kernel has Gram matrix , where . Its quadratic form is .

Products. is also a kernel. On any finite sample, factor as Gram matrices of vectors . Then

which is itself a Gram matrix. This is the positive-semidefinite property of the entrywise product.

Pointwise limits. A finite pointwise limit of kernels is a kernel: each finite quadratic form is the limit of nonnegative quadratic forms.

Polynomial, exponential, and Gaussian examples

Start with . Products and nonnegative sums show that

are kernels. Taking the limit of Taylor polynomials gives

Now expand the squared distance:

For ,

The last factor is an exponential inner-product kernel, and the first two implement scaling by a function. This proves that the Gaussian/RBF kernel is valid.

2. Hilbert spaces and continuous evaluation

Lecture 18; pp. 66-68.

A Hilbert space is an inner-product vector space complete in its induced norm: every Cauchy sequence converges to an element of the space. Its inner product gives

The second inequality is Cauchy-Schwarz.

The lecture examples are:

  • , with .
  • , the sequences with , using the same infinite-sum inner product.
  • , square-integrable functions with . Its elements are equivalence classes up to equality almost everywhere.

A linear functional is continuous exactly when for some finite . Inner products with a fixed are continuous by Cauchy-Schwarz.

The Riesz representation theorem, stated in the lecture, says the converse: every continuous linear functional has a unique representation .

The reproducing property

An RKHS is a Hilbert space of actual functions on for which evaluation is continuous for every .

Riesz then gives an element satisfying

Take to get . Define

It is a kernel by the inner-product calculation above, and . Therefore

The kernel “reproduces” evaluation. In particular,

This is the link between controlling a function’s RKHS norm and controlling its predictions. Ordinary need not be an RKHS: changing a function at one point does not change its element, so point evaluation is not generally well-defined.

3. From a kernel back to its RKHS

Lectures 18-19; pp. 68-71.

The Moore-Aronszajn theorem states that every positive semidefinite kernel determines a unique RKHS with that reproducing kernel.

Start from finite linear combinations

and define

Positive semidefiniteness makes squared norms nonnegative. Identify any zero-norm representations, then complete this inner-product space. Evaluation is bounded because

so it extends continuously to the completion. This produces the RKHS.

This construction makes precise the infinite-sum notation in the PDF: membership and convergence are governed by the RKHS norm. An arbitrary formal infinite sum is not automatically a member.

Example 1: the Gaussian kernel

For , each Gaussian bump lies in the RKHS, as does any finite sum. For example,

has squared norm

The coefficients and pairwise kernel values determine its norm.

Example 2: derive the kernel

Consider absolutely continuous functions on with and , with

The derivative map identifies this space with , so it is complete. Also

Thus evaluation is continuous. To find its representer, rewrite

We need almost everywhere and . Integrating,

Substituting its derivative into the inner product verifies the reproducing identity.

4. Regularized ERM and the representer theorem

Lectures 19-20; pp. 71-74.

Let be the RKHS of . Consider

The PDF uses summed loss plus ; dividing its objective by gives . This multiplies the norm, unlike the soft-margin convention in Part 3 where multiplies the loss.

Since , squared-loss fitting is ridge regression on the canonical features . But may be infinite-dimensional.

Representer theorem and proof

If a minimizer exists, every minimizer has the form

Let and decompose

Because ,

Therefore for every training input: their empirical losses are identical. Pythagoras gives

If , removing it strictly reduces the penalty because . Hence no minimizer can have a nonzero perpendicular component, proving the theorem. This argument does not require convex loss, though convexity helps solve the resulting problem.

The finite coefficient problem

Set and . Then

The optimization therefore becomes

Infinite-dimensional learning has reduced to at most coefficients.

5. Kernel regression and classification losses

Lectures 19-20; pp. 73-76.

Kernel ridge regression

For squared loss, minimize

Since is symmetric,

Setting the gradient to zero gives

A solution is obtained by solving the linear system

This matrix is positive definite: for ,

Thus is valid even if is singular. It satisfies the stationarity equation, and convexity makes it optimal. Predict using .

Clarification of p. 73: the formula given there assumes invertible and simplifies to . The latter remains valid for singular . Coefficients can then have additional null-space representations, but the fitted RKHS function is unique.

Quantile regression

For , define the pinball loss

Why does it estimate a quantile? For fixed , consider , assuming integrability. For , the derivative with respect to is ; for , it is . At continuity points of the conditional distribution,

Thus the minimum occurs at the conditional -quantile. With atoms, the subgradient condition becomes .

Its regularized sample version is

The representer theorem applies as before.

Kernel logistic regression

For , use

Minimize the regularized objective to obtain a real score . Convert it to a hard prediction by its sign, or report the model probability

The lecture also describes drawing a random class using this probability. That is a randomized prediction rule, distinct from reporting the probability or thresholding it.

Kernel hinge loss and SVMs

For , regularized ERM becomes

Multiplying by gives norm penalty and loss coefficient , matching the soft-margin formulation. An unpenalized intercept can be added to match Part 3 exactly.

Squared, quantile, logistic, and hinge losses are convex in the score. Since is linear in and is positive semidefinite, all these coefficient problems are convex.

6. Stationary kernels and Bochner’s theorem

Lecture 20; pp. 76-77.

A stationary kernel depends only on displacement:

For a random frequency vector , its characteristic function is

If and have the same distribution, the imaginary sine terms cancel, giving .

To see positive semidefiniteness, for real coefficients ,

Bochner’s theorem gives the converse for continuous stationary positive semidefinite kernels: each nonzero real such kernel can be written

for a symmetric frequency distribution. The zero kernel is the trivial separate case. Continuity is needed in this statement.

The lecture’s examples

The rational quadratic family is

For , take logarithms: . Hence this family approaches as .

Another family is

At it is Gaussian; at it is exponential, corresponding to a Cauchy-type spectral distribution. The PDF also points to the Matérn family as further kernel examples, without deriving its formula.

7. Gaussian processes and covariance kernels

Lecture 21; pp. 78-81.

A Gaussian process is a collection of random variables indexed by inputs, , such that every finite collection is jointly Gaussian. For a zero-mean process with covariance function ,

A sample is therefore a random function. The covariance describes how its values vary together across inputs.

Covariance functions are kernels. Symmetry is immediate, and

Conversely, a positive semidefinite kernel defines compatible Gaussian distributions on finite input sets, and hence a Gaussian process. The lectures develop a spectral construction to explain how to sample one.

8. Mercer expansion: the spectral view of a kernel

Lecture 21; pp. 79-80.

Take a bounded continuous kernel on and a strictly positive probability density . Define an integral operator on :

This generalizes matrix-vector multiplication: the sum over a matrix column becomes an integral over . It is an integral operator, not generally a convolution.

The operator is bounded

If , Cauchy-Schwarz gives

Integrating over and using yields

Symmetry of makes self-adjoint; positive semidefiniteness makes it positive. Square integrability of also makes it compact. These are the operator counterparts of the finite-dimensional spectral setting.

Eigenfunctions replace eigenvectors

A symmetric positive semidefinite matrix has an expansion . The corresponding Mercer expansion is

The positive eigenvalues tend to zero if there are infinitely many. Zero-eigenvalue directions may be needed to complete a basis of , but contribute nothing to the kernel expansion. This avoids assuming that the positive eigenfunctions alone span the whole space.

The spectral series converges in ; the continuous representatives supplied by the Mercer setting give the pointwise kernel expansion, locally uniformly. The density determines the eigenfunctions and eigenvalues, even though the represented kernel is fixed.

Derive the coefficients

For fixed , boundedness gives . Expand it in the spectral basis:

Compute each coefficient:

Substitution yields the Mercer expansion. This calculation uses the inner product; the RKHS reproducing inner product is a different one.

The expansion also supplies an explicit feature map:

9. Karhunen-Loève expansion and sampling

Lectures 21-22; pp. 80-83.

Let be independent variables. Define

For a finite truncation, any finite set of values is a linear transformation of independent Gaussians, so it is jointly Gaussian. Moreover,

because the full diagonal sum equals . The finite-dimensional Gaussian vectors therefore have a mean-square limit.

The process has mean zero. Its covariance is

Only terms with survive because . This proves that the expansion produces the desired GP.

Method 1: truncate the expansion

Draw standard normals and use

The sampled function can be evaluated at any input. The cost is needing the eigenpairs and accepting the omitted spectral tail.

Method 2: sample on a finite input grid

Choose , form , and sample directly. For example, if , draw and set

Then and . This also works for singular . If is positive definite, a Cholesky factor gives .

This method needs no continuous-domain eigenfunctions. It produces values at the chosen grid points; interpolation is an additional approximation.

10. Work out the eigenpairs of

Lecture 22; pp. 83-84.

On with uniform measure,

For a positive eigenvalue , split the eigenvalue equation at :

Differentiate using the fundamental theorem of calculus and the product rule:

Differentiate again:

The original equation at gives , while the first derivative at gives .

Set . The differential equation has solution

The first boundary condition forces . The second gives . A nonzero eigenfunction requires

Finally,

so normalization gives

Correction to p. 84: the printed integer frequencies do not satisfy . The half-integer frequencies above follow from the lecture’s own boundary conditions.

Substituting these eigenpairs into the preceding expansion gives a GP with covariance , namely standard Brownian motion on .

11. Why the course looks beyond fixed kernels

Lecture 22; pp. 84-85.

Kernel learning with convex losses offers tractable convex objectives. Gaussian kernels also have a universal approximation property: on compact , their RKHS is dense in the continuous functions under the uniform norm.

This means that for continuous and every , some RKHS function satisfies

Existence says nothing by itself about how many basis functions or observations efficient learning needs.

The lecture illustrates the curse of dimensionality by the worst-case approximation scaling for a bounded smoothness class:

for derivatives of smoothness. A grid interpretation is that local error of order needs , while covering a -dimensional region needs about cells.

For , the illustration becomes . This is a worst-case approximation-complexity example, not a universal sample-size formula for every kernel or target.

Structure can change the problem. A compositional function may have the form

with further pairwise composition for larger . A deep network can represent that hierarchy directly, motivating the discussion of deep learning.

The PDF uses summation as a simple compositional example. Summation is also easy for a linear kernel, so this example alone does not establish a neural-network advantage. Efficiency depends on the target structure and the chosen model. Universal approximation is also distinct from universal statistical consistency.

12. Conformal prediction

Lecture 23; pp. 87-90.

So far a model predicts a value, label, or probability. We now ask for a set whose coverage has a finite-sample guarantee.

Step 1: fit using training data

Use any fitting method to obtain a predictor. For classification it can output real class scores; it need not output a hard label.

Keep a separate calibration sample . Fix both predictor and scoring rule before using it. Under the lecture’s assumption, training, calibration, and future test pairs are i.i.d.

Step 2: define a nonconformity score

Choose to be larger when outcome agrees less with the prediction. The lecture examples are:

For a strongly positive binary score, label has a small nonconformity score and label has a large one. The score need not be a calibrated probability.

Step 3: calibrate a threshold

Compute and sort

For target error level , define

The adjustment accounts for the future score as one more exchangeable observation. The infinite-threshold case completes the definition when the requested coverage exceeds what a finite calibration quantile can supply.

For and , , so use the 90th smallest calibration score.

Step 4: invert the score

Output

In classification, test each candidate class against the same threshold. Depending on scores, the set can be empty, contain one label, or contain several. Larger sets express less decisive predictions.

Regression with estimated quantiles

Fit lower and upper quantile functions , for example at levels and as in the PDF. Assume the initial bounds are ordered. Define

Because these scores are nonnegative, the calibrated is nonnegative. The condition is equivalent to the three inequalities

Rearranging the first two yields

Calibration therefore expands the initial interval by a common amount sufficient for the desired marginal coverage.

Derive the coverage guarantee

Condition on the fitted predictor and fixed score rule. The calibration scores and future true-label score

are exchangeable. If there are no ties, the future score’s rank among all scores is uniform on .

For , exactly when that rank is at most . Hence

With ties, imagine random tie-breaking only for the rank argument. Every rank-at-most- event is still accepted by the rule using , so ties can only increase coverage. If , the threshold is infinite and coverage is 1.

Since membership in is precisely ,

This is marginal coverage: it averages over calibration data and the new pair, conditional on model fitting under the i.i.d. setup. It is not a guarantee for every individual input or for every fixed calibration set.

Using calibration labels to fit or tune the score breaks this simple exchangeability argument. A poor model can still obtain valid coverage by producing large sets; coverage and informativeness are separate properties.