Welcome to kingpin’s documentation!
kingpin 🎳
👀 Treed Gaussian process algorithm
Install 💥
pip install kingpin-tgp
Demo
kingpin example/motorcyle.txt
Features
Flexible allowing you to build GP models using any GP library you like 📦
Treed GPs to handle non-stationary data 🌟
Theory
We implement a treed Gaussian process (TGP) algorithm [1] in Python. A TGP automatically partitions the input space and trains a GP in each partition. This allows us to model non-stationary data, heteroscedastic noise and divide and conquer large datasets. The GP hyperparameters and the number and locations of divisions are marginalised using recursive-jump MCMC.
Example
First we import the kingpin package
import kingpin as kp
We use numpy to create a dataset
import numpy as np
x = np.linspace(0, 10, 101)
y = 100. * np.ones_like(x)
y[x > 5.05] = 300.
y[x > 7.55] = 100.
noise = np.ones_like(x)
and choose prediction points
p = np.linspace(x.min(), x.max(), 201)
Now we are ready to make our TGP model. We use the from_data constructor. This means that hyperparameter and tree modelling choices are based on peeking at the data
tgp = kp.TGP.from_data(x, y, noise, p)
Alternatively, all aspects of the model can be chosen by hand. Now we run RJ-MCMC to marginalise the hyperparameters and tree structure
tgp.walk(n_threads=1, n_iter=1000, n_burn=500)
Finally, we cam take a look at results
tgp.plot()
tgp.mean
tgp.cov
and diagnostics
tgp.acceptance
tgp.arviz_summary()
More examples
BibTeX
@article{tgp,
title = {{Bayesian Treed Gaussian Process Models With an Application to Computer Modeling}},
author = {Robert B Gramacy and Herbert K. H Lee},
year = 2008,
journal = {Journal of the American Statistical Association},
publisher = {Taylor & Francis},
volume = 103,
number = 483,
pages = {1119--1130},
doi = {10.1198/016214508000000689},
}
API
References
Robert B Gramacy and Herbert K. H Lee. Bayesian Treed Gaussian Process Models With an Application to Computer Modeling. Journal of the American Statistical Association, 103(483):1119–1130, 2008. doi:10.1198/016214508000000689.