Python module for constrained GP regression.
Code based on the paper C. Agrell (2019) Gaussian processes with linear operator inequality constraints. The current implementation covers boundedness of the function to estimate, combined with bounds on its first order partial derivatives, using the RBF or Matérn5/2 kernel.
Besides the standard numpy/scipy libraries, rpy2 is used to access some useful R packages for working with the truncated multivariate normal distribution. The code has been tested with the following requirements:
Python 3 (3.6.3 64bit)
- numpy (1.14.0)
- scipy (1.1.0)
- pandas (0.22.0)
- sklearn (0.19.1) Only uses the function sklearn.metrics.pairwise.euclidean_distances from this package for fast computation of Gram matrices (and could easily be replaced by custom code if needed)
- rpy2 (2.8.6) Used to acces R for computation involving the truncated multivariate normal. See the Python wrapper in '/GPConstr/r_functions/' for details
R (3.4.3)
- tmvtnorm (1.4.10)
- mvtnorm (1.0.7)
- TruncatedNormal (1.0)
- truncnorm (1.0.8)
Some examples are given in jupyter notebooks. pyDOE is used to generate training data, and plots are created using plotly with some custom plotting functions for GPs.
- Example_1a.ipynb 1D example of boundedness and monotonicity constraints
- Example_1b.ipynb 1D example of boundedness and monotonicity constraints - with noise
- Example_2.ipynb Emulation in 4D with derivative information
- Example_3.ipynb Regression in 5D with derivative information
We will be including other types of constraints and kernels as needed, either buidling on the current implementation or on a suitable GP library with good functionality for kernel manupulation such as e.g. GPflow