GPM
From charlesreid1
GPM = Gaussian Process Modeling
Notes
Link to nice notebook explaining how to implement this in Python: https://blog.dominodatalab.com/fitting-gaussian-process-models-python/
Python Libraries
To do Gaussian Process Modeling, can use several libraries:
- GPFlow (Gaussian Process Modeling using TensorFlow under the hood)
- PyMC3 (PyMC implements Markov-chain Monte Carlo methods for GPM)
- scikit-learn (implements several GPM routines/objects/functions)
These packages principally implement covariance functions that can be used to describe non-linearity in data, and methods for fitting GPM parameters.
Scikit-Learn
scikit-learn has several relevant functions/implementations of GPMs appropriate for different applications:
- GaussianProcessRegressor - create this by specifying an appropriate covariance function (kernel). Fitting is accomplished by maximizing log marginal likelihood (avoids computationally intensive cross-validation strategy). Does not allow for specification of mean function (assumed to be zero). This is because the mean is not as important when computing the posterior.
- GaussianProcessClassifier - useful for classification tasks and fitting categorical/binary data. Uses a latent Gaussian response variable, transforms it to the unit interval (or simplex). Soft probabilisitic classification task, rather than a hard classification prediction. User provides a kernel to describe the covariance in the data set. The posterior is non-normal. Laplace approximation used in place of maximizing marginal likelihood.
Kernels:
from sklearn import gaussian_processwill import code/functions related to Gaussian process modelingfrom sklearn.gaussian_process.kernels import Maternwill import one of about a dozen GPM kernels- Matern covariance is a good, flexible first-choice:
$ k_M(x) = \dfrac{ \sigma^2 }{\Gamma(\nu) 2^{\nu - 1}} \left( \dfrac{ \sqrt{2 \nu} x }{ l } \right)^{\nu} K_{\nu} \left( \dfrac{ \sqrt{2 \nu } x }{ l } \right) $
- $ \sigma $ is amplitude, scalar multiplier that controls y-axis scaling
- $ l $ is length scale, scales realizations laong x-axis
- $ \nu $ is roughness, controls sharpness/smoothing of ridges in covariance function
Example usage:
- A single GPM kernel can be a combination of multiple kernels
- Start by using a Matern component (Matern), then use an amplitude factor (ConstantKernel), then use an observation noise (WhiteKernel) kernel
kernel = ConstantKernel() + Matern(length_scale=2, nu=3/2) + WhiteKernel(noise_level=1)