Skip to main content

Real-time Forecast Package

A Python package for real-time orchestration of forecasting models.

The main object, RealTimeModel, combines a ForecastData object (from the forecast_evaluation package) with one or more ForecastModel objects. ForecastModel is an abstract base class with _fit(), _forecast() and an optional _forecast_decomp() method. All built-in models inherit from it, and you can subclass it to wrap any Python (or R, MATLAB, or Julia) forecasting model.

Installation

pip install forecast_realtime[models]

Quick demo

import forecast_evaluation as fe
import forecast_realtime as rt

forecast_data = fe.ForecastData(load_fer=True)

ridge = rt.models.ForecastRidge(label="Ridge", cv=5, scale=True)
lasso = rt.models.ForecastLasso(label="LASSO", cv=5, scale=True)

rt_model = rt.RealTimeModel(
    data=forecast_data,
    models=[ridge, lasso],
)

rt_model.forecast(
    y_variables=["cpisa"],
    X_variables=["gdpkp"],
    data_transformation={"cpisa": "pop", "gdpkp": "pop"},
    steps=12,
    y_lags=4,
    X_imputation="last",
)

# Optional interactive dashboard:
# rt_model.data.run_dashboard()

Marimo notebook

Install the notebook and model dependencies from the repository root:

pip install -e ".[models,notebooks]"

Open the demo as an editable notebook with visible code cells and outputs:

marimo edit notebooks/demo_models.py

Add your own model

Subclass ForecastModel and implement _fit() and _forecast() (plus _forecast_decomp() if you want news decompositions). y and X arrive as pandas DataFrames, and the base class handles validation, lags, dummies and forecast dates.

import numpy as np
import pandas as pd

from forecast_realtime import ForecastModel


class MyOLS(ForecastModel):
    """Small OLS model showing the custom-model authoring pattern."""

    def _fit(self, y, X=None, **kwargs):
        # y and X are passed as pandas DataFrames
        if X is None:
            raise ValueError("MyOLS requires X")
        X = X.to_numpy(dtype=float)
        y = y.to_numpy(dtype=float)

        # OLS estimate: beta = (X'X)^-1 X'y
        self.beta = np.linalg.inv(X.T @ X) @ X.T @ y

        return self

    def _forecast(self, steps, X=None, y=None, **kwargs):
        if X is None:
            raise ValueError("MyOLS requires future X")
        # ForecastModel passes the historical and future design rows.
        future_X = X.loc[X.index > self.last_y_fit_date].iloc[:steps]
        return future_X.to_numpy(dtype=float) @ self.beta

Pass it straight to RealTimeModel:

rt_model = rt.RealTimeModel(data=forecast_data, models=[MyOLS()])

Documentation

Data Classification

Bank of England Data Classification: OFFICIAL BLUE

Release files for forecast-realtime 0.5.6

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

Source distribution (sdist)

Source distribution for forecast-realtime 0.5.6
File Size Uploaded
forecast_realtime-0.5.6.tar.gz 165.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for forecast-realtime 0.5.6
File Interpreter ABI Platform
forecast_realtime-0.5.6-py3-none-any.whl Python 3 none any Details

Total release size: 282.4 kB

Release files / forecast_realtime-0.5.6.tar.gz

Download URL forecast_realtime-0.5.6.tar.gz
Size 165.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d350f3c127bd152d541ad6ad46bea0282e5035755ffb7f44ca04f90d3bcb1115
BLAKE2b-256 checksum
How to use checksums
ec1c2513fd424c2f3ea1b7070a1cb33f81ab9e0f206bfbe61741f38d39c42589
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 30, 2026.

Transparency log

Release files / forecast_realtime-0.5.6-py3-none-any.whl

Download URL forecast_realtime-0.5.6-py3-none-any.whl
Size 116.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
83670f273ec262217cf81326ba9e8091e1003b7313667a1d67dfaaccd882791c
BLAKE2b-256 checksum
How to use checksums
760ea0f8d774e45dcc35edc666dcefc62c4a4947780dd253a2c4f50dc1bfd9e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 30, 2026.

Transparency log

Release history Release notifications | RSS feed

0.5.10

2 release files

0.5.9

2 release files

0.5.8

2 release files

0.5.7

2 release files

This release

0.5.6 This release

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

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