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

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.4
File Size Uploaded
forecast_realtime-0.5.4.tar.gz 165.9 kB Details

Built distribution (wheel)

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

Total release size: 282.4 kB

Release files / forecast_realtime-0.5.4.tar.gz

Download URL forecast_realtime-0.5.4.tar.gz
Size 165.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a7e0fdcfabaf0f2d3934f225610f875f5d12d12a019057276b6471bf06e3dd67
BLAKE2b-256 checksum
How to use checksums
3bd5e9f16e4baa8d00cdd70857cddf55feab9c80196be95c7db4ffd64957b86d
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.4-py3-none-any.whl

Download URL forecast_realtime-0.5.4-py3-none-any.whl
Size 116.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
61d4ad1fcbb9546096c4c7cc6be1f09f4a7a5e739e37bb1775881a1c785095c7
BLAKE2b-256 checksum
How to use checksums
14aa51ae1027399958f5bda4a7c560e2dcc2f4d78d44f4e541d5e18b66fea31f
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

0.5.5

2 release files

This release

0.5.4 This release

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