Tools for diagnosing Gaussian Process models
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gp_diagnostics-0.1.0.tar.gz.
File metadata
- Download URL: gp_diagnostics-0.1.0.tar.gz
- Upload date:
- Size: 2.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.30
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db055a5cb5f76c1a687914a27a7b901067840e7bff00c8282a93ddbf4fc15cd8
|
|
| MD5 |
ee5e070ae30e95436b407adc1adbe456
|
|
| BLAKE2b-256 |
d005a51de9a93f3c63f4d8905a0702674704e9ab14d2fb0be5fcf2f9d35a2b69
|
File details
Details for the file gp_diagnostics-0.1.0-py3-none-any.whl.
File metadata
- Download URL: gp_diagnostics-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.30
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d35b58abdd8b28b564d1b215723d36a2b23337b05e1005072abfbefd226b3964
|
|
| MD5 |
b51eb7471ade2f5fc37eb5e8b6c7d6dd
|
|
| BLAKE2b-256 |
dbf9378d808166337b5a554be717523a28b18f03c122f5516cd3cd62a79d2d67
|