Skip to content

Commit ba11049

Browse files
committed
code review
1 parent b21ed60 commit ba11049

13 files changed

+161
-192
lines changed

README.md

Lines changed: 70 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
1-
# GPmp: the Gaussian process micro package
1+
# GPmp: the Gaussian Process micro package
22

3-
## What is GPmp?
3+
GPmp is a lightweight toolkit for Gaussian process (GP) modeling. It
4+
provides the essential components for GP-based algorithms with a focus
5+
on speed and customization.
46

5-
GPmp provides simple building blocks for GP-based algorithms. It is meant to
6-
be fast and easily customizable.
7+
## Features
78

8-
The user can choose between three backends to perform numerical
9-
computations: plain numpy, [JAX](https://jax.readthedocs.io/) or
10-
[PyTorch](). When JAX or PyTorch is used, GPmp relies on
11-
auto-differentiation to compute gradients. GPmp also uses JIT
12-
compilation features provided by JAX.
13-
14-
As core features, GPmp implements:
15-
* GP interpolation and regression with known or unknown mean / intrinsinc kriging
16-
* The standard Gaussian likelihood and the restricted likelihood of a model
17-
* Leave-one-out predictions using fast cross-validation formulas
18-
* Conditional sample paths
9+
- **GP interpolation & regression:** Supports known or unknown mean
10+
functions (including intrinsic kriging).
11+
- **Likelihood computation:** standard Gaussian and restricted likelihood.
12+
- **Efficient cross-validation:** fast leave-one-out predictions.
13+
- **Conditional sampling:** generate conditional sample paths.
1914

2015
It is up to the user to write the mean and covariance functions for
2116
setting a GP model.
@@ -28,101 +23,88 @@ However, for the purpose of the example, GPmp provides functions for:
2823
likelihood, or user-defined criteria
2924
* model diagnosis
3025
* vizualization of results
26+
* ...
27+
28+
## Backends
3129

32-
Note also that for the purpose of simplicity, the gpmp does not check
33-
the validity of arguments. This is left to the responsibility of the
34-
user / calling code.
30+
GPmp supports three numerical backends:
31+
- **PyTorch:** Dynamic computation with auto-differentiation.
32+
- **JAX:** Auto-differentiation with JIT compilation.
33+
- **NumPy:** Basic computation (default if neither PyTorch nor JAX are
34+
found).
35+
36+
On startup, GPmp automatically selects the backend in this order:
37+
PyTorch → JAX → NumPy. You can override this by setting the
38+
`GPMP_BACKEND` environment variable before launching GPmp.
3539

3640
## Installation
3741

38-
Clone the git repository:
39-
```
42+
Clone the repository:
43+
```bash
4044
git clone https://github.com/gpmp-dev/gpmp.git
4145
```
42-
(or download a zip version)
43-
44-
Install in dev mode:
45-
```
46+
Install in development mode:
47+
```bash
4648
pip install -e .
4749
```
4850

49-
Remarks:
50-
51-
1. It is recommended to run GPmp using PyTorch or JAX as a backend instead of Numpy.
52-
53-
2. Upon initialization, GPmp automatically detects if PyTorch is
54-
installed and sets the GPMP_BACKEND environment variable to 'torch'
55-
by default. If PyTorch is not found, it then searches for JAX and
56-
sets GPMP_BACKEND to 'jax'. If neither PyTorch nor JAX are
57-
detected, GPmp defaults to using Numpy, setting the GPMP_BACKEND
58-
environment variable to 'numpy'. Users have the option to manually
59-
override the chosen backend by setting the GPMP_BACKEND variable
60-
before launching GPmp.
61-
62-
2. JAX, which requires jaxlib, which is
63-
supported on Linux and macOS platforms, and on Windows via the
64-
Windows Subsystem for Linux. There is some initial native Windows
65-
support, but it is still somewhat immature (see below).
66-
67-
2. To install JAX with both CPU and NVidia GPU support, CUDA and CuDNN
68-
must be installed first. See
69-
https://github.com/google/jax#installation and
70-
https://jax.readthedocs.io/en/latest/changelog.html for details.
71-
72-
For instance, to install jaxlib with Cuda 11 and cudnn 8.2 or newer:
73-
```bash
74-
pip install jax[cuda11_cudnn82] -f https://storage.googleapis.com/jax-releases/jax_releases.html
75-
```
76-
77-
3. To install jaxlib on Windows, one can follow instructions at
78-
https://github.com/cloudhan/jax-windows-builder. Select and
79-
download a version of jaxlib from
80-
https://whls.blob.core.windows.net/unstable/index.html according to
81-
your Python version. Then install jax manually.
82-
83-
```powershell
84-
pip install <jaxlib_whl>
85-
pip install jax
86-
```
51+
### Backend Setup
52+
53+
- **PyTorch:** Recommended for best performance.
54+
- **JAX:**
55+
- For CPU-only usage, install directly from PyPI:
56+
```bash
57+
pip install jax
58+
```
59+
- For NVIDIA GPU support (e.g., with CUDA 12), run:
60+
```bash
61+
pip install -U "jax[cuda12]"
62+
```
63+
Detailed, platform-specific instructions are available in the
64+
[official JAX documentation](https://github.com/google/jax#installation).
8765

8866
## Usage
8967

90-
Please refer to the examples that illustrate the different features of GPmp.
68+
Check the examples in the repository for a quick start. Customize your
69+
own mean and covariance functions as needed.
9170

92-
## Documentation with Sphinx
93-
The automatic documentation is created using [Sphinx](https://www.sphinx-doc.org/en/master/) and following the python docstrings recommendations from [numpydoc](https://numpydoc.readthedocs.io/en/latest/format.html)
71+
## Documentation
9472

95-
The html theme is taken from
96-
>pip install pydata_sphinx_theme
73+
GPmp’s documentation is built with
74+
[Sphinx](https://www.sphinx-doc.org/en/master/) using the PyData
75+
theme. To generate the HTML documentation:
9776

98-
In order to generate the intereactive html:
99-
>cd ./doc
100-
101-
>make html
77+
```bash
78+
cd doc
79+
make html
80+
```
10281

103-
## To do
82+
## How to Cite
10483

105-
* write documentation
84+
If you use GPmp in your research, please cite it as follows:
10685

107-
## Authors
86+
```bibtex
87+
@software{gpmp2025,
88+
author = {Emmanuel Vazquez},
89+
title = {GPmp: the Gaussian Process micro package},
90+
year = {2025},
91+
url = {https://github.com/gpmp-dev/gpmp},
92+
note = {Version x.y},
93+
}
94+
```
10895

109-
See AUTHORS.md
96+
*Please update the version number as appropriate.*
11097

111-
## Copyright
98+
## Future Work
11299

113-
Copyright (C) 2022-2024 CentraleSupelec
100+
- Expand documentation and tutorials.
101+
- Enhance diagnostic tools and model visualization.
114102

115-
## License
103+
## Authors
116104

117-
GPmp is free software: you can redistribute it and/or modify it
118-
under the terms of the GNU General Public License as published by
119-
the Free Software Foundation, either version 3 of the License, or
120-
(at your option) any later version.
105+
See [AUTHORS.md](AUTHORS.md) for details.
121106

122-
GPmp is distributed in the hope that it will be useful, but WITHOUT
123-
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
124-
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
125-
License for more details.
107+
## License
126108

127-
You should have received a copy of the GNU General Public License
128-
along with gpmp. If not, see http://www.gnu.org/licenses/.
109+
GPmp is free software released under the GNU General Public License v3.0.
110+
See [LICENSE](LICENSE.txt) for more details.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.9.18
1+
0.9.19

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
- 0.9.19 introduce 'DifferentiableFunction' to encapsulate gradient computation, code enhancement
12
- 0.9.18 small improvements in kernel.py and num.py
23
- 0.9.17 refactor parameter selection procedures for more general selection criteria support
34
- 0.9.16 changes in core.py, num.py about Cholesky factorization

examples/gpmp_example02_1d_interpolation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Plot and optimize the restricted negative log-likelihood
33
44
Author: Emmanuel Vazquez <[email protected]>
5-
Copyright (c) 2022-2024, CentraleSupelec
5+
Copyright (c) 2022-2025, CentraleSupelec
66
License: GPLv3 (see LICENSE)
77
"""
88

examples/gpmp_example03_2d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
1515
----
1616
Author: Emmanuel Vazquez <[email protected]>
17-
Copyright (c) 2022-2024, CentraleSupelec
17+
Copyright (c) 2022-2025, CentraleSupelec
1818
License: GPLv3 (see LICENSE)
1919
----
2020
This example is based on the file stk_example_kb03.m from the STK at

examples/gpmp_example04_nd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
1414
----
1515
Author: Emmanuel Vazquez <[email protected]>
16-
Copyright (c) 2022-2024, CentraleSupelec
16+
Copyright (c) 2022-2025, CentraleSupelec
1717
License: GPLv3 (see LICENSE)
1818
"""
1919
import gpmp.num as gnp

examples/gpmp_example06_1d_regression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
----
66
Author: Emmanuel Vazquez <[email protected]>
7-
Copyright (c) 2022-2024, CentraleSupelec
7+
Copyright (c) 2022-2025, CentraleSupelec
88
License: GPLv3 (see LICENSE)
99
----
1010
This example is based on the file stk_example_kb01.m from the STK at

examples/gpmp_example20_1d_interpolation_variation_remap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Plot and optimize the restricted negative log-likelihood
33
44
Author: Emmanuel Vazquez <[email protected]>
5-
Copyright (c) 2022-2024, CentraleSupelec
5+
Copyright (c) 2022-2025, CentraleSupelec
66
License: GPLv3 (see LICENSE)
77
"""
88

examples/gpmp_example21_1d_interpolation_variation_reml.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Plot and optimize the restricted negative log-likelihood
33
44
Author: Emmanuel Vazquez <[email protected]>
5-
Copyright (c) 2022-2024, CentraleSupelec
5+
Copyright (c) 2022-2025, CentraleSupelec
66
License: GPLv3 (see LICENSE)
77
"""
88

@@ -82,10 +82,12 @@ def main():
8282
covparam0 = gp.kernel.anisotropic_parameters_initial_guess(model, xi, zi)
8383

8484
# selection criterion
85+
selection_criterion = gp.kernel.negative_log_restricted_likelihood
8586
nlrl, dnlrl = gp.kernel.make_selection_criterion_with_gradient(
86-
model, gp.kernel.negative_log_restricted_likelihood, xi, zi
87+
model, selection_criterion, xi, zi
8788
)
8889

90+
# optimize parameters
8991
covparam_reml, info = gp.kernel.autoselect_parameters(
9092
covparam0, nlrl, dnlrl, silent=False, info=True
9193
)

examples/gpmp_example22_1d_interpolation_variation_ml.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Plot and optimize the restricted negative log-likelihood
33
44
Author: Emmanuel Vazquez <[email protected]>
5-
Copyright (c) 2022-2024, CentraleSupelec
5+
Copyright (c) 2022-2025, CentraleSupelec
66
License: GPLv3 (see LICENSE)
77
"""
88

0 commit comments

Comments
 (0)