Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/swyoon/pytorch-minimal-gaussian-process
A minimal implementation of Gaussian process regression in PyTorch
https://github.com/swyoon/pytorch-minimal-gaussian-process
gaussian-process gaussian-process-regression gaussian-processes pytorch
Last synced: 6 days ago
JSON representation
A minimal implementation of Gaussian process regression in PyTorch
- Host: GitHub
- URL: https://github.com/swyoon/pytorch-minimal-gaussian-process
- Owner: swyoon
- Created: 2021-12-30T12:11:05.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-08T01:53:59.000Z (almost 2 years ago)
- Last Synced: 2024-08-03T09:08:53.880Z (4 months ago)
- Topics: gaussian-process, gaussian-process-regression, gaussian-processes, pytorch
- Language: Jupyter Notebook
- Homepage:
- Size: 492 KB
- Stars: 59
- Watchers: 1
- Forks: 12
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pytorch-minimal-gaussian-process
In search of truth, simplicity is needed. There exist heavy-weighted libraries, but as you know, we need to go bare bone sometimes.
Here is a minimal implementation of Gaussian process regression in PyTorch.The implementation generally follows Algorithm 2.1 in [Gaussian Process for Machine Learning (Rassmussen and Williams, 2006)](http://www.gaussianprocess.org/gpml/).
* Author: [Sangwoong Yoon](https://swyoon.github.io/), [Hyeokjun Kwon](https://www.linkedin.com/in/hyeokjun-kwon-24b992210)
## Features
* Gaussian process regression with squared exponential kernel.
* Hyperparameter optimization via marginal likelihood maximization using Pytorch built-in autograd functionality. (See `demo.ipynb`)
* Unittesting using Pytest.## Updates
* 2022-01-01: Bugfix in predictive variance computation
* 2023-01-03: Implement binary Laplace Gaussian process regression## Dependency
* Numpy
* PyTorch
* PyTest
* Matplotlib (for demo)## How to Use
### Gaussian process regression
```python
from gp import GP# generate data
X = torch.randn(100,1)
y = torch.sin(X * 2 * np.pi /4). + torch.randn(100, 1) * 0.1
grid = torch.linspace(-5, 5, 200)[:,None]# run GP
gp = GP() # you may specify initial hyperparameters using keyword arguments
gp.fit(X, y)
mu, var = gp.forward(grid)
```### Gaussian process classification
```python
from gp import GP# generate data
X = torch.randn(100,1)
f = torch.sin(X * 3 * np.pi / 4)
y = (f > 0.).int() * 2 - 1
grid = torch.linspace(-5, 5, 200)[:,None]# run GP
gp = BinaryLaplaceGPC() # you may specify initial hyperparameters using keyword arguments
gp.fit(X, y)
mu, var, pi = gp.forward(grid)
```
## Unittesting```
$ pytest
```## See also
* [GPyTorch](https://gpytorch.ai/): A full-featured Gaussian process package based on PyTorch.