From charlesreid1

Line 22: Line 22:
Kernels:
Kernels:
* <code>from sklearn import gaussian_process</code> will import code/functions related to Gaussian process modeling
* <code>from sklearn import gaussian_process</code> will import code/functions related to Gaussian process modeling
* <code>from sklearn.gaussian_process.kernels import Matern, WhiteKernel, ConstantKernel</code> will import three (of about a dozen) GPM kernels
* <code>from sklearn.gaussian_process.kernels import Matern</code> will import one of about a dozen GPM kernels
* Matern covariance is a good, flexible first-choice:
* Matern covariance is a good, flexible first-choice:



Revision as of 00:13, 6 November 2017

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_process will import code/functions related to Gaussian process modeling
  • from sklearn.gaussian_process.kernels import Matern will 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