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

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.5
File Size Uploaded
forecast_realtime-0.5.5.tar.gz 165.8 kB Details

Built distribution (wheel)

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

Total release size: 282.4 kB

Release files / forecast_realtime-0.5.5.tar.gz

Download URL forecast_realtime-0.5.5.tar.gz
Size 165.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a3e635dd52f8aa6d25a08e7eff6b0e25c267cbe203825aea7934700d0838ae2d
BLAKE2b-256 checksum
How to use checksums
fd011f25754e35a020bed42c043376f167da48fbdd77994366a9b86609ad3351
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.5-py3-none-any.whl

Download URL forecast_realtime-0.5.5-py3-none-any.whl
Size 116.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
34858d2dd9d42c00e4d4af237f46ecf8ce5cdf8d2f96801bfca2a5ab3d457107
BLAKE2b-256 checksum
How to use checksums
02014286a2416a503d11133284d948102d2a90be0cbd8d5b0f783cdad3ee3357
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

0.5.6

2 release files

This release

0.5.5 This release

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