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.3

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.3
File Size Uploaded Provenance Actions
universal_forecasting_library-0.1.3.tar.gz 10.2 kB Without provenance Details for universal_forecasting_library-0.1.3.tar.gz

Built distribution (wheel)

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

Total release size: 20.2 kB

Release files / universal_forecasting_library-0.1.3.tar.gz

Download URL universal_forecasting_library-0.1.3.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
f955f2608c583fd56de8eca1b354b3345424accbee18b0fb70caa4e37d61cb3e
BLAKE2b-256 checksum
How to use checksums
848f47f046d5abbab099f72a6b17e871259a36ea0d5fe98c629b1947da227064
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.3-py3-none-any.whl

Download URL universal_forecasting_library-0.1.3-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c96a0beacad4dba97b6d65c478c9f8ccb02fd965f81185f4a45c1dc6741c0255
BLAKE2b-256 checksum
How to use checksums
4bb8f95623ae6ff51d38d0e41e70526f0ae92d85549f2cca8e0803012f2ea1c0
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.3

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