In this section, the novel ML approach as a combination of the PCE and GP is presented, where the PCE is used to calculate the hyperparameters of the GP. First, the general architecture and methodology of this approach is presented. After that, the hyperparameter optimization is described. Then, a runtime comparison is presented.
3.1. Architecture and Methodology
In the generic PCE formulation above, random variables are denoted by , following the standard notation commonly used in uncertainty quantification. In the proposed PCEGP model, however, the GP inputs are denoted by and are treated as deterministic input data. Accordingly, the PCE is not used here as a standalone random-variable model but is evaluated at the scaled inputs to parameterize input-dependent GP hyperparameters.
The general architecture of the PCEGP is shown in
Figure 1. It consists of data scaling of the input
, data point-dependent hyperparameter calculation, and the prediction of the output
in
, which includes the mean and uncertainty prediction. First, the given input data point
is scaled to
with a scaler, e.g., the min–max scaler.
As illustrated in
Figure 1, the scaled data point
is directly used as the input for the PCEs, which form the first processing stage after data scaling and are used to calculate the input-dependent hyperparameters of the GP. For each covariance function
, a separate PCE is used to predict the corresponding input-dependent lengthscale hyperparameters
, where
denotes the number of used covariance functions. The scaled data point
is also used as the input for the PCE that calculates the input-dependent heteroscedastic noise parameter
. The input-dependent lengthscale parameters
predicted by the PCE are transformed to ensure that the lengthscale
is in
. Similarly, the predicted input-dependent noise parameter
is transformed to
to ensure that it remains in
.
The choice of the PCE basis function depends on the input data. The approach of this study allows the combination of different polynomial bases for the calculation of the GP hyperparameters depending on the input data. This eliminates the choice of the polynomial basis, and the weighting of these becomes part of the HPO. As shown in
Figure 1, the combination of different PCE basis functions is achieved by a linear combination of these bases.
Non-stationary covariance functions enable the model to dynamically adjust to functions characterized by varying degrees of smoothness and training point densities across the input space. For GPs, this can be achieved by the estimation of an input-dependent lengthscale parameter of a chosen covariance function. In this work, the PCE is used to calculate the lengthscale parameters as a function of the input data.
For this purpose, the stationary covariance functions have to be adapted to estimate a data point-dependent lengthscale
. For example, the squared exponential covariance function
is changed to
which enables the possibility to calculate the lengthscale for each data point separately by the PCE. This construction follows the approach in [
5,
12], where the input-dependent lengthscale is learned with a DNN. In the present work this mapping is parameterized by a PCE. This makes it possible to transform any stationary covariance function into a non-stationary one. Here,
is generally described as an input-dependent lengthscale. The lengthscale value calculated by the PCE is denoted with
. In
Figure 1, the case
is shown, where the data point
is already scaled.
To avoid problems with the covariance calculation, an output scaling by standardization is used in the following, which also corresponds to the previously mentioned assumption of for the GP output.
The choice of the polynomial basis depends on the distribution of the input data. With
the lengthscale becomes an input-dependent hyperparameter for the covariance functions, estimated by the PCE. From this point onward, the optimizer’s task shifts from directly adjusting the lengthscale parameters to optimizing the
coefficients of the PCE for lengthscale calculation. In the case where the lengthscale parameter is calculated by a linear combination of
b polynomial expansions, the number of parameters to optimize changes to
where
denotes the polynomial degree of the PCE for lengthscale estimation. The polynomial coefficients of the input-dependent lengthscale
are summarized in the vector
.
The superposition of the polynomial expansions is achieved by a linear combination of the polynomials, as demonstrated in
Figure 1 with
A separate PCE is also used to model the heteroscedastic noise parameter
of the GP as a function of the input data. The estimation of the noise parameter is defined by
Assuming the noise variance
of real sensor data depends on the measurement range but usually does not exhibit highly complex behavior, the polynomial degree can be truncated to a significantly smaller value
than for the lengthscale calculation. This also limits the number of parameters
to be optimized for modeling the noise variance
The coefficients for noise estimation by the PCE are summarized in
. In GP models, the lengthscale and noise parameters are critical in defining the covariance function that determines the covariance between input points. The lengthscale controls how quickly the correlation between data points decays with increasing distance, while the noise parameter represents the variance of the observed noise. For these hyperparameters to function correctly, they must satisfy certain constraints to ensure a valid covariance structure.
Ensuring that the lengthscale parameter
remains positive is essential as a non-positive lengthscale would violate the mathematical requirements for the GP. If the lengthscale is zero or negative, the covariance function may not properly represent the distance-dependent correlations between points, resulting in an invalid covariance matrix. A positive lengthscale ensures that the kernel function decreases smoothly as the distance between points increases, which is necessary to maintain a valid GP model and for the covariance matrix to remain positive semidefinite (PSD). This requirement means that for any non-trivial vector
, the condition
must hold. Similarly, the noise variance
must be non-negative. The noise variance contributes to the diagonal elements of the covariance matrix. If
, the diagonal elements of the covariance matrix may become negative, which would violate the requirement for positive semidefiniteness. Negative noise variances do not make sense in a probabilistic model as variances cannot be negative. Thus, ensuring that
is crucial for maintaining the validity of the GP.
When using methods such as the PCE to estimate the lengthscale and noise variance of a GP, it is possible that the values generated may be zero or negative. The PCE can generate any real-valued output within its stochastic domain, including values that are not appropriate for parameters such as lengthscale and noise. A transformation is required to ensure that these hyperparameters satisfy the necessary constraints.
A transformation
is applied to map the estimated lengthscale
and noise
to valid domains
In this setting,
and
denote unconstrained PCE outputs, whereas the GP covariance function is evaluated only with the transformed quantities
and
. The resulting covariance matrix element of input
and
can be written as
so that only strictly positive lengthscales and noise variances enter the kernel.
A common choice for such a transformation is the softplus transformation, which maps any real number to
. The softplus transformation is defined as
By applying this approach, both the lengthscale and the noise remain positive during the HPO process.
To perform versatile modeling tasks with this novel approach, different covariance functions are combined, and the influence of the respective covariance function is controlled by HPO. The combination of the covariance functions is realized by summation of the covariance functions with
The covariance matrix is then computed from the combined covariance function, and the prediction
is determined by combining this matrix with the estimated noise. Finally, the predictions are rescaled to the original range
. In Algorithm 1, the algorithm for model prediction is shown. In this work, the covariance functions and polynomial bases are chosen manually and are not part of the HPO. In
Section 5, the setup of the model for the experiments carried out in this work is presented in detail.
| Algorithm 1 PCEGP model prediction |
Input: Input data Output: Model prediction Specified in the model: Covariance functions , combined covariance function , polynomials for lengthscale , polynomials for noise variance , transformation , transformed hyperparameters and at the training inputs, covariance matrix depending on the training data, and model hyperparameters
- 1:
Step 1: Scale input and output data: - 2:
- 3:
Step 2: Calculate the point-dependent lengthscale (PCE output): - 4:
for do - 5:
- 6:
end for - 7:
Step 3: Transform the point-dependent lengthscale: - 8:
for do - 9:
- 10:
end for - 11:
Step 4: Calculate point-dependent covariance for each training point and kernel, and sum to : - 12:
for do - 13:
- 14:
for do - 15:
- 16:
- 17:
end for - 18:
end for - 19:
Step 5: Summarize covariances into a vector: - 20:
- 21:
Step 6: Compute point-dependent noise variance (PCE output): - 22:
- 23:
Step 7: Transform the point-dependent noise variance: - 24:
- 25:
Step 8: Compute scaled output mean: - 26:
- 27:
Step 9: Compute scaled output variance: - 28:
- 29:
Step 10: Rescale the output: - 30:
|
3.2. Hyperparameter Optimization
In this work, HPO was performed with the tree-structured Parzen estimator (TPE) [
33] and the Nadam optimizer. The Nadam optimizer combines the adaptive learning rate strategy of Adam [
34] with the Nesterov momentum and is introduced in [
35]. The Nadam optimizer is preferred over the Adam optimizer because it achieves faster convergence through the Nesterov momentum, as described in [
35], making it particularly suitable given the large number of PCE coefficients in the model. This optimizer is well suited for the PCEGP approach since the log-marginal likelihood of the model is non-convex, the number of trainable PCE coefficients for the non-stationary lengthscale, and the noise can be large.
In the proposed PCEGP model, the PCE is not trained separately and then combined with the Gaussian process afterwards. Instead, the PCE coefficients directly parameterize the input-dependent GP hyperparameters, in particular the non-stationary lengthscale and, if used, the heteroscedastic noise. These coefficients are therefore optimized jointly within the GP training procedure through the model loss based on the log-marginal likelihood. Consequently, the optimization is carried out with respect to the PCEGP parameter vector as a whole, rather than through separate optimization problems for the PCE and the GP. Adaptive learning rates reduce the need for manual step-size tuning across differently scaled coefficients, and the momentum term stabilizes the optimization in narrow valleys of the objective. On the outer level, a Bayesian hyperparameter search based on the TPE treats Nadam as a black-box inner optimizer and searches over all hyperparameters that are not directly learned by gradient descent. A schematic overview of the optimization loop is given in Algorithm 2. The first step is to investigate the data for the choice of a suitable input and output scaler, covariance functions, and polynomial bases. After that, the data are scaled. A termination criterion has to be selected for the optimization loop, i.e., the number of trials for hyperparameter optimization. Then, the hyperparameter optimization starts with the TPE as a Bayesian approach. First, initial hyperparameter combinations are placed with random search in the entire hyperparameter space. Afterwards, new hyperparameters are suggested via the TPE algorithm.
For the TPE, the objective function for hyperparameter optimization takes the hyperparameters of the model as inputs. This includes the selection of the polynomial degree for the lengthscale and the polynomial degree for the heteroscedastic noise variance calculation. In addition, the scaling factors , the learning rate , the number of gradient iterations , and the initial values of the PCE coefficients are suggested via the TPE. In the case that elastic net regularization is used, the regularization parameters and are also used as hyperparameters for the Bayesian optimization. The hyperparameter space of the PCEGP therefore contains both continuous and discrete variables, such as learning rates, scaling factors, and polynomial degrees, which can be handled in a unified way by the TPE. The model loss serves as the objective function and is minimized during hyperparameter optimization. In this process, the trainable PCE coefficients are updated jointly with the remaining model parameters, where they directly determine the input-dependent GP hyperparameters entering the covariance matrix. A shuffled k-fold cross-validation is used to evaluate this loss, where k different models are trained with a gradient descent method and the hyperparameters of the PCEGP are updated over iterations.
In this work, Bayesian hyperparameter optimization based on the TPE ensures that the gradient descent procedure was performed with informative hyperparameter combinations. In contrast to grid search or pure random search, the TPE learns from poor hyperparameter combinations and reduces the probability of sampling new candidates in these regions. This property is particularly useful in the present setting since each trial is computationally expensive due to cross-validation and multiple gradient descent iterations, and a large part of the hyperparameter space corresponds to clearly suboptimal settings.
During gradient-based model hyperparameter optimization, the covariance matrix depends on the lengthscale PCE coefficients
and the noise PCE coefficients
and is described by
Here,
denotes the prediction of the lengthscale parameters for each data point, obtained from the PCE as a function of the coefficients
and the input
. These input-dependent lengthscales enter the covariance function and, together with the remaining kernel hyperparameters, parameterize the non-stationary covariance matrix
. With
, the prediction of the heteroscedastic noise, depending on the PCE coefficients
and the input
, is denoted and contributes to the diagonal term
. The task of the optimizer therefore shifts from optimizing the lengthscale and noise directly to optimizing the polynomial coefficients of the PCE. The gradient from Equation (
15) is evaluated with respect to these polynomial coefficients for hyperparameter optimization.
| Algorithm 2 Hyperparameter optimization of PCEGP model |
Input: Data , number of trials , number of initial trials , number of folds , number of gradient descent iterations Output: Optimized model hyperparameters and training hyperparameters , , , , Specified: Covariance function , polynomials for lengthscale and noise variance
- 1:
repeat - 2:
Step 1: Suggest hyperparameters: - 3:
if then - 4:
Random Search for , , , , , - 5:
else - 6:
TPE for , , , , , - 7:
end if - 8:
Step 2: Data scaling: - 9:
with scaling parameters on - 10:
for do - 11:
Step 3: Cross-validation data split: - 12:
. - 13:
Step 4: Setup PCEGP Model: - 14:
Define covariance function , polynomials and - 15:
Step 5: Optimize model parameters on training data - 16:
for do - 17:
Compute gradient: - 18:
Update first moment estimate: - 19:
- 20:
Update second moment estimate: - 21:
- 22:
Compute bias-corrected estimates: - 23:
- 24:
, - 25:
Update parameters: - 26:
end for - 27:
Step 6: Compute validation loss: - 28:
end for - 29:
Step 7: Compute average loss across folds: - 30:
- 31:
Step 8: Update best model and training hyperparameters: - 32:
if then - 33:
- 34:
- 35:
end if - 36:
- 37:
until
|
3.4. Runtime Comparison of PCEGP and GP
In this section, a runtime comparison between the standard GP from GPyTorch [
36] and the PCEGP is presented. Three scenarios with
,
1000, and
10,000 for the PCEGP were generated, where three different PCEs were used. For all experiments of the runtime comparison, the squared exponential covariance function was used. The non-stationary lengthscale parameters were calculated with a Legendre polynomial and a uniform distribution in
.
The first configuration was implemented with
and
, resulting in
. To achieve
, a configuration with
and
was employed. The third configuration was implemented with
and
, which resulted in
11,440. For the standard GP, the model training and predictions were performed with
. For all inputs, equidistantly spaced data between 0 and 1 were generated. The output was the simple test function
, where
was generated by summarizing each input
. The experiments were carried out for
up to
with a step size of 50. All experiments were repeated ten times for statistical validation. Each model was trained over 100 gradient descent iterations, with the training time averaged per iteration. The prediction times were calculated by averaging the time required to make predictions for
test data points. The PCEGP model was implemented using the base elements of the GPyTorch library 1.11 for kernel implementations and the SciPy library 1.10.1 [
37] for the implementation of the PCE. The standard GP was implemented using the GPyTorch library. The experiments were conducted on a QEMU virtual CPU with 64 virtual CPUs, 32 GB of RAM, and a clock speed of 2.50 GHz. In
Figure 3, the runtime comparison for training and prediction of the PCEGP and GP is illustrated. The PCEGP approach exhibits training runtimes slightly above the standard GP from GPyTorch per gradient descent iteration. This behavior is consistent with the theoretical analysis in
Figure 2 because both methods are dominated by the cubic GP term in
N, while the PCEGP has an additional
term and a more complex kernel evaluation, which increases the constant factor and shifts the curves upwards. In
Figure 3, faster prediction times of the PCEGP model compared to the standard GP from GPyTorch are shown, even for the largest configuration with
11,440. This behavior is different from what the theoretical prediction complexity in
Figure 2 suggests, where the PCEGP has an additional
term. This difference is explained by implementation-specific constant factors that are not visible in the Big-O notation. The theoretical curves assume identical constant factors for all models and isolate only the dependence on
N and
. In practice, the generic GPyTorch implementation of the standard GP returns a full multivariate normal distribution and includes additional features such as lazy tensor handling and caching, which introduce substantial overhead per prediction. In contrast, the PCEGP implementation is tailored to this application and computes only the quantities required for mean and variance prediction, which avoids unnecessary computations. It should be noted that the theoretical curves in
Figure 2 describe the asymptotic behavior as
N becomes large and neglect constant and lower-order terms. In the experimental setting in
Figure 3, a considerable part of the runtime for small and moderate training set sizes is spent in operations that do not scale with
N, such as Python and library overhead, memory allocation, and kernel setup. In addition, optimized linear algebra routines use blocked and multi-threaded implementations whose efficiency depends on the matrix size. These effects lead to a slower increase of the measured runtimes for small
N, so that the characteristic steep growth of the cubic and quadratic terms becomes visible only for larger training set sizes.
As a result, the constant factor in front of the term is significantly larger for the standard GP than for the PCEGP, and this difference dominates the additional cost of the PCE evaluation in the considered range of N and . The PCEGP model therefore remains competitive and even faster in prediction, despite its slightly higher theoretical complexity. It can also be observed that the prediction runtime for the PCEGP with 11,440 only increases slowly, which indicates a higher overhead of the PCE given the high number of coefficients. However, predicting a data point still takes only about one millisecond and remains faster than the standard GP from GPyTorch as N increases.