Forecasting with Hyper-Trees
Project description
Hyper-TreesGBDTs as Hyper-Models for Classical Forecasting Models
|
Overview
Hyper-Trees are a novel framework for modeling time series data with gradient boosted trees (GBDTs). Instead of forecasting time series directly, Hyper-Trees use GBDTs to learn the parameters of a classical time series model such as ARIMA or Exponential Smoothing as functions of features. The target time series model then generates the final forecasts. This naturally injects the inductive bias of forecasting models into tree-based learning. While our framework is built upon the well-established LightGBM model, it can in principle be used with any modern GBDT framework.
Hyper-Trees offer several advantages:
- Improved Extrapolation in Tree-Based Models. Forecasts are generated via a parametric target time series model, rather than the piece-wise constant output of tree-models.
- Cross-Series Learning with Local Adaptivity. A global GBDT learns the feature-to-parameter mapping, so similar series share information while each still receives its own parameters.
- Time-Varying Parameters. Coefficients vary cross-sectionally (series-specific features such as store type or region) and temporally (day, week, month, year, ...), capturing effects such as distinct AR(p) dynamics on weekdays versus weekends.
- Model Transparency and Interpretability. Forecasts are produced by classical time series models whose parameters retain clear statistical meaning.
- Full Functionality of GBDTs. Core GBDT capabilities (missing-value handling, feature importance, categorical support, monotonicity constraints) carry over unchanged.
News
[2026-07-14] v0.2.0 adds support for forecast intervals via conformal prediction and also adds multiple new models.
[2026-06-01] v0.1.0 released on PyPI.
[2024-05-01] Create repository and initial commits.
Available Models
| Model | Description | Scope |
|---|---|---|
Hyper-Tree-AR |
Autoregressive model with tree-learned, time-varying AR(p) parameters. | |
Hyper-TreeNet-AR |
Hybrid model combining tree embeddings with a neural network to learn AR(p) parameters. | |
Hyper-Tree-ARMA |
Autoregressive moving-average model with tree-learned, time-varying AR(p) and MA(q) parameters, fitted recursion-free via the two-stage Hannan-Rissanen procedure. | |
Hyper-TreeNet-ARMA |
Hybrid model combining tree embeddings with a neural network to learn the ARMA(p, q) parameters. | |
Hyper-Tree-ETS |
Exponential smoothing model where ETS parameters are estimated by trees. | |
Hyper-Tree-STL |
STL decomposition with tree-learned parameters for trend and seasonality. | |
Hyper-Tree-VAR |
Vector autoregression with tree-learned, time-varying VAR(p) coefficient matrices, capturing cross-series lead/lag dependence. Intended for small aligned panels. | |
Hyper-TreeNet-VAR |
Hybrid model combining tree embeddings with a neural network to learn the VAR(p) coefficient matrices; recommended VAR variant, since its runtime is independent of the number of coefficients. | |
Hyper-Tree-TSB |
Intermittent demand model (Teunter-Syntetos-Babai) with tree-learned, time-varying smoothing rates for demand probability and demand size. |
Global means a single model is trained across multiple time series; Local means a separate model is trained for each individual series.
All models produce point forecasts and support conformal forecast intervals via ForecastIntervals (see Getting Started). Full distributional (probabilistic) forecasting is planned for future releases. Note on Hyper-Tree-STL: it is designed to decompose time series into trend and seasonal components and is not intended for forecasting. However, the STL-parameters can still be used to generate forecasts.
Getting Started
The example below trains a Hyper-Tree-AR model on the classic AirPassengers series and forecasts the final 12 months. Your data only needs the columns series_id, date, and value. Any other columns are automatically treated as features, and the autoregressive lags are added for you.
from hypertrees.models import HyperTreeAR
from hypertrees import ForecastIntervals
from examples.utils import (load_air_passengers, plot_example_forecast)
# Load data and add 'month' as a feature
dta = load_air_passengers()
dta["month"] = dta["date"].dt.month
# Split the data into training and testing sets, reserving the last 12 months for testing
fcst_h = 12
test = dta.tail(fcst_h).drop(columns="value")
train = dta.drop(test.index)
# Initialize an AR-12 model for monthly data, calibrate conformal intervals, and forecast
ci_levels = [80, 90]
ht_model = HyperTreeAR(p=12, freq="M", fcst_h=fcst_h)
ht_model.train(
lgb_params={"learning_rate": 0.1},
train_data=train,
forecast_intervals=ForecastIntervals(n_windows=5), # calibrate intervals
)
forecasts = ht_model.forecast(test_data=test, level=ci_levels)
# Plot actuals vs. forecast
plot_example_forecast(dta, forecasts)
For more detailed quick-start guides, including hyper-parameter optimization and the other Hyper-Tree models, we refer to the example notebooks.
Installation
To run the Hyper-TreeNet-AR model efficiently, we recommend installing PyTorch with CUDA support. While GPU is recommended for faster runtime, it is not strictly required. All models also run on CPU. We use uv pip for installs. If you don't have uv, consider installing it or simply replace uv pip install with pip install.
Basic Installation (CPU)
Install the latest release from PyPI:
uv pip install hypertrees-forecasting
Or install the development version directly from GitHub:
uv pip install git+https://github.com/StatMixedML/Hyper-Trees.git
Or clone the repository and install in editable mode for development:
git clone https://github.com/StatMixedML/Hyper-Trees.git
cd Hyper-Trees
uv pip install -e .
This installs Hyper-Trees with the latest compatible versions of all dependencies, including a CPU-compatible version of PyTorch. All models will work, just without GPU acceleration.
Optional: Extra Dependencies
The example in this Readme and also the example notebooks use matplotlib (plotting), shap (feature-importance visualization), and optuna (hyper-parameter optimization). To install these alongside the package, use the extras option:
uv pip install "hypertrees-forecasting[extras]" # from PyPI
uv pip install -e ".[extras]" # editable / development
These packages are not required to use the Hyper-Tree models themselves, only to run the example notebooks.
GPU Support
For CUDA-enabled PyTorch, install Hyper-Trees first, then install PyTorch from its CUDA index:
uv pip install torch --index-url https://download.pytorch.org/whl/cu121 --upgrade
Replace cu121 with the variant matching your driver. See pytorch.org/get-started/locally for the current list.
Reproducing Paper Results
The full reproducibility package, including the pinned environment, datasets, configurations, and experiment notebooks needed to reproduce all paper results, lives in the experiments/ folder. See the Experiments README for installation instructions and step-by-step guidance on running the experiments.
Early-stage software
hypertrees-forecasting is in an early stage of development and is provided “as is”, without any warranty or guarantee. We welcome bug reports, feature requests, and pull requests, and encourage feedback by opening a new discussion. We strongly recommend thorough testing and validation before using the package in production or other critical applications.
Acknowledgments
This work draws on and integrates methods and implementations from the following key repositories:
- LightGBM – Gradient boosting framework for efficient tree-based learning.
- PyTorch – Deep learning framework for tensor computation and neural network modeling.
- Nixtla – Open Source Time Series Ecosystem. The conformal forecast intervals in
hypertrees/conformal.pyare adapted from Nixtla's statsforecast, mlforecast, and neuralforecast (Apache-2.0); seeTHIRD_PARTY_NOTICES. - sktime – A unified framework for machine learning with time series.
- GluonTS – Probabilistic time series modeling and forecasting with deep learning.
License
This project is licensed under the Apache License 2.0 with Commons Clause License Condition v1.0. In short, the code is free for research, academic, testing, production, and internal commercial use; selling access to the Software's functionality as a primary offering (e.g., as an API service, managed service, or hosted offering) requires a separate commercial license. See the LICENSE file for details.
Citation
If you use Hyper-Trees in your research, please cite our paper:
@article{maerz.2024,
title = {Forecasting with Hyper-Trees},
author = {März, Alexander and Rasul, Kashif},
journal = {arXiv preprint arXiv:2405.07836},
year = {2024}
}
History
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 hypertrees_forecasting-0.2.0.tar.gz.
File metadata
- Download URL: hypertrees_forecasting-0.2.0.tar.gz
- Upload date:
- Size: 217.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c364b9b47b620a5668efc99cce45512ac740620d557321672d946f304ba95ac7
|
|
| MD5 |
c4ee38aa0d9248b8ca25c487be9a3504
|
|
| BLAKE2b-256 |
8eab51c52610a34c90bbc6532f04af1607e7c1c2b02885560cda6d1f68bb2568
|
Provenance
The following attestation bundles were made for hypertrees_forecasting-0.2.0.tar.gz:
Publisher:
release.yml on StatMixedML/Hyper-Trees
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hypertrees_forecasting-0.2.0.tar.gz -
Subject digest:
c364b9b47b620a5668efc99cce45512ac740620d557321672d946f304ba95ac7 - Sigstore transparency entry: 2167845273
- Sigstore integration time:
-
Permalink:
StatMixedML/Hyper-Trees@cb2960397e85c757ccc7e734bc554874945f5247 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/StatMixedML
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cb2960397e85c757ccc7e734bc554874945f5247 -
Trigger Event:
release
-
Statement type:
File details
Details for the file hypertrees_forecasting-0.2.0-py3-none-any.whl.
File metadata
- Download URL: hypertrees_forecasting-0.2.0-py3-none-any.whl
- Upload date:
- Size: 155.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58864745db79fdc2fb7b84fa275bb91284981a9760ab1b82e487eed63c006a47
|
|
| MD5 |
01a8db1077a6df4bfd3a04ee421ddcbb
|
|
| BLAKE2b-256 |
aff6edd47988af9fa3c6fab20a4b2cdbeb99508f63061129af0b4369584aec8b
|
Provenance
The following attestation bundles were made for hypertrees_forecasting-0.2.0-py3-none-any.whl:
Publisher:
release.yml on StatMixedML/Hyper-Trees
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hypertrees_forecasting-0.2.0-py3-none-any.whl -
Subject digest:
58864745db79fdc2fb7b84fa275bb91284981a9760ab1b82e487eed63c006a47 - Sigstore transparency entry: 2167845288
- Sigstore integration time:
-
Permalink:
StatMixedML/Hyper-Trees@cb2960397e85c757ccc7e734bc554874945f5247 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/StatMixedML
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cb2960397e85c757ccc7e734bc554874945f5247 -
Trigger Event:
release
-
Statement type: