ResPolyGP: Orthogonal Legendre Trajectory Gaussian Process Prior Model
Project description
ResPolyGP
ResPolyGP is a Python library for Gaussian Process (GP) trajectory modeling that resolves standard exact GP computational bottlenecks and non-convex initialization challenges on non-stationary, cyclical sequence extrapolation.
By formulating secular polynomial trends as a structured finite-rank prior over Legendre orthogonal basis functions ($K = \Phi A \Phi^\top + \sigma_n^2 I$), ResPolyGP utilizes the Woodbury Matrix Identity and Matrix Determinant Lemma to project the standard cubic exact GP complexity onto a tiny basis space.
This accelerates exact GP polynomial trend inference from $O(N^3)$ time and $O(N^2)$ memory to $O(ND^2 + D^3)$ time and $O(ND + D^2)$ memory (where $D$ is the active basis degree, typically $D \le 5 \ll N$), delivering up to a 1000x computational speedup without any approximation.
Key Features
- Orthogonal Bounded Legendre Kernels: Replaces standard unstable monomial trend kernels with recursively computed Legendre orthogonal polynomials mapped onto $x \in [-1, 1]$ to prevent floating-point underflow/overflow and preserve conditioning.
- True $O(ND^2 + D^3)$ Woodbury Solver: Employs Woodbury matrix inversion and matrix determinant lemma in low-rank space, bypassing the Cholesky bottleneck and completely preventing
NotPSDError. - Sequential Significance Early Stopping: Filters polynomial degrees dynamically via a variance-explained significance threshold ($q_d < 0.01$) to prevent overfitting to local noise crests.
- Simplex-Constrained Softmax Priors: Normalizes and refines components on the simplex ($\sum \alpha_k = 1.0$), ensuring structural regularization.
- Shape Parameter Freezing / Weights-Only Tuning: Locks shape parameters (e.g. Lomb-Scargle periods and ACF stochastic decay lengths) at their analytical time-domain values, optimizing only mixture weights to eliminate optimization drift.
- Spectral Healing: Detrends secular trends analytically to restore stationarity before Lomb-Scargle periodic detection, reducing periodic extrapolation error by over 80%.
Installation
You can install ResPolyGP directly from PyPI:
pip install respolygp
Dependencies
- Python >= 3.8
numpyscipytorchgpytorch
Quickstart
Below is a simple example showing how to initialize, fit, and predict with ResPolyGPModel.
import numpy as np
from respolygp import ResPolyGPModel
# 1. Generate a noisy cubic trajectory
np.random.seed(42)
t_raw = np.linspace(10, 50, 100)
# Standardized time mapping to [-1, 1]
t_norm = (t_raw - 10) / 40.0 * 2.0 - 1.0
y_raw = 5.0 + 3.0 * t_norm - 2.0 * t_norm**2 + 4.0 * t_norm**3 + np.random.normal(0, 0.1, 100)
# 2. Instantiate and run Legendre trend decomposition
model = ResPolyGPModel(max_degree=5, sig_threshold=0.01, use_robust_scale=True)
decomp = model.fit_decomposition(t_raw, y_raw)
print(f"Active Legendre degrees: {decomp['parameters']['active_degrees']}")
# 3. Initialize hyperparameters from analytical time-domain components
model.initialize_hyperparameters(t_raw, y_raw)
# 4. Refine simplex weights via Adam optimizer
history = model.fit_gp(t_raw, y_raw, lr=0.05, epochs=15, verbose=True)
# 5. Predict out-of-sample in raw physical scale units
t_test = np.array([55.0, 60.0])
mean, var, lower, upper = model.predict_raw(t_test)
print(f"Extrapolated mean: {mean}")
print(f"Extrapolated variance: {var}")
print(f"95% Confidence Bounds: [{lower}, {upper}]")
For additive systems combining both Legendre trends and Lomb-Scargle periodic components, use MostlyFinalAdditiveGPModel:
from respolygp import MostlyFinalAdditiveGPModel
model = MostlyFinalAdditiveGPModel(max_degree=5, sig_threshold=0.01, use_robust_scale=True)
# Runs the full Sequential Reversal (Periodic-First) pipeline and initializes hyperparameters
model.initialize_hyperparameters(t_raw, y_raw)
# Refines simplex weights and noise under shape constraint
model.fit_gp(t_raw, y_raw, lr=0.05, epochs=15)
License
This project is licensed under the GNU General Public License v3 (GPLv3) - see the LICENSE file 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 respolygp-0.1.1.tar.gz.
File metadata
- Download URL: respolygp-0.1.1.tar.gz
- Upload date:
- Size: 53.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7d83d1e02daad89918de3855fdb7415ccda681f23d0b0674589c8b1b3e8b8fa
|
|
| MD5 |
dfa10a8651d1579ecb2c5addf5579f7a
|
|
| BLAKE2b-256 |
4214bbfb135e7c8d8b012a819ef149431d7bdfe9a109930f12b44db13c594489
|
File details
Details for the file respolygp-0.1.1-py3-none-any.whl.
File metadata
- Download URL: respolygp-0.1.1-py3-none-any.whl
- Upload date:
- Size: 42.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb531703d332cda0adf06b54a8d39cc5ce30c0bdfbaa9b2456ff361823ef5281
|
|
| MD5 |
a19587009aff06983e11290193130889
|
|
| BLAKE2b-256 |
cbcda22c4f0f6e72a22e8d5c5ae86a774cdb69484ba43d8269d7ce144e478181
|