{'fraction_non_alphanumeric': 0.04485355192744999, 'fraction_numerical': 0.01004915644276202, 'mean_word_length': 4.051588939331407, 'pattern_counts': {'":': 0, '<': 2, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 25, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Kernel Methods for Surrogate Modeling

This chapter deals with kernel methods as a special class of techniques for surrogate modeling. Kernel methods have proven to be efficient in machine learning, pattern recognition and signal analysis due to their flexibility, excellent experimental performance and elegant functional analytic background. These data-based techniques provide so called kernel expansions, i.e., linear combinations of kernel functions which are generated from given input-output point samples that may be arbitrarily scattered. In particular, these techniques are meshless, do not require or depend on a grid, hence are less prone to the curse of dimensionality, even for high-dimensional problems. In contrast to projection-based model reduction, we do not necessarily assume a high-dimensional model, but a general function that models input-output behavior within some simulation context. This could be some micro-model in a multiscale-simulation, some submodel in a coupled system, some initialization function for solvers, coefficient function in PDEs, etc. First, kernel surrogates can be useful if the input-output function is expensive to evaluate, e.g. is a result of a finite element simulation. Here, acceleration can be obtained by sparse kernel expansions. Second, if a function is available only via measurements or a few function evaluation samples, kernel approximation techniques can provide function surrogates that allow global evaluation. We present some important kernel approximation techniques, which are kernel interpolation, greedy kernel approximation and support vector regression. Pseudo-code is provided for ease of reproducibility. In order to illustrate the main features, commonalities and differences, we compare these techniques on a real-world application. The experiments clearly indicate the enormous acceleration potential


Introduction
This chapter deals with kernel methods as tools to construct surrogate models of arbitrary functions, given a finite set of arbitrary samples.
These methods generate approximants based solely on input-output pairs of the unknown function, without geometrical constraints on the sample locations. In particular, the surrogates do not necessarily depend on the knowledge of an high-dimensional model but only on its observed input-output behavior at the sample sites, and they can be applied on arbitrarily scattered points in high dimension.
These features are particularly useful when these methods are applied within some simulation context. For example, kernel surrogates can be useful if the input-output function is expensive to evaluate, e.g. is a result of a finite element simulation. Here, acceleration can be obtained by sparse kernel expansions. Moreover, if a function is available only via measurements or a few function evaluation samples, kernel approximation techniques can provide function surrogates that allow global evaluation.
Kernel methods are used with much success in Model Order Reduction, and far beyond the scope of this chapter. For example, they have been used in the modeling of geometry transformations and mesh coupling [3,12,13], and in mesh repair methods [33], or in the approximation of stability factors and error indicators [14,32,34], where only a few samples of the exact indicators are sufficient to construct an efficient surrogate to be used in the online phase. Moreover, kernel methods have been combined with projection based MOR methods, e.g. to obtain simulation-based classification [60], or to derive multifidelity Monte Carlo approximations [40]. Kernel surrogates have been employed in optimal control problems [51,59], in the coupling of multi-scale simulations in biomechanics [25,69], in real time prediction for parameter identification and state estimation in biomechanical systems [29], in gas transport problems [22], in the reconstruction of potential energy surfaces [30], in the forecasting of time stepping methods [6], in the reduction of nonlinear dynamical systems [67], in uncertainty quantification [28], and for nonlinear balanced truncation of dynamical systems [5].
In further generality, there exists many kernel-based algorithms and application fields that we do not address here. Mainly, we mention the solution of PDEs, in which several approaches have emerged in the last years, and which particularly allow to solve problems with unstructured grids on general geometries, including high dimensional manifolds (see e.g. [11,17]). Moreover, several other techniques are studied within Machine Learning, such as classification, density estimation, novelty detection or feature extraction (see e.g. [53,54]).
Furthermore, we remark that these methods are members of the larger class of machine learning and approximation techniques, which are generally suitable to construct models based on samples to make prediction on new inputs. These models are usually referred to as surrogates when they are then used as replacements of the model that generated the data, as they are able to provide an accurate and faster response. Some examples of these techniques are clas-sical approximation methods such as polynomial interpolation, which are used in this context especially in combination with sparse grids to deal with highdimensional problems (see [19]), and (deep) neural network models. The latter in particular have seen a huge increase in analysis and application in the recent years. For a recent treatment of deep learning, we refer e.g. to [21].
Despite these very diverse applications and methodologies, kernel methods can be analyzed to some extent in the common framework of Reproducing Kernel Hilbert spaces and, although the focus of this chapter will be on the construction of sparse surrogate models, parts of the following discussion can be the starting point for the analysis of other techniques.
In general terms, kernel methods can be viewed as nonlinear versions of linear algorithms. As an example, assume to have some set X n := {x k } n k=1 ⊂ R d of data points and target data values Y n := {y k } n k=1 ⊂ R. We can construct a surrogate s : R d → R that predicts new data via linear regression, i.e., find w ∈ R d s.t. s(x) := w, x , where ·, · is the scalar product in R d . A good surrogate model s will give predictions such that |s(x k ) − y k | is small. If we can write w ∈ R d as w = n j=1 α j x j for a set of coefficients (α i ) n i=1 ∈ R n , then s can be rewritten as Note that this formulation includes also regression with an offset (or bias) b = 0, which can be written in this form by an extended representation as s(x) := w, x + b =: w,x , wherex := (x, 1) T ∈ R d+1 andw := (w, b) T ∈ R d+1 .
Using now the Gramian matrix A ∈ R n×n with entries A ij := x i , x j and rows A T i ∈ R n , we look for the surrogate s which minimizes Additionally, a regularization term can be added to keep the norm of α small, e.g. in terms of the value α T Aα. Thus, the surrogate can be characterized as the solution of the optimization problem min α∈R n Aα − y 2 2 + λα T Aα, i.e., α = (A + λI) −1 y if λ > 0. In many cases this (regularized) linear regression is not sufficient to obtain a good surrogate. A possible idea is to try to combine this linear, simple method with a nonlinear function which maps the data to a higher dimensional space, where the hope is that the image of the data can be processed linearly. For this we consider a so-called feature map Φ : R d → H, where H is a Hilbert space, and apply the same algorithm to the transformed data Φ(X n ) := {Φ(x i )} n i=1 with the same values Y n . Since the algorithm depends on X n only via the Gramian A, it is sufficient to replace it with the new Gramian A ij := Φ(x i ), Φ(x j ) H to obtain a nonlinear algorithm.
We will see that Φ(x), Φ(y) H defines in fact a positive definite kernel, and if any numerical procedure can be written in terms of inner products of the inputs, it can be transformed in the same way into a new nonlinear algorithm simply by replacing the inner products with kernel evaluations (the so-called kernel trick). We will discuss the details of this procedure in the next sections in the case of interpolation and Support Vector Regression, but this immediately gives a glance of the ample spectrum of algorithms in the class of kernel methods.
This chapter is organized as follows. Section 2 covers the basic notions on kernels and kernel-based spaces which are necessary for the development and understanding of the algorithms. The next Section 3 presents the general ideas and tools to construct kernel surrogates as characterized by the Representer Theorem, and these ideas are specialized to the case of kernel interpolation in Section 4 and Support Vector Regression in Section 5. In both cases, we provide the theoretical foundations as well as the algorithmic description of the methods, with particular attention to techniques to enforce sparsity in the model. These surrogates can be used to perform various analyses of the full model, and we give some examples in Section 6. Section 7 presents a general strategy to choose the various parameters defining the model, whose tuning can be critical for a successful application of the algorithms. Finally, we discuss in Section 8 the numerical results of the methods on a real application dataset, comparing training time (offline), prediction time (online), and accuracy.

Background on kernels
We start by introducing some general facts of positive definite kernels. Further details on the general analytical theory of reproducing kernels can be found e.g. in the recent monograph [45], while the books [15,65] and [53,55] contain a treatment of kernel theory from the point of view of pattern analysis and scattered data interpolation, respectively.

Positive definite kernels
Given a nonempty set Ω, which can be a subset of R d , d ∈ N, but also a set of structured objects such as strings or graphs, a real-and scalar-valued kernel K on Ω is a bivariate symmetric function K : Ω × Ω → R, i.e., K(x, y) = K(y, x) for all x, y ∈ Ω. For our purposes, we are interested in (strictly) positive definite kernels, defined as follows.
Definition 1 (Positive definite kernels). Let Ω be a nonempty set. A kernel K on Ω is positive definite (PD) on Ω if for all n ∈ N and for any set of n pairwise distinct elements X n := {x i } n i=1 ⊂ Ω, the kernel matrix (or Gramian matrix) The kernel is strictly positive definite (SPD) if the kernel matrix is positive definite, i.e., (1) holds with strict inequality when α = 0.
The further class of conditionally (strictly) positive definite kernels is also of interest in certain contexts. We refer to [65,Chapter 8] for their extensive treatment, and we just mention that they are defined as above, except that the condition (1) has to be satisfied only for the subset of coefficients α which match a certain orthogonality condition. When this condition is defined with respect to a space of polynomials of degree m ∈ N, the resulting kernels are used e.g. to guarantee a certain polynomial exactness of the given approximation scheme, and they are often employed in certain methods for the solution of PDEs.

Examples and construction of kernels
Despite the abstract definition, there are several ways to construct functions K : Ω × Ω → R which are (strictly) positive definite kernels, and usually the proper choice of the kernel is a crucial step in the successful application of the method. We list here a general strategy to construct kernels, and some notable examples.
An often used, constructive approach to design a new kernel is via feature maps as follows.
Proposition 2 (Kernels via feature maps). Let Ω be a nonempty set. A feature map Φ is any function Φ : Ω → H, where (H, ·, · H ) is any Hilbert space (the feature space). The function is a PD kernel on Ω.
Proof. K is a PD kernel since it is symmetric and positive definite, because the inner product is bilinear, symmetric and positive definite. In many cases, H is either R m with very large m or even an infinite dimensional Hilbert space. The computation of the possibly expensive m-or infinite-dimensional inner product can be avoided if a closed form for K can be obtained. This implies a significant reduction of the computational time required to evaluate the kernel and thus to execute any kind of algorithm.
We see now some examples.
Example 3 (Expansion kernels). The construction comprises finite dimensional linear combinations, i.e., for a set of functions {v j } m j=1 : Ω → R, the function This idea can be extended to an infinite number of functions provided {v j (x)} ∞ j=1 ∈ H := 2 (N) uniformly in Ω, and the resulting kernels are called Hilbert-Schmidt or expansion kernels, which can be proven to be even SPD under additional conditions (see [49]). As an example in d = 1, we mention the Brownian Bridge kernel K(x, y) := max(x, y) − xy, defined with a feature map v j (x) := √ 2(jπ) −1 sin(jπx) for j ∈ N, which is SPD on Ω := (0, 1). We remark that the kernel can be extended to (0, 1) d with d > 1 using a tensor product of onedimensional kernels.
This feature map representation proves also that dim(H) =: m < ∞ means that the kernel is not SPD in general: e.g., if X n contains n pairwise distinct points and m < n, then the vectors {Φ(x i )} n i=1 can not be linearly independent, and thus the kernel matrix is singular.
Example 4 (Kernels for structured data). Feature maps are also employed to construct positive definite kernels on sets Ω of structured data, such as sets of strings, graphs, or any other object. For example, the convolution kernels introduced in [20,26] consider a finite set of features v 1 (x), . . . , v m (x) ∈ R of an object x ∈ Ω, and define a feature map exactly as in (2).
Example 5 (Polynomial kernels). For a ≥ 0, p ∈ N, x, y ∈ R d , the polynomial kernel is PD on any Ω ⊂ R d . It is a d-variate polynomial of degree p, which contains the monomial terms of degrees j := j (1) , . . . , j (d) ∈ J, for a certain set J ⊂ N d 0 . If m := |J|, a feature space is R m with feature map for some positive numbers {a j } m j=1 and monomials Observe that using the closed form (3) of the kernel instead of the feature map is very convenient, since we work with d-dimensional instead of m-dimensional vectors, where possibly m : d.
For Ω ⊂ R d in many applications the most used kernels are translational invariant kernels, i.e., there exist a function φ : R d → R with K(x, y) := φ(x − y), x, y ∈ Ω, and in particular radial kernels, i.e., there exist a univariate function φ : A radial kernel, or Radial Basis Function (RBF), is usually defined up to a shape parameter γ > 0 that controls the scale of the kernel via K(x, y) := φ(γ x − y ).
The main example of such kernels is the Gaussian K(x, y) := e −γ 2 x−y 2 , which is in fact strictly positive definite. An explicit feature map has been computed in [56]: If Ω ⊂ R d is nonempty, a feature map is the function In this case it is even more evident how working with the closed form of K is much more efficient than working with a feature map and computing L 2 -inner products. RBF kernels offer a significant easiness of implementation in arbitrary space dimension d. The evaluation of the kernel K(·, x), x ∈ R d , on a vector of n points can indeed by realized by first computing a distance vector D ∈ R n , D i := x − x i , and then applying the univariate function φ on D. A discussion and comparison of different algorithms (in Matlab) to efficiently compute a distance matrix can be found in [15,Chapter 4], and most scientific computing languages comprise a built-in implementation (such as pdist2 1 in Matlab and distance_matrix 2 in Scipy).
Translational invariant and RBF kernels can be often analyzed in terms of their Fourier transforms, which provide proofs of their strict positive definiteness via the Bochner Theorem (see e.g. [65,Chapter 6]), and connections to certain Sobolev spaces, as we will briefly see in Section 2.3.
Among various RBF kernels, there are also compactly supported kernels, i.e., K(x, y) = 0 if x − y > 1/γ, which produce sparse kernel matrices if γ is large enough. The most used ones are the Wendland kernels introduced in [63], which are even radial polynomial within their support.
There are, in addition, various operations to combine positive definite kernels and obtain new ones. For example, sums and products of positive definite kernels and multiplication by a positive constant a > 0 produce again positive definite kernels. Moreover, if K is a positive definite kernel and K is symmetric with K K (i.e., K := K − K is PD) then also K is positive definite. Furthermore, if Ω = Ω × Ω and K , K are PD kernels on Ω , Ω , then K(x, y) := K (x , y )K (x , y ) and K(x, y) := K (x , y ) + K (x , y ) are also PD kernels on Ω, i.e., kernels can be defined to respect tensor product structures of the input.

Kernels and Hilbert spaces
Most of the analysis of kernel-based methods is possible through the connection with certain Hilbert spaces. We first give the following definition.
Definition 7 (Reproducing Kernel Hilbert Space). Let Ω be a nonempty set, H an Hilbert space of functions f : Ω → R with inner product ·, · H . Then H is called a Reproducing Kernel Hilbert Space (RKHS) on Ω if there exists a function K : Ω × Ω → R (the reproducing kernel) such that The reproducing property is equivalent to state that, for x ∈ Ω, the xtranslate K(·, x) of the kernel is the Riesz representer of the evaluation functional δ x : H → R, δ x (f ) := f (x) for f ∈ H , that is hence a continuous functional in H. Also the converse holds, and the following result gives an abstract criterion to check if a Hilbert space is a RKHS.  is an orthonormal basis, then a reproducing kernel is given by Indeed, the two properties of Definition 7 can be easily verified by direct computation.
The following result proves that reproducing kernels are in fact positive definite kernels in the sense of Definition 1. Moreover, the first two properties are useful to deal with the various type of approximants of Section 4 and Section 5, which will be exactly of this form.
Proposition 11. Let H be a RKHS on Ω with reproducing kernel K. Let n, n ∈ N, α ∈ R n , α ∈ R n , X n , X n ⊂ Ω, and define the functions Then we have the following: 3. K is the unique reproducing kernel of H and it is a positive definite kernel.
Proof. The first two properties follow from Definition 7, and in particular from H being a linear space and from the bilinearity of ·, · H . For Property (3), the fact that K is symmetric and positive definite, hence a PD kernel, follows from Property (1) of Definition 7, and from the symmetry and positive definiteness of the inner product. Moreover, the reproducing property implies that, if K, K are two reproducing kernels of H, then for all x, y ∈ Ω it holds K(x, y) = K(·, y), K (·, x) H = K (x, y).
It is common in applications to follow instead the opposite path, i.e., to start with a given PD kernel, and try to see if an appropriate RKHS exists. This is in fact always the case, as proven by the following fundamental theorem from [2].
Theorem 12 (RKHS from kernels -Moore-Aronszajn Theorem). Let Ω be a nonempty set and K : Ω × Ω → R a positive definite kernel. Then there exists a unique RKHS H := H K (Ω) with reproducing kernel K.
Proof. The theorem was first proven in [2], to which we refer for a detailed proof. The idea is to deduce that, by Property (1) of Proposition 3, a candidate RKHS H of K needs to contain the linear space of finite linear combinations of kernel translates. Moreover, from Property (2) of Proposition 11, the inner product on this H 0 needs to satisfy With this observation in mind, the idea of the construction of H is to start by H 0 , prove that (4) defines indeed an inner product on H 0 , and that the completion of H 0 w.r.t. this inner product is a RKHS having K as reproducing kernel. Uniqueness then follows from Property (3) of the same proposition.
As it is common in the approximation literature, we will sometimes refer to this unique H as the native space of the kernel K on Ω.
Remark 13 (Kernel feature map). Among other consequences, this construction allows to prove that any PD kernel is generated by at least one feature map. Indeed, the function Φ : Ω → H, Φ(x) := K(·, x), is clearly a feature map for K with feature space H, since the reproducing property implies that Φ(x), Φ(y) H = K(·, x), K(·, y) H = K(x, y) for all x, y ∈ Ω.
Remark 14. For certain translational invariant kernels it is possible to prove that the associated native space is norm equivalent to a Sobolev spaces of the appropriate smoothness, which is related to the kernels' smoothness (see [65,Chapter 10]). This is particularly interesting since the approximation properties of the different algorithms, including certain optimality that we will see in the next sections, are in fact optimal in these Sobolev spaces (with an equivalent norm).
The various operations on positive definite kernels mentioned in Section 2.2 have an analogous effect on the corresponding native spaces. For example, the scaling by a positive number a > 0 does not change the native space, but scales the inner product correspondingly, and, if K K are positive definite kernels, then H K (Ω) ⊂ H K (Ω). We remark that the latter property has been used for example in [71] to prove inclusion relations for the native spaces of RBF kernels with different shape parameters.

Kernels for vector-valued functions
So far we only dealt with scalar-valued kernels, which are suitable to treat scalarvalued functions. Nevertheless, it is clear that the interest in model reduction is typically also on vector-valued or multi-output functions, which thus require a generalization of the theory presented so far. This has been done in [35], and it is based on the following definition of matrix-valued kernels.

Definition 15 (Matrix-valued PD kernels).
Let Ω be a nonempty set and q ∈ N. A function K : Ω × Ω → R q×q is a matrix valued kernel if it is symmetric, i.e., K(x, y) = K(y, x) T for all x, y ∈ Ω. It is a PD (resp., SPD) matrix-valued kernel if the kernel matrix A ∈ R nq×nq is positive semidefinite (resp., positive definite) for all n ∈ N and for all sets X n ⊂ Ω of pairwise distinct elements.
This more general class of kernels is also associated to a uniquely defined native space of vector-valued functions, where the notion of RKHS is replaced by the following.

Definition 16 (RKHS for matrix-valued kernels).
Let Ω be a nonempty set, q ∈ N, H an Hilbert space of functions f : Ω → R q with inner product ·, · H . Then H is called a vector-valued RKHS on Ω if there exists a function K : Ω × Ω → R q×q (the matrix-valued reproducing kernel) such that A particularly simple version of this construction can be realized by considering separable matrix-valued kernels (see e.g. [1]), i.e., kernels that are defined as K(x, y) :=K(x, y)B, whereK is a standard scalar-valued PD kernel, and B ∈ R q×q is a positive semidefinite matrix. In the special case Q = I (the q × q identity matrix), in [70] it is shown that the native space of K is the tensor product of q copies of the native space ofK, i.e., This simplification will give convenient advantages when implementing some of the methods discussed in Section 4.

Data based surrogates
We can now introduce in general terms the two surrogate modeling techniques that we will discuss, namely (regularized) kernel interpolation and Support Vector Regression (SVR).
For both of them, the idea is to represent the expensive map to be reduced as a function f : Ω → R q that maps an input x ∈ Ω to an output y ∈ R q . Here f is assumed to be only continuous, and the set Ω can be arbitrary as long as a positive definite kernel K can be defined on it. Moreover, the function does not need to be known in any particular way except than through its evaluations on a finite set The goal is to construct a function s ∈ H such that s(x) is a good approximation of f (x) for all x ∈ Ω (and not only for x ∈ X n ), while being significantly faster to evaluate. The process of computing s from the data (X n , Y n ) is often referred to as training of the surrogate s, and the set (X n , Y n ) is thus called training dataset.
The computation of the particular surrogate is realized as the solution of an infinite dimensional optimization problem. In general terms, we define a loss function which takes as input a candidate surrogate g ∈ H and the values X n ∈ Ω n , Y n ∈ (R q ) n , and returns a measure of the data-accuracy of g. Then, the surrogate s is defined as a minimizer, if it exists, of the cost function where the second part of J is a regularization term that penalizes solutions with large norm. The tradeoff between the data-accuracy term and the regularization term is controlled by the regularization parameter λ ≥ 0.
For the sake of presentation, we restrict in the remaining of this section to the case of scalar-valued functions, i.e., q = 1. The general case follows by using matrix valued kernels as introduced in Section 2.4, and the corresponding definition of orthogonal projections.
The following fundamental Representer Theorem characterizes exactly some solutions of this problem, and it proves that the surrogate will be a function i.e., a finite linear combination of kernel translates on the training points. A first version of this result was proven in [27], while we refer to [52] for a more general statement.

Theorem 17 (Representer Theorem).
Let Ω be a nonempty set, K a PD kernel on Ω, λ > 0 a regularization parameter, and let (X n , Y n ) be a training set.
Then, if the optimization problem has a solution, it has in particular a solution of the form for suitable coefficients α ∈ R n .
Proof. We prove that for every g ∈ H there exists s ∈ V (X n ) such that J(s) ≤ J(g). To see this, we decompose g ∈ H as In particular, since K(·, x i ) ∈ V (X n ), we have by the reproducing property of the kernel that and it follows that L(g, X n , Y n ) = L(s, X n , Y n ). Moreover, again by orthogonal projection we have The existence of a solution will be guaranteed by choosing a convex cost function J, i.e., since the regularization term is always convex, by choosing a convex loss function. Then the theorem states that solutions of the infinite dimensional optimization problem can be computed by solving a finite dimensional convex one.
This is a great result, but observe that the evaluation of s(x), x ∈ Ω, requires the evaluation of the n-terms linear combination (6), where n is the size of the dataset. Assuming that the kernel can be evaluated in constant time, the complexity of this operation is O(n). Thus, to achieve the promised speedup in evaluating the surrogate in place of the function f , we will consider in the following methods that enforce sparsity in s, i.e., which compute approximate solution where most of the coefficients α j are zero. If the nonzero coefficients correspond to an index set Taking into account this sparsity and denoting X N := {x i ∈ X n : i ∈ I N } and α := (α i : i ∈ I N ), we can summarize in Algorithm 1 the online phase for any of the following algorithms, consisting in the evaluation of s on a set of points X te ⊂ Ω. Here and in the following, we denote as s(X) := (s(x 1 ), . . . , s(x m )) T ∈ R m the vector of evaluations of s on a set of points X : Remark 18 (Normalization of the cost function). It is sometimes convenient to weight the loss term in the cost function (5) by a factor 1/n, which normalizes its value with respect to the number of data. We do not use this convention here, and we only remark that this is equivalent to the use of a regularization parameter λ = nλ for a given λ > 0.

Kernel interpolation
The first method that we discuss is (regularized) kernel interpolation. In this case, we consider the square loss function which measures the pointwise distance between the surrogate and the target data. We have then the following special case of the Representer Theorem. We denote as y ∈ R n the vector of output data, assuming again for now that q = 1.

Corollary 19 (Regularized interpolant).
Let Ω be a nonempty set, K a PD kernel on Ω, λ ≥ 0 a regularization parameter. For any training set (X n , Y n ) there exists an approximant of the form where the vector of coefficients α ∈ R n is a solution of the linear system where , is the kernel matrix on X n . Moreover, if K is SPD this is the unique solution of the minimization problem (5).
Proof. The loss L is clearly convex, so there exists a solution of the optimization problem, and by Theorem 17 we know that we can restrict to solutions in V (X n ). We then consider functions s := n j=1 α j K(·, x j ) for some unknown α ∈ R n . Computing the inner product as in Proposition 11, we obtain The functional J restricted to V (X n ) can be parametrized by α ∈ R n , and thus it can be rewritten asJ : i.e., ∇ αJ (α) = 0 if and only if A (A + λI) α = Ay, which is satisfied by α such that (A + λI) α = y. If K is SPD then both A and A + λI are invertible, so this is the only solution.
The extension to vector valued functions, i.e. q > 1, is straightforward using the separable matrix valued kernels with B = I of Section 2.4. Indeed, in this case the data values are vectors y i := f (x i ) ∈ R q , and thus in the interpolant (7) also the coefficients are vectors α j ∈ R q . The linear system (8) has the same matrix, but instead α, y ∈ R n×q are defined as α := (α 1 , . . . , α n ) T , y := (y 1 , . . . , y n ) T .
We remark that in the following the values x i , y i , s(x), and α k have always to be understood as row vectors when q > 1. This notation is very convenient when representing the coefficients as the solution of a linear system. Furthermore, the representation of the dataset samples (x, y) is quite natural when dealing with tabular data, where each column represents a feature and each row a sample vector.
For K SPD and pairwise distinct sample locations X n we can also set λ := 0 and obtain pure interpolation, i.e., the solution satisfies L(s, X n , Y n ) = 0, or Observe that this means that with this method we can exactly interpolate arbitrary continuous functions on arbitrary pairwise distinct scattered data in any dimension, as opposite to many other techniques which require complicated conditions on the interpolation points or a grid structure. Moreover, this approximation process has several optimality properties in H, which remind of similar properties of spline interpolation.
Proposition 20 (Optimality of kernel interpolation). Let K be SPD, f ∈ H, and λ = 0. Then s is the orthogonal projection of f in V (X n ), and in particular i.e., s is the minimal norm interpolant of f on X n .
Proof. The proof is analogous to the proof of the Representer Theorem, using a decomposition f = g + g ⊥ , and proving that s = g.
We will see in Section 7 a general technique to tune λ using the data, which should return λ = 0 (or very small) when this is the best option. Nevertheless, also for an SPD kernel there are at least two reasons to still consider regularized interpolation. First, the data can be affected by noise, and thus an exact pointwise recovery does not make much sense. Second, a positive parameter λ > 0 improves the condition number of the linear system, and thus the stability of the solution. Indeed, the 2-condition number of A + λI is which is a strictly decreasing function of λ, with κ(0) = κ(A) and lim λ→∞ κ(λ) = 1.
Moreover (see [66]) this increased stability can be achieved by still controlling the pointwise accuracy. Namely, if f ∈ H, it holds We can then summarize the offline phase for regularized kernel interpolation in Algorithm 2.
Remark 21 (Flat limit). The matrix A can be seriously ill-conditioned for certain kernels, and this constitutes a problem at least in the case of pure interpolation. It can also be proven that kernels which guarantee a faster error convergence result in a worse conditioned matrix [48].
For RBF kernels, this happens especially for γ → 0 (the so called flat limit), and it is usually not a good idea to directly solve the linear system. In the last years there has been very active research to compute s via different formulations, which rely on different representations of the kernel. We mention here mainly the RBF-QR algorithm 3 [18,31] and the Hilbert-Schmidt SVD 4 [16] . Both methods are limited so far to only some kernels, but they manage to achieve a great accuracy, which is usually impossible to obtain with the direct solution of the linear system.

Remark 22 (Error estimation).
For SPD translational invariant kernels there is a very detailed error analysis of the interpolation process (λ = 0), for which we refer to [65,Chapter 11]. We only mention that these error bounds assume that f ∈ H, and are of the form where C > 0 is a constant independent of f , and h n is the fill distance of X n in Ω, i.e., h n := h Xn,Ω := sup x∈Ω min xj ∈Xn x − x j , which is the analogue of the mesh width for scattered data. Moreover, the order of convergence p > 0 is dependent on the smoothness of the kernel. In particular, these error bounds can be proven to be optimal when the native space of K is a Sobolev space. Moreover, these results have been recently extended to the case of regularized interpolation (λ > 0) in [43,66].

Kernel greedy approximation
The surrogate constructed via Corollary 19 involves a linear combination of n terms, where n is the size of the dataset. In general, there is no reason to assume that the result has any sparsity, i.e., in general all the α j will be nonzero, and it is thus necessary to introduce some technique to enforce this sparsity.
A very effective way to achieve this result is via greedy algorithms. The idea is to select a small subset X N ⊂ X n , N n, given by indexes I N ⊂ {1, . . . , n}, and to solve the corresponding restricted problem with the dataset (X N , Y N ) to compute a surrogate where the coefficient vectors are computed based on (8), and are in general different from the ones of the full surrogate. If we manage to select I N in a proper way, we will obtain s N (x) ≈ f (x) for all x ∈ Ω, while the evaluation of s N (x) is now only of order O(N ). An optimal selection of X N is a combinatorial problem and thus is very expensive and in practice computationally intractable. The idea of greedy algorithms is instead to perform this selection incrementally, i.e., adding at each iteration only the most promising new point, based on some error indicator.
The general structure of the algorithm is described in Algorithm 3. For the moment, we consider a generic selection rule η : X n ×N×Ω n ×(R q ) n → R ≥0 that selects points based on the value η (x, N, X n , Y n ). This is a compact notation to denote that the selection rule assigns a score to a point x ∈ Ω, and it is computed using various quantities that depend on the dataset (X n , Y n ) and on the iteration number N , including in particular the surrogate computed at the previous iteration. The algorithm is terminated by means of a given tolerance τ > 0.

Remark 23.
In the case that the maximizer of η the line 5 of Algorithm 3 is not unique, only one of the multiple points is selected and included in X N .
In line 7 of the algorithm, we need to compute the surrogate s N with dataset (X N , Y N ). This step can be highly simplified by reusing s N −1 as much as possible, thus improving the efficiency of the algorithm. As a side effect, with this incremental procedure it is easy to update the surrogate if the accuracy has to be improved. This can be achieved using the Newton basis, which is defined in analogy to the Newton basis for polynomial interpolation. It has been introduced in [37,39] for K SPD, and extended to the case of K PD and λ > 0 in [47], and we refer to these papers for the proof of the following result.
The Newton basis {v j } N j=1 is defined as the Gram-Schmidt orthonormaliza- and, if B ∈ R N ×N , B jk := β jk , and V ∈ R N ×N , V jk := v k (x j ), then B, V are triangular, B = V −T , and is the Cholesky decomposition of the regularized kernel matrix A N +λI ∈ R N ×N , A jk := K(x ij , x i k ), with pivoting given by I N .
Observe that this basis is nested, i.e., we can incrementally add a new element without recomputing the previous ones. Even more, with this basis the surrogate can be computed as follows.

Proposition 25 (Incremental regularized interpolation).
Let Ω be non empty, λ ≥ 0, K be PD on Ω or SPD when λ = 0. Let (X N , Y N ) be the subset of (X n , Y n ) corresponding to indexes I N , for all N ≤ n.
Lets 0 := 0, and, for N ≥ 1, compute the following incremental functioñ Then, for all N , the regularized interpolant can be computed as Remark 26. In the case λ = 0 and K SPD, the functions N coincides with the interpolant s N . We refer to [39,47] for the details.
We are now left to define the selection rules, represented by η, to select the new point at each iteration.
For this, we first need to define the power function, which gives an upper bound on the interpolation error, and it can be defined using the Newton basis as Its relevance is due to the fact that it provides an upper bound on the pointwise (regularized) interpolation error, i.e., if x / ∈ X n , and K is PD, or SPD when λ = 0, it holds for all f ∈ H that This function is well known and studied in the case of pure interpolation (see e.g. [65,Chapter 11]), for which the upper bound holds for all x ∈ Ω, and it can be easily extended to the case of regularized interpolation (see [47]). In both cases, it can be proven that P n (x) = 0 if and only if x ∈ X n , and its maximum is strictly decreasing with N .
Remark 27. This interpolation technique is strictly related to the Kriging method and to Gaussian Process Regression (see e.g. [38,42]. In this case the kernel represents the covariance kernel of the prior distribution, and the power function is the Kriging variance, or variance of the posterior distribution (see [50]).
We can then define the following selection rules. We assume to have a dataset (X n , Y n ), and to have already selected N points corresponding to indexes I N −1 . We use the notation [1, n] := {1, . . . , n}, and we have • P -greedy: Observe that all the selections are well defined, since P N −1 (x i ) = 0 for all i / ∈ I N −1 if X N are pairwise distinct, and they can be efficiently implemented by using the update rules (11) for s N and (12) for P N . Moreover, they are motivated by different ideas: The P -greedy selection tries to minimize the Power function, thus providing a uniform upper bound on the error for any function f ∈ H via (13); the f -and f /P -greedy (which reads "f -over-P -greedy"), on the other hand, use also the output data, and produce points which are suitable to approximate a single function and thus are expected to result in a better approximation. In the case of f -greedy this is done by including in the set of points the location where the current largest error is achieved, thus reducing the maximum error. The f /P -greedy selection, instead, reduces the error in the H-norm, and indeed it can be proven to be locally optimal, i.e., it guarantees the maximal possible reduction of the error, in the H-norm, at each iteration.
We can now describe the full computation of the greedy regularized interpolant in Algorithm 4. It realizes the computation of the sparse surrogate s N by selecting the points X N via the index set I N , and computing only the nonzero coefficients α. Moreover, using the nested structure of the Newton basis and the incremental computation of Proposition 25, the algorithm needs only to compute the columns of the full kernel matrix corresponding to the index set I N , and thus there is no need to compute nor store the full n × n matrix, i.e., the implementation is matrix-free. In addition, again using Proposition 25 most of the operations are done in-place, i.e., some vectors are used to store and update the values of the Power Function and of y. In the algorithm, we use a Matlablike notation, i.e., A(I N , :) denotes the submatrix of A consisting of rows I N and of all the columns. Moreover, the notation v 2 denotes the pointwise squaring of the entries of the vector v.
The set of points X N defined by I N , and the coefficients α, can then be used in the online phase of Algorithm 1.

Remark 28 (Vector valued functions and implementation details)
. Algorithm 4 and the overall procedure are well defined for arbitrary q ≥ 1. Indeed, using the separable matrix valued kernel of Section 2.4, the Newton basis only depends on the scalar valued kernel K, while the computation of the coefficients is valid by considering that now c, α are matrices instead of vectors. In particular, the computation of c N (line 14) and the update of y (line 11) has to be done via column-wise multiplications.
Moreover, observe that in line 12 we employ a standard technique to update the inverse of a lower triangular matrix, i.e., given V N ∈ R N ×N lower triangular with inverse V −1 N , we define

The present version of the algorithm for vector-valued functions has been introduced in [68] and named Vectorial Kernel Orthogonal Greedy Algorithm
(VKOGA). We keep the same abbreviation also for the regularized version, which has been studied in [47].
Remark 29 (Convergence rates). When the greedy algorithm is run by selecting points over Ω instead of X N , there are also convergence rates for the resulting approximation processes. For pure interpolation (i.e., K SPD, λ = 0) convergence of f -greedy has been proven in [36], of P -greedy in [46], and of f /Pgreedy in [68], while in [47] the convergence rate of P -greedy has been extended to regularized interpolation. All the results make additional assumptions on the kernels, for which we refer to the cited literature. Nevertheless, we remark that the convergence rates for interpolation with P -greedy are quasi-optimal for translational invariant kernels, while the results for the other algorithms guarantee only a possibly significantly slower convergence rate. These results are believed to be significantly sub-optimal, since extensive experiments indicate that f -and f /P -greedy behave much better. This seems to suggest that there is space for a large improvement in the theoretical understanding of the methods.

Remark 30 (Other techniques).
There are other techniques that can be applied to reduce the complexity of the evaluation of the surrogate s, which do not use greedy algorithms but instead different approaches. First, there is a domain decomposition technique, known as Partition of Unity Method, which partitions Ω into subdomains, solves the (regularized) interpolation problem restricted to each patch, and then combines the results by a weighted sum of the local interpolants to obtain a global approximant. This method has the advantage that this offline phase can be completely parallelized. Moreover, when evaluating the surrogate only the few local interpolant having a support containing the test points have to be evaluated, thus requiring the evaluation of a few, small kernel expansions, thus providing a significant speed-up. The efficiency of this technique relies on an efficient search procedure to determine the local patches including the given points, which is the only limitation in the application to high dimensional problems. Both theoretical results and efficient implementations are available [7,64].
Moreover, other sparsity-inducing techniques have been proposed, namely, the use of an 1 -regularization term [10], and the method of the Least Absolute Shrinkage and Selection Operator (LASSO) [61].

Support Vector Regression
The second method that we present is Support Vector Regression (SVR) [53], which is based on different premises, but it still fits in the general framework of Section 3. In this case, we consider the ε-insensitive loss function which is designed to linearly penalize functions s which have values outside of an ε-tube around the data, while no distinction is made between function values that are inside this tube.
In this setting it is common to use the regularization parameter to scale the cost by a factor 1/λ, and not the regularization term by a factor λ. The two choices are clearly equivalent, but we adopt here this different normalization to facilitate the comparison with the existing literature, and because this offers additional insights in the structure of the surrogate.
Since the problem is not quadratic (and not smooth), we first derive an equivalent formulation of the optimization problem (5). Assuming again that the output is scalar, i.e., q = 1, the idea is to introduce non-negative slack variables ξ + , ξ − ∈ R n which represent upper bounds on L via ξ − i ≥ max(0, y i − s(x i ) − ε), 1 ≤ i ≤ n, and to minimize them in place of the original loss. With these new variables we can rewrite the optimization problem in the following equivalent way.

Definition 31 (SVR -Primal form).
Let Ω be a nonempty set, K a PD kernel on Ω, λ > 0 a regularization parameter. For a training set (X n , Y n ) the SVR approximant (s, ξ + , ξ − ) ∈ H × R 2n is a solution of the quadratic optimization problem For this rewriting of the optimization problem, we can now specialize the Representer Theorem as follows.
Corollary 32 (SVR -Alternative primal form). Let Ω be a nonempty set, K a PD kernel on Ω, λ > 0 a regularization parameter. For any training set (X n , Y n ) there exists an SVR approximant of the form where (α, ξ + , ξ − ) ∈ R 3n is a solution of the quadratic optimization problem with 1 n := (1, . . . , 1) T ∈ R n , and A ∈ R n×n , A ij := K(x i , x j ), the kernel matrix on X n . Moreover, if K is SPD this is the unique solution of the minimization problem (5).
Proof. The result is an immediate consequence of Proposition 31, where we use the form (16) for s and compute its squared norm via Proposition 11.
The slack variables (14) have a nice geometric interpretation. Indeed, the optimization process clearly tries to reduce their value as much as possible, while respecting the constraints. We state a more precise result in the following proposition, and give a schematic illustration in Figure 1.
Proposition 33 (Slack variables). Let α, ξ + , ξ − ∈ R n be a solution of (17), and let s be the corresponding surrogate (16). Then, for each index i ∈ {1, . . . , n}, the values ξ + i , ξ − i represent the distance of s(x i ) from the ε-tube around y i , and in particular In particular, only one of ξ + i and ξ − i can be nonzero.
Instead of solving the primal problem of Corollary 32, it is more common to derive and solve the following dual problem. Here again we denote as y ∈ R n the vector of all scalar training target values. Figure 1: Illustration of the role of the slack variables in (17).

Proposition 34 (SVR -Dual form).
Let Ω be a nonempty set, K a PD kernel on Ω, λ > 0 a regularization parameter. For any training set (X n , Y n ) there exists a solution (α + , α − ) ∈ R 2n of the problem which is unique if K is SPD. Moreover, a solution of (17) is given by We give a sketch of the proof, although a formal derivation requires more care, and we refer to [53,Chapter 9] for the details. The idea is to first derive the Lagrangian L := L(α, ξ + , ξ − ; α + , α − , µ + , µ − ) for the primal problem (17) using non-negative Lagrange multipliers α + , α − , µ + , µ − ∈ R n for the inequality constraints, and then derive the dual problem by imposing the Karush-Kuhn-Tucker (KKT) conditions (see e.g. Chapter 6 in [53]).
The Lagrangian is defined as Using the symmetry of A, the partial derivatives of L with respect to the primal variables can be computed as and setting these three equalities to zero we obtain equations for α, µ + , µ − , where in particular α = 1 2 (α − − α + ) (which is the unique solution if A is invertible). Substituting these values in the Lagrangian we get The remaining conditions in (18) stem from the requirements that the Lagrange multipliers are non-negative, and in particular 0 ≤ µ + i = 1/λ − α + i , i.e., α + i ≤ 1/λ, and similarly for α − i .
This dual formulation is particularly convenient to explain that the SVR surrogate has a built-in sparsity, i.e., the optimization process provides a solution where possibly many of the entries of α = 1 2 (α − − α + ) are zero. This behavior is in strong contrast with the case of interpolation of Section 4 where we needed to adopt special techniques to enforce this property. The points x i ∈ X n with α i = 0 are called support vectors, which gives the name to the method.
In particular, as for the slack variables there is a clean geometric description of this sparsity pattern, that gives additional insights into the solution. To see this we remark that, in addition to the stationarity KKT conditions (21), an optimal solution satisfies also the complementarity KKT conditions We then have the following: 1. Equations (22) state that α + i = 0 only if s(x i ) − y i − ε − ξ + i = 0, and similarly for α − i . Since ξ + i ≥ 0, this happens only when s(x i ) − y i ≥ ε, i.e., only for points (x i , s(x i )) which are outside or on the boundary of the ε-tube.
2. In particular, if α + i = 0 it follows that s(x i ) − y i ≥ ε, and thus y i − s(x i ) − ε − ξ − i = 0, and then necessarily α − i = 0. Thus, at most one of α + i and α − i can be nonzero.

Equations (23) imply that α
, whenever s(x i ) is strictly outside of the ε-tube. The corresponding x i are called bounded support vector, and the value of the corresponding coefficients is indeed kept bounded by the value of the regularization parameter. Reducing λ, i.e., using less regularization, allows solutions with coefficients of larger magnitude.
In summary, we can then expect that if s is a good approximation of the data, it will be also a sparse approximation.
We summarize the offline phase for SVR in Algorithm 5. We remark that in this case the extension to vector-valued functions is not as straightforward Algorithm 5 SVR -Offline phase 1: Input: training set X n ∈ Ω n , Y n ∈ R n , kernel K (and kernel parameters), regularization parameter λ ≥ 0, tube width ε > 0. 2: Compute the kernel matrix A ∈ R n×n , A ij := K(x i , x j ). 3: Solve the quadratic problem (18).
as for kernel interpolation, and it is thus common to train a separate SVR for each output component.

Remark 35 (General Support Vector Machines)
. SVR is indeed one member of a vast collection of algorithms related to Support Vector Machines (SVMs). Standard SVMs solve classification problems, i.e., Y n ⊂ {0, 1}. The original algorithm has been introduced as a linear algorithm (or, in the present understanding, as limited to the linear kernel, i.e., the polynomial kernel with a = 0, p = 1), and it has later been extended via the kernel trick to its general kernel version in [4]. The SVR algorithms have instead been introduced in [53].
Moreover, the version presented here is usually called ε-SVR. There exists also another non equivalent version called ν-SVR, which adds another term in the cost function multiplied by a factor ν ∈ [0, 1]. This has the role of giving an upper bound on the number of support vectors and on the fraction of training data which are outside of the ε-tube (see Chapter 9 in [53]).
We also remark that it is sometimes common to include in any SVM-based algorithm also an offset or bias term b ∈ R, i.e., to obtain a surrogate s(x) = n j=1 α j K(x, x j ) + b. This changes in an obvious way the primal problem (17), while the dual contains also the constraint However, we stick here to this formulation and refer to [57] for a discussion of statistical and numerical benefits of not using this offset term, at least in the case of SPD kernels.
Remark 36 (Error estimation). Also for SVR there is a detailed error theory, usually formulated in the framework of statistical learning theory (see [62]). Results are obtained by assuming that the dataset (X n , Y n ) is drawn from a certain unknown probability distribution, and then quantifying the approximation power of the surrogate. For a detailed treatment of this theory, we refer to [53,55]. Moreover, recently also deterministic error bounds for translational invariant kernels have been proven in [43,44].

Sequential Minimal Optimization
Although the optimization problem (18) can in principle be solved with any quadratic optimization method, there exists a special algorithm, called Sequential Minimal Optimization (SMO) that is designed for SVMs and that performs possibly much better.
SMO is an iterative method which improves an initial feasible guess for α + , α − ∈ R n until convergence, and the update is made such that the minimal possible number of entries of α are affected. In this way, very large problems can be efficiently solved. The original version of the algorithm has been introduced in [41] for SVM, and it has later been adapted to more general methods such as SVR, that we use here to illustrate the structure of its implementation.
The idea is to find at each iteration ∈ N a minimal set of indexes I ⊂ {1, . . . , n} and optimize only the variables with indexes in I . The procedure is then iterated until the optimum is reached. If the SVR includes an offset term, as explained in the previous section we have constraints Given a feasible solution α + i , α − i ( ) at iteration ∈ N, it is thus not possible to update a single entry of α + i or α − i without violating the KKT conditions (since at most one between α + i and α − i need to be nonzero) or violating the second constraint. It is instead possible to select two indexes I := {i, j} and in this case we have variables α + i , α − i , α + j , α − j and we can solve the restricted quadratic optimization problem under the constraints which can be solved analytically. The crucial step is to select I , and this is done by finding a first index that does not satisfy the KKT conditions and a second one with some heuristic. It can be proven that, if at least one of the two violates the KKT conditions, then the objective is strictly decreased and convergence is obtained. Moreover, the vectors α + = α − = 0 ∈ R n are always feasible and can thus be used as a first guess. In practice, the iteration is stopped when a sufficiently small value of the cost function is reached.
In the case of SVR without offset discussed in the previous section the situation is even simpler, since the second constraint in (24) is not present and it is thus possible to update a single pair α + i , α − i at each iteration. Nevertheless, it has been proven in [57] that using also in this case two indexes improves significantly the speed of convergence. Moreover, the same paper introduces several additional details to select the pair, to optimize the restricted cost function, and to establish termination conditions. A general version of SMO for SVR is summarized in Algorithm 6, where we assume that the function η : {1, . . . , n} → {1, . . . , n} implements the selection rule of I .

7:
Solve the optimization problem restricted to I . 8: end while 9: Set I N : are available in several programming languages and implement also some version of this algorithm. We mention especially LIBSVM 5 [9] and liquidSVM 6 [58].
6 Model analysis using the surrogate Apart from predicting new inputs with good accuracy and a significant speedup, the surrogate model can be used to perform a variety of different tasks related to meta-modeling, such as uncertainty quantification and state estimation. This can be done in a non-intrusive way, meaning that the full model is employed as a black-box that provides input-output pairs to train the surrogate, but is not required to be modified.
In principle, any kind of analysis that requires multiple evaluations can be significantly accelerated by the use of a surrogate, including the ones that are not computationally feasible due to the high computational cost of the full model. An example is uncertainty quantification, where the expected value of f can be approximated by a Monte Carlo integration of s using a set X m ⊂ Ω of integration points, i.e., Once the surrogate is computed using a training set (X n , Y n ), this approximate integral can be evaluated also for m n with a possibly very small cost, since the evaluation of s is significantly cheaper than the one of f .
Another example, which we describe in detail in the following, is the solution of an inverse problem to estimate the input parameter which generated a given output, i.e., from a given vector y ∈ R q we want to estimate x ∈ Ω such that f (x) = y. This can be done by considering a state-estimation cost function C : Ω → R defined by and estimating x by the value x * defined as In principle, we could perform the same optimization also using f instead of s in (25), but the surrogate allows a rapid evaluation of C. Moreover, if K is at least differentiable, then also s is differentiable, and thus we can use gradient-based methods to minimize C.
To detail this approach, we assume f : Ω → R q and to have a surrogate obtained as in Section 4.1 with the separable matrix valued kernel of Section 2.4, i.e., from (10) we have As explained in (9), in the vector-valued case q > 1 we always assume that the output s N (x) and the coefficients α k are row vectors, and in particular α ∈ R N ×q and s N (x) ∈ R 1×q . In this case we have the following.
Proposition 38 (Gradient of the state estimation cost). For x ∈ Ω ⊂ R d and y ∈ R q , the gradient of the cost (25) can be computed in x ∈ Ω as where D ∈ R d×N with columns D j := ∇ x K(x, x j ), and E := s N (x) − y ∈ R 1×q .
Proof. By linearity, the gradient of s N in x can be computed as and thus Observe in particular that whenever K is known in closed form the matrix D can be explicitly computed, and thus the gradient can be assembled using only matrix-vector multiplications of matrices of dimensions N, d, q, but independent of n. The solution x * can then be computed by any gradient-based optimization method, and each iteration can be performed in an efficient way.

Parameter and model selection
For all the methods that we have seen the approximation quality of the surrogate depends on several parameters, which need to be carefully chosen to obtain good results. There are both parameters defining the kernel, such as the shape parameter γ > 0 in a RBF kernel, and model parameters such as the regularization parameter λ ≥ 0. To some extent, also the selection of the kernel itself can be considered as a parametric dependence of the model. Moreover, it is essential to test the quality of the surrogate on an independent test set of data, since tuning it on the training set alone can very likely lead to overfitting, i.e., to obtain a model that is excessively accurate on the training set, while failing to generalize its prediction capabilities to unseen data.
In practical applications the target function f is unknown, so it cannot be used to check if the approximation is good, and all we know is the training set (X n , Y n ). In this case the most common approach is to split the sets into train, validation and test sets in the following sense. We permute (X n , Y n ), fix numbers n tr , n val , n te such that n = n tr + n val + n te , and define a partition of the dataset as and similarly for Y tr , Y val , Y te .
The idea is then to use the validation set (X val , Y val ) to validate (i.e., choose) the parameters, and the test set (X te , Y te ) to evaluate the error. Having disjoint sets allows to have a fair way to test the algorithm.
For the process we also need an error function that returns the error of the surrogate s evaluated on a generic set of points X := {x i } i ⊂ Ω w.r.t. the exact values Y := {y i } i . We denote as |X| the number of elements of X. Common examples are the maximal error and the Root Mean Square Error (RMSE) defined as Then one chooses a set of possible parameter instantiations {p 1 , . . . , p np }, n p ∈ N that has to be checked. A common choice for positive numerical parameters is to take them logarithmically equally spaced, since the correct scale is not known in advance, in general.
The training and validation process is described in Algorithm 7, where we denote as s(p i ) the surrogate obtained with parameter p i . It works as an outer loop with respect to the training of any of the surrogates that we have considered, and it has thus to be understood as part of the offline phase. Train surrogate s(p i ) with data (X tr , Y tr )

4:
Compute validation error e i := E(s(p i ), X val , Y val ) 5: end for 6: Choose parameterp := p i with i := arg min e i 7: Train surrogate s(p) with data (X tr ∪ X val , Y tr ∪ Y val ) 8: Compute test errorĒ = E(s(p), X te , Y te ) 9: Output: surrogate s(p), optimal parameterp, test errorĒ A more advanced way to realize the same idea is via k-fold cross validation.
To have an even better selection of the parameters, one can repeat the validation step (lines 2-6 in the previous algorithm) by changing the validation set at each step. To do so we do not select a validation set (so n = n tr + n te ), and instead consider a partition of X tr , Y tr into a fixed number k ∈ {1, . . . , n tr } of disjoint subsets, all approximately of the same size, i.e., and similarly for Y tr := ∪ k i=1 Y i and for Y te . In the validation step each of the the X i is used as a validation set, and the validation is repeated for all i = 1, . . . , k. In this case the error e i for the parameter p i is defined as the average error over all these permutations, as described in Algorithm 8.  Train surrogate s(p i ) with data (∪ =j X , ∪ =j Y )

Numerical examples
For the testing and illustration of the two methods of Section 4 and Section 5, we consider a real-world application dataset describing the biomechanical modeling of the human spine introduced and studied in [69]. We refer to that paper for further details and we just give a brief description in the following.
The input-output function f : R 3 → R 3 represents the coupling between a global multibody system (MBS) and a Finite Elements (FEM) submodel. The human spine is represented as a MBS consisting of the vertebra, which are coupled by the interaction through intervertebral disks (IVDs). The PDE representing the behavior of each IVD is approximated by a FEM discretization, and it has the input geometry parameters as boundary conditions, and computes the output mechanical response as a result of the simulation. In particular, the three inputs are two spatial displacements and an angular inclination of a vertebra, and the three outputs are the corresponding two force components and the momentum which are transfered to the next vertebra. The dataset is generated by running the full model for n := 1370 different input parameters X n and generating the corresponding set of outputs Y n .
The dataset, as described in Section 7, is first randomly permuted and then divided in training and test datasets (X ntr , Y ntr ), (X nte , Y nte ) with n tr := 1238 and n te = 132, corresponding to roughly 90% and 10% of the data. We remark that the full model predicts a value (0, 0, 0) T for the input (0, 0, 0) T and this sample pair is present in the dataset. We thus manually include it in the training set independently of the permutation. The training and test sets can be seen in Figure 2.
The models are trained using a Matlab implementation of the algorithms. For VKOGA we use an own implementation 7 , while for SVR we employ the KerMor package 8 , which provides an implementation of the 2-index SMO for the SVR without offset that is discussed in Section 5.1. We remark that this implementation requires the output data to be scaled in [−1, 1], and thus we perform this scaling for the training and validation, while the testing is executed by scaling back the predictions to the original range. To have a fair comparison, we use the same data normalization also for the VKOGA models.
The regularized VKOGA (with f -, P -, and f /P -greedy selection rules) and the SVR models are trained with the Gaussian kernel. Both algorithms depend on the shape parameter γ of the kernel and on the regularization parameter λ, while SVR additionally depends on the width ε of the tube. These parameters are selected by k-fold cross validation as described in Section 7. The values of k and of the parameter samples used for validation are reported in Table  1, where each parameter set is obtained by generating logarithmically equally spaced samples in the given interval, i.e., 400 parameter pairs are tested for VKOGA and 4000 triples for SVR. As an error measure we use the max error in (26). We remark that the SVR surrogate is obtained by training a separate model for each output, as described in Section 5, but only one cross validation is used. This means that for each parameter triple three models are trained, and then the parameter is evaluated in the prediction of the three dimensional output. Moreover, the training of the VKOGA surrogates is terminated when the square of the power function is below the tolerance τ P := 10 −12 , or when the training error is below the tolerance τ f := 10 −6 . Additionally, it would be possible to use a maximal number of selected points as stopping criterion, and this offers the significant advantage of directly controlling the expansion size, which could be reduced to any given number (of course at the price of a reduced accuracy). In the case of SVR, instead, the number N is a result of the tuning of the remaining parameters. k γ min γ max n γ λ min λ max n λ ε min ε max n ε 5 10 −2 10 1 20 10 −16 10 3 20 10 −10 10 −3 10 Table 1: Parameters ranges and sample numbers used in the k-fold cross validation.
In Table 2 we report the values of the parameters selected by the validation procedure for the four models, as well as the number N of nonzero coefficients in the trained kernel expansions. Observe that for SVR the three values of N refer to the number of support vectors for the three scalar-valued models. Moreover, the number of support vectors or kernel centers is only slightly larger for SVR than for the VKOGA models, but, as discussed in the following, the VKOGA models give prediction errors which are up to two orders of magnitude smaller than the ones of the SVR model.
We can now test the four models in the prediction on the test set. Table 3 contains various error measures between the prediction of the surrogates and the exact data. We report the values of the maximum error E max and the RMSE E RM SE defined in (26), and the relative maximum error E max,rel obtained by scaling each error by the norm of the exact output.  To provide a better insight in the approximation quality of the methods, we show in Figure 3 the distribution of the error over the test set. The plots show, for each sample (x i , y i ) in the test set, the absolute error y i − s(x i ) 2 as a function of the magnitude y i 2 of the output. Moreover, the black lines represent a relative error from 10 0 to 10 −3 . It is clear that in all cases the maximum and RMS errors of Table 3 are dominated by the values obtained for outputs of large norm, where the VKOGA models obtain a much better accuracy than SVR. The relative errors, on the other hand, are not evenly distributed for SVR, where most of the test set is approximated with a relative error between 10 1 and 10 −2 except for the samples with small magnitude of the output. For these data, the model gives increasingly bad predictions as the magnitude is smaller, reaching a relative error much larger than 1. The VKOGA models, instead, obtain a relative error smaller than 10 −2 on the full test set except for the entries of small magnitude. For these samples, the f -and P -greedy versions of the algorithm perform almost the same and better than the f /P -greedy variant, thus giving an overall smaller relative error in Table  3. Moreover, these results are obtained with a significantly smaller expansion size for f -greedy than for P -greedy. Indeed, even if the SVR surrogates for the individual output components are smaller than the VKOGA ones, the overall number of non-zero coefficients is 359 + 378 + 405 = 1142, i.e., more than the one of each of the three VKOGA models, thus leading to a less accurate and more expensive surrogate. Regarding the runtime requirements, we can now estimate both the offline (training) and online (prediction) times. The offline time required for the validation and training of the models is essentially determined by the number of parameters tested in the k-fold cross validation, while the training time of a single model is almost negligible. As a comparison, we report in Table 4 the average runtimeT of f line for 10 runs of the training of the models for the fixed set of parameters of Table 2. All the reported times are in the ranges of seconds (for VKOGA) and below one minute (for SVR). We remark that this timing is only a very rough indication and not a precise comparison, since the times highly depends on the number of selected points (for VKOGA) and the number of support vectors for SVR, and both are dependent on the used parameters. For example, we repeated the experiment for SVR with the same parameter set but with ε = 10 −1 . In this case this value of ε is overly large (if compared to the the one selected by cross validation) and it likely produces a useless model, but nevertheless we obtain an average training time of 0.03 sec.

Method
A more interesting comparison is the online time, which directly determines the efficiency of the surrogate models in the replacement of the full simulation. In this case, we evaluate the models 5000 times on the full test set consisting of n te = 132 samples, and we report the average online timeT online per single test sample in Table 4. The table contains also again the number N of elements of the corresponding kernel expansions, and it is evident that a smaller value leads to a faster evaluation of the model.
In the original paper [69], it has been estimated that a 30 sec full simulation with 24 IVDs with a timestep ∆t = 10 −3 sec requires 7.2 · 10 5 evaluations of the coupling function f , and these were estimated to require 600 h. This corresponds to an average ofT f ull = 3 sec per evaluation of f , giving a speedup T f ull /T online as reported in Table 4.
These surrogates can now be employed to solve different tasks that require multiple evaluations of f . As an example, we employ the f -greedy model (as the most accurate and most efficient) to solve a parameter estimation problem as described in Section 6. We consider the output values Y nte in the test set as a set of measures that have not been used in the training of the model, and we try to estimate the values of X nte . For each output vector y i ∈ R 3 we define a target value y := y i + η y i 2 v to define the cost (25), where v ∈ R 3 is a uniform random vector representing some noise, and η ∈ [0, 1] is a noise level. We then use a built-in Matlab optimizer with the gradient of Proposition 38, with initial guess x 0 := 0 ∈ R 3 , to obtain an estimate x * i of x i . The results of the estimate for each output value in the test set are depicted in Figure 4 for η = 0, 0.1, where we report also the final value of the cost function C(x * i ). In all cases, the optimizer seems to converge, since the value of the cost function is in all cases smaller than 10 −4 , which represents a relative value smaller than 10 −3 with respect to the magnitude of the input values. The maximum absolute error in the estimations is quite uniform for all the samples in the test set, and this results in a good relative error of about 10 −1 for large inputs, while for inputs of very small magnitude the relative error is larger than 1, and a larger noise level leads to less accurate predictions. This behavior is coherent with the analysis of the test error discussed above, since the approximant is less accurate on inputs of small magnitude, and thus it provides a less reliable surrogate in the cost function.

Summary and perspectives
In this chapter we discussed the use of kernel methods to construct surrogate models based on scattered data samples. These methods can be applied to data with general structure, and they scale well with the dimension of the input and output values. In particular, we analyzed issues and methods to obtain sparse solutions, which are then extremely fast to evaluate, while still being very accurate. These properties have been further demonstrated on numerical tests on a real application dataset. These methods can be analyzed in the common framework of Reproducing Kernel Hilbert Spaces, which provides solid theoretical foundations and a high flexibility to derive new algorithms. The integration of machine learning and model reduction is promising and many interesting aspects have still to be investigated. For example, surrogate models have been used in [23,24] to learn a representation with respect to projection-based methods, and generally a more extensive application of machine learning to dynamical systems requires additional understanding and the derivation of new techniques. Moreover, the field of data-based numerics is very promising, where classical numerical methods are integrated or accelerated with data-based models.