Skip to main content

A Python package for Gimbal Regression, a deterministic local linear regression framework with explicit diagnostics.

Project description

grpy

grpy is a Python package for Gimbal Regression (GR)
a deterministic local linear regression framework for stable and reproducible estimation under anisotropic neighborhood geometry.

The package is designed with a focus on:

  • Deterministic estimation (no iterative optimization)
  • Numerical stability under irregular spatial sampling
  • Explicit diagnostics (conditioning, effective sample size, fallback)
  • Reproducibility via a single-pass estimator

Unlike conventional local regression methods (e.g., GWR/MGWR), grpy exposes both estimates and their numerical reliability as first-class outputs.


Installation

Basic installation

pip install grpy

Install from source (development mode)

git clone https://github.com/yuichiro-otani/grpy.git
cd grpy
pip install -e .

Optional Dependencies

Some features require additional packages. Install as needed:

# plotting utilities
pip install grpy[plot]

# benchmarking and comparison methods
pip install grpy[benchmark]

# development tools
pip install grpy[dev]

# everything
pip install grpy[all]

Quick Example

import numpy as np
from grpy import GimbalRegression

rng = np.random.default_rng(42)
n = 100

lat = 35.0 + 0.02 * rng.random(n)
lon = 139.0 + 0.02 * rng.random(n)

x = rng.normal(size=n)
y = 1.0 + 2.0 * x + 0.1 * rng.normal(size=n)

model = GimbalRegression(
    K=20,
    h_m=2000.0,
    gamma=1.0,
)

model.fit(
    y=y,
    x=x,
    lat=lat,
    lon=lon,
)

yhat = model.predict()
diag = model.diagnostics()
summary = model.summary()

print(summary)

Map Visualization

Requires plot extras:

pip install grpy[plot]

Example:

fig, ax = model.draw_map(
    column="B1",
    title="Local coefficient B1",
    basemap=True,
)

Diagnostics

grpy returns diagnostic quantities alongside estimates:

  • Condition numbers of local normal matrices
  • Effective sample size (ESS)
  • Fallback indicators (uniform weighting)
diag = model.diagnostics()
print(diag.head())

These diagnostics allow users to directly assess numerical reliability of local estimates, not just predictive accuracy.

Reproducibility

The estimator is:

  • deterministic
  • single-pass
  • free from stochastic components

This ensures that results are exactly reproducible given identical inputs.

Project Structure

grpy/
├── src/grpy/
├── tests/
├── examples/
  • src/grpy – core implementation
  • tests/ – unit tests
  • examples/ – usage examples

Citation

If you use this package, please cite:

@article{Otani2026GR,
  author  = {Otani, Yuichiro},
  title   = {Gimbal Regression: A Geometry-Aware Framework for Stable Local Linear Estimation under Anisotropic Sampling},
  journal = {arXiv preprint arXiv:2603.10382},
  year    = {2026},
  doi     = {10.48550/arXiv.2603.10382}
}

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gimbal_regression-0.1.2-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file gimbal_regression-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for gimbal_regression-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 69b49a16aa60f5f544a22a2252d7969aafea4d73b19d952e4929ddde99e0c37b
MD5 f26772620fb0ed945635dc706fe81e74
BLAKE2b-256 e4f5d9c97b2d487ce107cdfc46fd82b57818f6431d4a35f13d33661ecc895beb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page