Overfit-to-Generalization Framework for Equitable Spatiotemporal Modeling
Project description
og-learn
Overfit-to-Generalization Framework for Equitable Spatiotemporal Modeling
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:
-
Stage 1 (Overfit): A high-variance model (e.g., LightGBM) is deliberately overfitted to capture local patterns and generate pseudo-labels.
-
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
📖 Full documentation: https://px39n.github.io/og-learn/
Data
Example datasets are available on Zenodo: https://doi.org/10.5281/zenodo.17915696
Direct download: og-learn.zip
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
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 og_learn-1.0.0.tar.gz.
File metadata
- Download URL: og_learn-1.0.0.tar.gz
- Upload date:
- Size: 47.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78c26561ebaecf242b6c681ec3e3176d7f7ab08f0d579863d49d4b368fc382a9
|
|
| MD5 |
0673de2c4fbcacef6919194972da07cb
|
|
| BLAKE2b-256 |
aa20cdd580dd0e0a13e3b7ebb7490b0404dce2e4f47cf57d04338ea2c06c5075
|
Provenance
The following attestation bundles were made for og_learn-1.0.0.tar.gz:
Publisher:
publish.yml on px39n/og-learn
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
og_learn-1.0.0.tar.gz -
Subject digest:
78c26561ebaecf242b6c681ec3e3176d7f7ab08f0d579863d49d4b368fc382a9 - Sigstore transparency entry: 762519015
- Sigstore integration time:
-
Permalink:
px39n/og-learn@bd941deb90d53cb05b5c78a977f9003a69ecacf0 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/px39n
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bd941deb90d53cb05b5c78a977f9003a69ecacf0 -
Trigger Event:
release
-
Statement type:
File details
Details for the file og_learn-1.0.0-py3-none-any.whl.
File metadata
- Download URL: og_learn-1.0.0-py3-none-any.whl
- Upload date:
- Size: 57.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b186bce857054d996f1a4d1a3d1ad75a1385394290613995583086f98babde6
|
|
| MD5 |
ce00f2314f6e0d8de6d4309815a5f0da
|
|
| BLAKE2b-256 |
552444c3cd7030bc134f60b1c745a09ac166235e9809847cfd9ed0ebd8500402
|
Provenance
The following attestation bundles were made for og_learn-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on px39n/og-learn
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
og_learn-1.0.0-py3-none-any.whl -
Subject digest:
4b186bce857054d996f1a4d1a3d1ad75a1385394290613995583086f98babde6 - Sigstore transparency entry: 762519017
- Sigstore integration time:
-
Permalink:
px39n/og-learn@bd941deb90d53cb05b5c78a977f9003a69ecacf0 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/px39n
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bd941deb90d53cb05b5c78a977f9003a69ecacf0 -
Trigger Event:
release
-
Statement type: