gp-diagnostics
gp-diagnostics is a Python library for diagnosing Gaussian Process (GP) models. It provides tools for advanced cross-validation, residual analysis, and visualization to support the evaluation and interpretation of GP regression models.
Key Features
-
Cross-Validation
- Leave-One-Out (LOO) or Multifold CV for GP regressions with optional fixed observational noise.
- Fast computation of CV residuals (including covariance) based on the approach by Ginsbourger and Schaerer (2021).
- Cholesky-based implementations with fallback checks for matrix definiteness.
-
GP Evaluation Metrics
- Functions to compute log marginal likelihood, pseudo-likelihood (for CV), and mean squared error.
- Easy integration with existing GP code to measure model performance and residual normality.
-
Diagnostic Plots
- Histogram of residuals, QQ plots, predictions vs. true values, and more.
- Interactive Plotly figures for easy exploration and diagnostics.
Installation
pip install gp-diagnostics
Usage
See examples/example.ipynb and examples/exact_gp_example.ipynb for detailed usage examples.
Core Modules
1. cv.py
loo(): Leave-One-Out CV residuals and covariance.multifold(): Multifold CV for grouped data (e.g., multiple time series).- Both handle GP prior covariance plus optional noise variance.
2. metrics.py
evaluate_GP(): Calculates log marginal likelihood, pseudo-likelihood, and MSE.log_prob_normal()andlog_prob_standard_normal(): Useful log probability helpers.
3. plots.py
- Plotly-based functions to visualize residuals (histogram, QQ), predictive intervals, etc.
qq_residuals(),hist_residuals(),pred_vs_error(), and more for quick diagnostics.
4. utils
checks.py: Validations (e.g., numeric array, lower-triangular).linalg.py: Cholesky utilities, triangular solves, matrix inversion.stats.py: QQ data generation, partitioning data folds, etc.
Contributing
Please feel free to open issues or submit pull requests if you have ideas for improvements or bug fixes.
For local development (requires uv)
- Clone this repository.
- Install dependencies with
uv sync - Implement your changes and add tests.
- Submit a pull request to
mainwhen ready.
Testing
All tests live under the tests/ directory. To run them:
# With pytest:
pytest
# Or with tox (runs multiple Python versions, if available):
tox
Authors
- Christian Agrell (christian.agrell@dnv.com)
- Magnus Kristiansen (magnus.kristiansen@dnv.com)
License
MIT License
© 2024 DNV. See LICENSE for details.
Metadata
Release files for gp-diagnostics 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gp_diagnostics-0.1.0.tar.gz | 2.4 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gp_diagnostics-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 2.4 MB
Release files / gp_diagnostics-0.1.0.tar.gz
| Download URL | gp_diagnostics-0.1.0.tar.gz |
|---|---|
| Size | 2.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
db055a5cb5f76c1a687914a27a7b901067840e7bff00c8282a93ddbf4fc15cd8
|
|
BLAKE2b-256 checksum How to use checksums |
d005a51de9a93f3c63f4d8905a0702674704e9ab14d2fb0be5fcf2f9d35a2b69
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.30
|
Release files / gp_diagnostics-0.1.0-py3-none-any.whl
| Download URL | gp_diagnostics-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d35b58abdd8b28b564d1b215723d36a2b23337b05e1005072abfbefd226b3964
|
|
BLAKE2b-256 checksum How to use checksums |
dbf9378d808166337b5a554be717523a28b18f03c122f5516cd3cd62a79d2d67
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.30
|