src.variants.metamodels.regression module

This module is responsible for training and inference of linear and polynomial regression models.

It includes linear and polynomial regression: - It includes the two functions train_linear_regression_model and infer_linear_regression_model for training and inference of linear regression models. It includes the two functions prepare_lr_prediction_interval and calc_lr_prediction_interval for the corresponding calculation of external prediction intervals. - It includes the two functions train_polynomial_regression_model and infer_polynomial_regression_model for training and inference of polynomial regression models. See details in their own documentations.

The theory of these non-simultaneous Bonferroni-type prediction intervals can be found, e.g., in [1, Sec. 5.5], [2, Sec. 5.3], [3, Ch. 13.7.3], and [4, Ch. 3.2.1].

Literature: [1] C. J. Roy and W. L. Oberkampf, „A comprehensive framework for verification, validation, and uncertainty quantification in scientific computing,“ Computer Methods in Applied Mechanics and Engineering, vol. 200, no. 25-28, pp. 2131–2144, 2011. [2] C. J. Roy and M. S. Balch, „A Holistic Approach to Uncertainty Quantification with Application to Supersonic Nozzle Thrust,“ International Journal for Uncertainty Quantification, vol. 2, no. 4, pp. 363–381, 2012. [3] W. L. Oberkampf and C. J. Roy, Verification and Validation in Scientific Computing, Cambridge, Cambridge University Press, 2010, ISBN: 9780511760396. [4] R. G. Miller, Simultaneous Statistical Inference, New York, NY, Springer New York, 1981, ISBN: 978-1-4613-8124-2.

Contact person: Stefan Riedmaier Creation date: 07.09.2020 Python version: 3.8

src.variants.metamodels.regression.calc_prediction_interval(x, design_array, mse, t_value)

This function calculates external prediction intervals for a linear and polynomial regression.

Parameters:
  • x (np.ndarray) – input array for prediction

  • design_array (np.ndarray) – input array from training, extended to linear model coefficients

  • mse (float) – mean squared error

  • t_value (float) – t-value from t-distribution

Returns:

prediction interval

Return type:

np.ndarray

src.variants.metamodels.regression.infer_linear_regression_model(x, model)

This function predicts outputs using the linear regression model.

Parameters:
  • x (np.ndarray) – input data

  • model – trained linear regression model

Returns:

predicted outputs

Return type:

np.ndarray

src.variants.metamodels.regression.infer_polynomial_regression_model(x, model, degree=2)

This function predicts outputs using the polynomial regression model.

Parameters:
  • x (np.ndarray) – input data

  • model – trained linear regression model

  • degree – (optional) degree of the polynomial

Returns:

predicted outputs

Return type:

np.ndarray

src.variants.metamodels.regression.prepare_lr_prediction_interval(x, y, model, alpha=0.95)

This function calculates the design array, mean squared error and t-value of the linear regression model.

The three of them are required for the subsequent calculation of external prediction intervals.

Parameters:
  • x (np.ndarray) – inputs

  • y (np.ndarray) – ouputs

  • model – trained linear regression model

  • alpha (float) – (optional) level of significance (probability of making type I error)

Returns:

design array, mean squared error and t-value

Return type:

tuple(np.ndarray, float, float)

src.variants.metamodels.regression.prepare_pr_prediction_interval(x, y, model, degree, alpha=0.95)

This function calculates the design array, mean squared error and t-value of the polynomial model.

The three of them are required for the subsequent calculation of external prediction intervals.

Parameters:
  • x (np.ndarray) – inputs

  • y (np.ndarray) – ouputs

  • model – trained polynomial regression model

  • degree – degree of the polynomial model

  • alpha (float) – (optional) level of significance (probability of making type I error)

Returns:

design array, mean squared error and t-value

Return type:

tuple(np.ndarray, float, float)

src.variants.metamodels.regression.train_linear_regression_model(x, y)

This function trains a multiple linear regression model.

Parameters:
  • x (np.ndarray) – inputs

  • y (np.ndarray) – outputs

Returns:

trained linear regression model

src.variants.metamodels.regression.train_polynomial_regression_model(x, y, degree=2)

This function trains a polynomial regression model using sklearn.

Parameters:
  • x (np.ndarray) – input array

  • y (np.ndarray) – output array

  • degree (int) – (optional) degree of the polynomial

Returns:

polynomial regression model