Gaussian Process Regression (GPR) is a probabilistic model and non-parametric method that assumes the function is drawn from a Gaussian process. This allows the model to make predictions with well-defined uncertainty, useful for tasks such as uncertainty-aware decision-making. A more complete mathematical description is provided in the Machine Learning for Engineers course on the Gaussian Process Regression learning page.
Optimization Under Uncertainty
The following sections contain the code blocks for Gekko Optimization of a GPR model that minimizes the GPR prediction and uncertainty.
Import Libraries: Import the necessary libraries including NumPy, Matplotlib, Gekko, and Scikit-learn's Gaussian Process Regressor and kernels. Install Gekko if it isn't already installed.
Generate Data: Define a function to generate data with noise and visualizes this data along with the true function.
Data Preparation: Data is split into training and testing sets using train_test_split from scikit-learn.
GPR Model Training: A Gaussian Process Regressor (GPR) is created and trained on the training data. The performance of the model is evaluated using the R-squared metric on the test data.
Model Visualization: The trained GPR model predictions and confidence intervals are plotted against the true function and noisy measurements.
Optimization with Gekko: The Gekko package is used to perform optimization. A variable is created within Gekko and the trained GPR model is used to predict the output and its uncertainty for this variable. Gekko then optimizes this variable to minimize the objective, which in this case is either the predicted value or the uncertainty of the prediction.
Uncertainty Optimization: uncertainty is minimized.
Multi-Objective Uncertainty Optimization: uncertainty and expected values are minimized as a weighted sum.
Results Visualization: Finally, the optimization results are visualized, showing the points of optimized predicted values and uncertainties.
Thanks to LaGrande Gunnell for adding the ML library to Gekko and for the example problem.