Giter VIP home page Giter VIP logo

andrewwango / gpr-mcmc Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 2.48 MB

Gaussian Process Regression (GPR) with non-Gaussian likelihoods using robust infinite-dimension Monte Carlo Markov Chain (MCMC) sampling for spatial inference problems

License: Apache License 2.0

Python 17.40% Jupyter Notebook 82.60%
gaussian-process-regression gaussian-processes mcmc monte-carlo-markov-chain spatial-interpolation spatial-regression preconditioned-crank-nicholson

gpr-mcmc's Introduction

Gaussian Process Regression using Monte Carlo Markov Chain sampling

Gaussian Process Regression (GPR) with non-Gaussian likelihoods using robust infinite-dimension Monte Carlo Markov Chain (MCMC) sampling.

Why?

Gaussian Process Regression is only available in exact, closed form when the data likelihood is assumed to be Gaussian. However, in many use-cases data can be:

  • Discrete count data (such as population), in which case the most appropriate likelihood is Poisson;
  • Binary classification data, in which case an appropriate likelihood could be the probit model.

To deal with this, there are a number of approximation methods, such as the Laplace approximation. See [Murphy: Probabilistic Machine Learning: Advanced Topics (Section 18.4)] for an excellent treatment. The scikit-learn GP classification uses the Laplace method.

The MCMC sampling approach is attractive as we can theoretically sample from any non-conjugate likelihood to simulate an exact solution. This works using a Metropolis-Hastings style accept/reject step informed by the given likelihood.

However, the performance of traditional Metropolis-Hastings suffers in high dimensions such as in spatial problems where there are many data points, because the acceptance probability in the Metropolis step degenerates to zero. In this repo we implement MCMC using the preconditioned Crank-Nicholson proposal step, which is well-defined in infinite dimensions.

Usage

Use the algorithm as you would normally use scikit-learn Gaussian Process regression or classification:

>>> import numpy as np
>>> from gpr_mcmc import GaussianProcessMCMCRegressor as GPMR
>>> gpmr = GPMR(
    ell=0.2, # default RBF kernel length
    log_likelihood='poisson',
    random_state=np.random.default_rng(42) # seed for MCMC sampling
    )
>>> gpmr.fit(X_train, y_train)
gpr_mcmc.gpr_mcmc.GaussianProcessMCMCRegressor
>>> gpmr.score(X_test, y_test, method="mae") # mean absolute error

See demo.ipynb for a real example using spatial data.

Main options

  • mcmc_method: MCMC variant to use. "grw" is Gaussian random walk - Metropolis-Hastings with a Gaussian prior proposal. "pcn" is preconditioned Crank-Nicholson which does not degenerate in infinite-dimensions.
  • log_likelihood: If str, must be one of poisson, gaussian or probit. If a callable, see likelihoods.py for example implementations.
  • kernel: Any GPR kernel from scikit-learn Kernel API. If None, RBF kernel is used with ell given by ell.
  • beta: step size using in MCMC proposals. Controls the "temperature" of the sampling.

gpr-mcmc's People

Contributors

andrewwango avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.