Metadata-Version: 2.4
Name: eb-adapters
Version: 0.2.5
Summary: Adapter layer for third-party forecasting libraries in Electric Barometer
License: BSD-3-Clause
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.24
Requires-Dist: pandas>=2.0
Requires-Dist: eb-metrics==0.2.9
Requires-Dist: eb-contracts==0.2.3
Provides-Extra: prophet
Requires-Dist: prophet>=1.1; extra == "prophet"
Provides-Extra: statsmodels
Requires-Dist: statsmodels>=0.14; extra == "statsmodels"
Provides-Extra: catboost
Requires-Dist: catboost>=1.2; extra == "catboost"
Provides-Extra: lightgbm
Requires-Dist: lightgbm>=4.0; extra == "lightgbm"
Requires-Dist: scikit-learn; extra == "lightgbm"
Provides-Extra: xgboost
Requires-Dist: xgboost>=2.0; extra == "xgboost"
Provides-Extra: test
Requires-Dist: pytest>=8.0; extra == "test"
Requires-Dist: pytest-cov>=5.0; extra == "test"
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: pytest-cov>=5.0; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Provides-Extra: all
Requires-Dist: prophet>=1.1; extra == "all"
Requires-Dist: statsmodels>=0.14; extra == "all"
Requires-Dist: catboost>=1.2; extra == "all"
Requires-Dist: lightgbm>=4.0; extra == "all"
Requires-Dist: xgboost>=2.0; extra == "all"
Requires-Dist: scikit-learn; extra == "all"
Requires-Dist: pytest>=8.0; extra == "all"
Requires-Dist: pytest-cov>=5.0; extra == "all"
Requires-Dist: mypy; extra == "all"
Requires-Dist: ruff; extra == "all"
Dynamic: license-file

# Electric Barometer · Adapters (`eb-adapters`)

[![CI](https://github.com/Economistician/eb-adapters/actions/workflows/ci.yml/badge.svg)](https://github.com/Economistician/eb-adapters/actions/workflows/ci.yml)
![License: BSD-3-Clause](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)
![Python Versions](https://img.shields.io/pypi/pyversions/eb-adapters)
![PyPI](https://img.shields.io/pypi/v/eb-adapters)

Adapter interfaces that normalize forecasting model APIs for consistent evaluation within the Electric Barometer ecosystem.

---

## Overview

`eb-adapters` wraps heterogeneous forecasting libraries behind a common `fit` / `predict` contract for uniform evaluation. It isolates framework-specific behavior; metrics and evaluation live in sibling packages.

---

## Installation

`eb-adapters` is distributed as a standard Python package.

```bash
pip install eb-adapters
```

The package supports Python 3.11 and later.

---

## Core Concepts

- **Interface normalization** — Forecasting models from different libraries are wrapped behind a common training and prediction contract, enabling uniform downstream evaluation.
- **Thin adaptation layer** — Adapters aim to be minimal and non-invasive, preserving native model behavior while standardizing how models are invoked.
- **Framework isolation** — Library-specific configuration, defaults, and quirks are contained within adapters, preventing leakage into evaluation or orchestration layers.
- **Explicit lifecycle boundaries** — Model fitting, prediction, and state management are clearly separated to support reproducibility and controlled execution.
- **Comparability over abstraction** — Adapters do not attempt to hide meaningful differences between modeling approaches; they exist to make comparison feasible, not to enforce uniformity.

---

## Minimal Example

The example below shows how a forecasting model is wrapped behind a standardized adapter interface so it can be trained and evaluated consistently alongside other models.

```python
import numpy as np
from eb_adapters import ArimaAdapter, SarimaxAdapter

y_train = np.array([10.0, 12.0, 11.0, 13.0, 14.0, 15.0], dtype=float)
X_train = np.arange(len(y_train), dtype=float).reshape(-1, 1)
X_horizon = np.arange(7, dtype=float).reshape(-1, 1)

arima = ArimaAdapter(order=(1, 1, 1))
arima.fit(X_train, y_train)
y_pred = arima.predict(X_horizon)

sarimax = SarimaxAdapter(order=(1, 0, 0), seasonal_order=(0, 0, 0, 0))
sarimax.fit(X_train, y_train)
y_pred = sarimax.predict(X_horizon)
```

The same `fit(X, y)` / `predict(X)` contract is used with tree-based models:

```python
import numpy as np
from eb_adapters import XGBoostRegressorAdapter

X_train = np.arange(20, dtype=float).reshape(-1, 1)
y_train = (2.0 * X_train[:, 0] + 1.0)
X_future = np.arange(20, 27, dtype=float).reshape(-1, 1)

adapter = XGBoostRegressorAdapter(n_estimators=50, max_depth=3)
adapter.fit(X_train, y_train)
y_pred = adapter.predict(X_future)
```

---

## License

BSD 3-Clause License.
© 2026 Kyle Corrie.
