Skip to main content

Overfit-to-Generalization Framework for Equitable Spatiotemporal Modeling

Project description

og-learn

Overfit-to-Generalization Framework for Equitable Spatiotemporal Modeling

PyPI version License: MIT

Overview

og-learn is a Python library that implements the Overfit-to-Generalization (OG) framework, designed to address local overfitting in spatiotemporal machine learning models. The framework redistributes predictive capacity from data-rich to data-poor regions through a two-stage approach.

The Problem: Local Overfitting

Models trained on non-uniformly distributed observations tend to:

  • Overfit to data-dense regions (achieving high accuracy)
  • Underperform in sparse areas (poor generalization)
  • Show inconsistent optimal hyperparameters across different validation groups

This disparity is often invisible when using conventional global metrics.

The Solution: OG Framework

The OG framework exploits complementary properties of different model architectures:

  1. Stage 1 (Overfit): A high-variance model (e.g., LightGBM) is deliberately overfitted to capture local patterns and generate pseudo-labels.

  2. Stage 2 (Generalization): A low-variance model (e.g., MLP, Transformer) learns from the pseudo-labels with density-aware sampling and noise injection.

Installation

pip install og-learn

Quick Start

from og_learn import OGFramework
from og_learn.models import LightGBMOverfitter, TransformerRegressor

# Initialize the OG framework
og = OGFramework(
    hv_model=LightGBMOverfitter(),  # High-variance model for Stage 1
    lv_model=TransformerRegressor(), # Low-variance model for Stage 2
)

# Fit the model
og.fit(X_train, y_train, coords=coordinates)

# Predict
predictions = og.predict(X_test)

Key Features

  • Density-Aware Sampling: Prioritizes sparse regions and rare covariate patterns
  • Unlimited Synthetic Target Generation: Generates high-fidelity pseudo-labels via spatial perturbation
  • Flexible Model Pairing: Supports various HV/LV model combinations
  • Cross-Validation Strategies: Built-in time-wise, site-wise, region-wise, and spatiotemporal-wise CV

Supported Models

High-Variance (HV) Models

  • LightGBM
  • XGBoost
  • CatBoost

Low-Variance (LV) Models

  • MLP (Multi-Layer Perceptron)
  • Transformer Regressor
  • ResNet

Documentation

For full documentation, see [documentation link].

Citation

If you use this package in your research, please cite:

@article{liang2025og,
  title={Countering Local Overfitting for Equitable Spatiotemporal Modeling},
  author={Liang, Zhehao and Castruccio, Stefano and Crippa, Paola},
  journal={},
  year={2025}
}

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Project details


Download files

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

Source Distribution

og_learn-0.1.0.tar.gz (47.4 kB view details)

Uploaded Source

Built Distribution

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

og_learn-0.1.0-py3-none-any.whl (57.1 kB view details)

Uploaded Python 3

File details

Details for the file og_learn-0.1.0.tar.gz.

File metadata

  • Download URL: og_learn-0.1.0.tar.gz
  • Upload date:
  • Size: 47.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for og_learn-0.1.0.tar.gz
Algorithm Hash digest
SHA256 57f19ac2ddadb6936661c8541f0dd48883683154e48fa995e510b4d530961148
MD5 5744bb1188989ab560f1a4fe34d86a86
BLAKE2b-256 98b9ccd0b44fc7db784d4fea95faaab724f113e428c0c560f33c1f9fe0ccb61c

See more details on using hashes here.

Provenance

The following attestation bundles were made for og_learn-0.1.0.tar.gz:

Publisher: publish.yml on px39n/og-learn

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file og_learn-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: og_learn-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 57.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for og_learn-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1c530748cd1ca90d3c388a02cf86f40fff5ed10ab57b44ddc8f32b94adecba8e
MD5 d232fb98dc00b4544c7d4ed711828b7e
BLAKE2b-256 d5d51858c6e742d950ab0e2294776cbb09d3ca2b6ce406ba29d46510b8ebc506

See more details on using hashes here.

Provenance

The following attestation bundles were made for og_learn-0.1.0-py3-none-any.whl:

Publisher: publish.yml on px39n/og-learn

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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