PolynomialChaosExpansion Class

The PolynomialChaosExpansion class is imported using the following command:

>>> from UQpy.surrogates.polynomial_chaos.PolynomialChaosExpansion import PolynomialChaosExpansion

Methods

class PolynomialChaosExpansion(polynomial_basis, regression_method)[source]

Constructs a surrogate model based on the Polynomial Chaos Expansion (polynomial_chaos) method.

Parameters:

regression_method (Regression) – object for the method used for the calculation of the polynomial_chaos coefficients.

fit(x, y)[source]

Fit the surrogate model using the training samples and the corresponding model values. This method calls the run() method of the input method class.

Parameters:
  • x (ndarray) – containing the training points.

  • y (ndarray) – containing the model evaluations at the training points.

The fit() method has no returns and it creates an numpy.ndarray with the polynomial_chaos coefficients.

predict(points, **kwargs)[source]

Predict the model response at new points. This method evaluates the polynomial_chaos model at new sample points.

Parameters:

points (ndarray) – Points at which to predict the model response.

Returns:

Predicted values at the new points.

leaveoneout_error()[source]

Returns the cross validation error (leave-one-out) based on experimental design.

The PolynomialChaosExpansion.leaveoneout_error() method can be used to estimate the accuracy of the PCE predictor without additional simulations. Leave-one-out error \(Q^2\) is calculated from differences between the original mathematical model and approximation \(\Delta_i= \mathcal{M} (x^{(i)}) - \mathcal{M}^{PCE}(x^{(i)})\) as follows:

\[Q^2 = \mathbb{E}[(\Delta_i/(1-h_i))^2]/\sigma_Y^2\]

where \(\sigma_Y^2\) is a variance of model response and \(h_i\) represents the \(i\) th diagonal term of matrix \(\mathbf{H}= \Psi ( \Psi^T \Psi )^{-1} \Psi^T\) obtained from design matrix \(\Psi\) without additional simulations [59].

Returns:

Cross validation error of experimental design.

validation_error(x, y)[source]

Returns the validation error.

The PolynomialChaosExpansion.validation_error() method can be used to estimate the accuracy of the PCE predictor. Here, we compute the generalization error in the form of the relative mean squared error normalized by the model variance. The user must create an independent validation dataset \([x_{val}, y_{val} = M(x_{val})]\) (i.e. a set of inputs and outputs of the computational model).

In case where the computational model is very expensive, the use of an alternative error measure is recommended, for example the cross-validation error which partitions the existing training dataset into subsets and computes the error as the average of the individual errors of each subset.

Parameters:
Returns:

Validation error.

get_moments(higher=False)[source]

Returns the first four moments of the polynomial_chaos surrogate which are directly estimated from the polynomial_chaos coefficients.

The PolynomialChaosExpansion.get_moments() method can be used for the calculation of the first two moments of the PCE model directly from the PCE coefficients. This is possible due to the orthonormality of the polynomial basis.

The first moment (mean value) is calculated as

\[\mu_{PCE} = \mathbb{E} [ \mathcal{M}^{PCE}(x)] = y_{0}\]

where \(y_{0}\) is the first PCE coefficient associated with the constant term.

The second moment (variance) is calculated as

\[\sigma^{2}_{PCE} = \mathbb{E} [( \mathcal{M}^{PCE}(x) - \mu_{PCE} )^{2} ] = \sum_{i=1}^{p} y_{i}\]

where \(p\) is the number of polynomials (first PCE coefficient is excluded).

The third moment (skewness) and the fourth moment (kurtosis) are generally obtained from third and fourth order products obtained by integration, which are extremely computationally demanding. Therefore here we use analytical solution of standard linearization problem for Hermite (based on normalized Feldheim’s formula ) and Legendre polynomials (based on normalized Neumann-Adams formula), though it might be still computationally demanding for high number of input random variables.

Parameters:

higher (bool) – True corresponds to calculation of skewness and kurtosis (computationaly expensive for large basis set).

Returns:

Returns the mean and variance.

Attributes

PolynomialChaosExpansion.polynomial_basis: PolynomialBasis

Contains the 1D or ND chaos polynomials that form the PCE basis

PolynomialChaosExpansion.multi_index_set: ndarray

Multi-index-set

PolynomialChaosExpansion.coefficients: ndarray

Polynomial Chaos Expansion Coefficient

PolynomialChaosExpansion.bias: ndarray

Bias term in case LASSO or ridge regression are employed to estimate the PCE coefficients

PolynomialChaosExpansion.outputs_number: int

Dimensions of the quantities of interest

PolynomialChaosExpansion.design_matrix: ndarray

Matrix containing the evaluations of the PCE basis on the experimental design that has been used to fit the PCE coefficients

PolynomialChaosExpansion.experimental_design_input: ndarray

Realizations of the random parameter in the experimental design that has been used to fit the PCE coefficients

PolynomialChaosExpansion.experimental_design_output: ndarray

Model outputs for the random parameter realizations of the experimental design that has been used to fit the PCE coefficients

Examples