Point and probabilistic time series forecasting — one interface, every model.
Project description
Twiga Forecast
Point & probabilistic time series forecasting — one interface, every model.
"Twiga" means giraffe in Swahili 🦒
Documentation · Tutorials · API Reference · PyPI
Most forecasting libraries force a choice — ML or deep learning, point forecasts or probabilistic ones, flexibility or production readiness. Twiga removes that trade-off.
A single TwigaForecaster trains, tunes, evaluates and backtests gradient-boosted trees, neural networks, quantile regression, parametric distributions and conformal prediction through one consistent, config-driven API.
Installation
# Core (tree models + lets-plot + great-tables)
pip install twiga
# + Matplotlib, Plotly, SciencePlots
pip install "twiga[plots]"
# + Neural networks (PyTorch Lightning)
pip install "twiga[nn]"
# Everything
pip install "twiga[all]"
Batteries included — XGBoost, LightGBM, CatBoost, NGBoost, lets-plot and Great Tables ship with the base install.
| Extra | What it adds |
|---|---|
plots |
Matplotlib, Plotly, SciencePlots (publication-quality & interactive charts) |
nn |
PyTorch, Lightning, TorchMetrics, TensorBoard |
explain |
SHAP feature attribution |
mlops |
MLflow, FastAPI, Evidently, Prefect |
all |
Everything above |
What Twiga offers
| Feature | Description |
|---|---|
| 🔀 One interface, every model | Swap a gradient-boosted tree for a neural network by changing one config object, not rewriting code |
| 📊 Probabilistic forecasting | Quantile regression, parametric distributions (Normal, Laplace, LogNormal, Gamma, Beta, Student-t) and conformal prediction, all composable with any backbone |
| 🎯 Calibrated uncertainty | Conformal prediction wraps any trained model with finite-sample coverage guarantees, no retraining required |
| ⚙️ Experiment-ready | Pydantic configs wired directly to Optuna search spaces; time-based backtesting and checkpoint-based resume are first-class features |
| 🔍 Feature intelligence | Eight association measures fused with Borda-count rank aggregation; stationarity tests, entropy and residual diagnostics in one call |
| 🚀 Production MLOps | Optional stack with experiment tracking, versioned checkpoints, drift monitoring, REST API and automated retraining |
Quick start
import pandas as pd
from twiga.forecaster.core import TwigaForecaster
from twiga.core.config import DataPipelineConfig, ForecasterConfig
from twiga.models.ml.lightgbm_model import LIGHTGBMConfig
# train_df / test_df are pandas DataFrames with a DatetimeIndex
forecaster = TwigaForecaster(
data_params=DataPipelineConfig(target_feature="load_mw", forecast_horizon=48),
model_params=[LIGHTGBMConfig()],
train_params=ForecasterConfig(split_freq="days", train_size=14, test_size=7),
)
forecaster.fit(train_df=train_df)
predictions_df, metrics_df = forecaster.evaluate_point_forecast(test_df=test_df)
Switch to a neural network by swapping one config:
from twiga.models.nn.mlpgam_model import MLPGAMConfig
forecaster = TwigaForecaster(
data_params=DataPipelineConfig(target_feature="load_mw", forecast_horizon=48),
model_params=[MLPGAMConfig()],
train_params=ForecasterConfig(split_freq="days", train_size=14, test_size=7),
)
See the tutorials for probabilistic forecasting, conformal prediction, backtesting, HPO, and MLOps examples.
Documentation
| Section | Description |
|---|---|
| Get Started | Install, key concepts, and your first forecast |
| User Guide | Forecaster API, data pipeline, metrics, backtesting |
| Models | ML tree models, neural networks, HPO |
| Probabilistic | Distributions, quantile regression, conformal prediction |
| Tutorials | End-to-end Jupyter notebooks |
| MLOps | Tracking, serving, monitoring, orchestration |
| API Reference | Full API reference |
Contributing
Bug reports and feature requests are welcome — please open an issue. Pull requests should target the main branch and pass the pre-commit checks (uv run pre-commit run --all-files).
Contributors
Thanks goes to these wonderful people:
|
Anthony Faustine |
Frederick Apina |
Lucas Pereira |
References
- A. Faustine, N. J. Nunes and L. Pereira, "Efficiency through Simplicity: MLP-based Approach for Net-Load Forecasting with Uncertainty Estimates," IEEE Transactions on Power Systems, doi: 10.1109/TPWRS.2024.3400123.
- A. Faustine and L. Pereira, "FPSeq2Q: Fully Parameterized Sequence to Quantile Regression for Net-Load Forecasting With Uncertainty Estimates," IEEE Transactions on Smart Grid, vol. 13, no. 3, pp. 2440-2451, May 2022, doi: 10.1109/TSG.2022.3148699.
- A. Faustine and L. Pereira, "Conformal Multilayer Perceptron-Based Probabilistic Net-Load Forecasting for Low-Voltage Distribution Systems with Photovoltaic Generation," 2024 IEEE International Conference on Communications, Control, and Computing Technologies for Smart Grids (SmartGridComm), Oslo, Norway, 2024, pp. 59-64, doi: 10.1109/SmartGridComm60555.2024.10738106.
- A. Faustine and L. Pereira, "Enhancing LV System Resilience through Probabilistic Forecasting of Interdependent Variables: Voltage, Reactive and Active Power," CIRED Chicago Workshop 2024: Resilience of Electric Distribution Systems, Chicago, USA, 2025, pp. 27-31, doi: 10.1049/icp.2024.2555.
Apache 2.0 License · Built with ❤️ for energy & power systems forecasting
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 twiga-0.1.2.tar.gz.
File metadata
- Download URL: twiga-0.1.2.tar.gz
- Upload date:
- Size: 560.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e33633088fd1798e75a1dab656dbe405fbfb464f8545db49556c8d6b2257dfe
|
|
| MD5 |
92fbd64478eec380f2b8d041303e2303
|
|
| BLAKE2b-256 |
66b6b9657346e91b167c927f0728c3a6a6961494dddfa602a54c6bec67d8d5de
|
Provenance
The following attestation bundles were made for twiga-0.1.2.tar.gz:
Publisher:
publish_pypi.yaml on sambaiga/twiga-forecast
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
twiga-0.1.2.tar.gz -
Subject digest:
5e33633088fd1798e75a1dab656dbe405fbfb464f8545db49556c8d6b2257dfe - Sigstore transparency entry: 1423529074
- Sigstore integration time:
-
Permalink:
sambaiga/twiga-forecast@1c9c5223ce4782ec6294e25957f1ad92b678670d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/sambaiga
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yaml@1c9c5223ce4782ec6294e25957f1ad92b678670d -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file twiga-0.1.2-py3-none-any.whl.
File metadata
- Download URL: twiga-0.1.2-py3-none-any.whl
- Upload date:
- Size: 544.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b8f60b6a3d51639021f9e2af560274092f821115cfae3ebf3faf7739c7ee7ca
|
|
| MD5 |
ac7540fb479ddfb7248223e256a03d71
|
|
| BLAKE2b-256 |
4968772220579656271601c9d598965de7c69a6465101a7a584653b82296428f
|
Provenance
The following attestation bundles were made for twiga-0.1.2-py3-none-any.whl:
Publisher:
publish_pypi.yaml on sambaiga/twiga-forecast
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
twiga-0.1.2-py3-none-any.whl -
Subject digest:
2b8f60b6a3d51639021f9e2af560274092f821115cfae3ebf3faf7739c7ee7ca - Sigstore transparency entry: 1423529137
- Sigstore integration time:
-
Permalink:
sambaiga/twiga-forecast@1c9c5223ce4782ec6294e25957f1ad92b678670d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/sambaiga
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yaml@1c9c5223ce4782ec6294e25957f1ad92b678670d -
Trigger Event:
workflow_dispatch
-
Statement type: