Skip to main content

Universal Forecasting Library

The universal-forecasting-library is a unified, "zero-shot" forecasting framework designed to provide a seamless interface for multiple time-series forecasting architectures. It abstracts away the complexity of data preparation, feature engineering, and hyperparameter tuning.

Installation

You can install the package directly via pip. By default, this performs a lightweight installation (without PyTorch and heavy foundation models).

# Lightweight Install (Linear & Tree Ensemble)
pip install universal-forecasting-library

# Full Install (Includes TSFM and PyTorch)
pip install universal-forecasting-library[tsfm]

Available Forecasters

The library uses an orchestration layer (UniversalForecaster) to dispatch work to specific forecasting engines. Here is a quick summary of what each engine does:

  • LinearForecaster (linear): Fast, classical statistical models. It wraps algorithms like AutoARIMA, AutoETS, AutoTheta, and SeasonalNaive. Best used as a strong, parallelized baseline.
  • TreeEnsembleForecaster (tree_ensemble): Machine learning approach. Uses LightGBM wrapped in a multi-output RegressorChain. It automatically builds complex features (lags, rolling stats, holidays) and predicts the entire future horizon in one shot. Best for complex datasets where feature engineering shines.
  • TSFMForecaster (tsfm): Deep learning approach. Wraps Hugging Face's Time Series Foundation Models (like TinyTimeMixer). Uses massive pre-trained neural networks to perform zero-shot forecasting on your data. Best for discovering complex patterns without manual feature tuning.

Usage Guide

Initialization

Import the orchestrator and initialize your forecasting session:

from universal_forecaster import UniversalForecaster

forecast = UniversalForecaster(
    input_windows=36,               # Lookback window (used primarily by TSFM)
    horizon=18,                     # The number of steps into the future to predict
    forecast_type='tree_ensemble',  # Choose from: 'linear', 'tree_ensemble', 'tsfm'
    test_type='model',              # (Optional) 'model' to test architectures, 'param' for hyperparameters
    tsfm_model_path="./local_ttm"   # Path to local foundation model weights (if using TSFM)
)

Data Format Requirements

The input data must be a Pandas DataFrame containing at minimum:

  • ds: The datetime column.
  • y: The numeric target variable to forecast.
  • unique_id (Optional): An identifier for multi-series forecasting. If omitted, a dummy ID is injected automatically.

Training & Predicting

import pandas as pd

# Example Data
df_train = pd.DataFrame({
    'ds': pd.date_range('2023-01-01', periods=100),
    'y': range(100)
})

# 1. Fit the forecaster. 
# If test_type is set, this will automatically hold out 10% of data, evaluate configurations, and retrain on 100%.
forecast.fit(df_train)

# 2. Predict the horizon
# Returns a DataFrame with an 'Ensemble' column containing the predictions
predictions_df = forecast.predict()
print(predictions_df)

Advanced Features

1. Auto-Testing & Model Selection (test_type)

The framework can automatically evaluate multiple configurations on a chronologically held-out 10% validation set, pick the best one using Mean Absolute Error (MAE), and seamlessly retrain on the full dataset.

  • test_type='model': Tests between different architectural families (e.g., linear vs tree_ensemble).
  • test_type='param': Tests different hyperparameter grids for a specific architecture.

2. Automated Feature Engineering

When using non-linear models (like tree_ensemble), the UniversalForecaster automatically generates:

  • Cyclical Calendar Features: Sine/Cosine transformations of day-of-week, month, and hour.
  • Holiday Features: Automatic integration with holidays (currently configured for Indonesia).
  • Lag Features: Auto-scaled lag features based on the detected frequency.
  • Rolling Statistics: Rolling mean and standard deviation (volatility) to capture recent trends.

Metadata

Release files for universal-forecasting-library 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for universal-forecasting-library 0.1.2
File Size Uploaded Provenance Actions
universal_forecasting_library-0.1.2.tar.gz 10.2 kB Without provenance Details for universal_forecasting_library-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for universal-forecasting-library 0.1.2
File Interpreter ABI Platform Actions
universal_forecasting_library-0.1.2-py3-none-any.whl Python 3 none any Details for universal_forecasting_library-0.1.2-py3-none-any.whl

Total release size: 20.1 kB

Release files / universal_forecasting_library-0.1.2.tar.gz

Download URL universal_forecasting_library-0.1.2.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c2a5ecfc15a8e046a9d6bb4718410a344768ea40d26db267c058a55666936f08
BLAKE2b-256 checksum
How to use checksums
f3392689553510b65a769a456d0d610982f5cd31de72aafd9e175ecb310d5672
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.0

Release files / universal_forecasting_library-0.1.2-py3-none-any.whl

Download URL universal_forecasting_library-0.1.2-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
acef5f9a905e49420ddd6360f9bb3cf5826e5f81613e2b43d6d105adc6a8ee95
BLAKE2b-256 checksum
How to use checksums
fae3a7b232a62a759d4b8829c96d8acd8d93fee33568c6263b1569c10a3abecb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.0

Security for universal-forecasting-library 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page