Skip to main content
ByEliott Kalfon

Time-Series Forecasting with TabPFN

Turning the tabular foundation model into a zero-shot forecaster. TabPFN can forecast time series without any task-specific training. The tabpfn-time-series package wraps the model in a pipeline that takes historical context and returns a probabilistic forecast. This notebook covers both a univariate forecast on the M4 hourly dataset and a multivariate forecast, where known future covariates sharpen the prediction. Reference: https://github.com/PriorLabs/tabpfn-time-series/blob/main/examples/quickstart.ipynb tabpfn-ts-method-overview.png

Setup

Installing the time-series package and authenticating. tabpfn-time-series brings the pipeline and plotting helpers. As elsewhere, the API token is read from Colab secrets.

Authenticating with a Token

Setting TABPFN_TOKEN so the pipeline can reach the TabPFN API. As elsewhere, the API token is read from Colab secrets. Accept the license and copy your key from priorlabs.ai if you have not already.

Loading the Data

The M4 hourly dataset: many hourly series with a known future to score against. The M4 dataset is a standard forecasting benchmark from the M4 competition; its hourly subset is a collection of many independent hourly time series (things like electricity demand or web traffic). Each individual series is one item, identified by an item_id, and we forecast each one separately. We load the standard M4 hourly train and test splits: the train frame is the historical context, and the test frame holds the actual future values we will compare the forecast against.

Select a few series

Restricting to two items to keep the demo fast and legible.

Build the pipeline

One pipeline object drives both the univariate and multivariate forecasts. By default TabPFNTSPipeline runs TabPFN through the hosted API (tabpfn-client) rather than a local model. That is why the progress logs further down come from the client, and why the TABPFN_TOKEN set above is what authenticates those calls.

Univariate Forecast

Forecasting from history alone, with no extra inputs. We ask the pipeline for a 48-step horizon. With only context_df, each series is forecast purely from its own past. The result is probabilistic, with quantiles around the median.

Plotting the forecast

The forecast against the held-out actuals. plot_forecast overlays the predicted median and quantile band on the historical context and the true future values.
Plotting the forecast

Multivariate Forecast

Adding known future covariates to sharpen the prediction. Often we know something about the future: a load forecast, a weather forecast. The pipeline can condition on these covariates. Here we use an electricity-price dataset that ships with related forecasts, and compare predictions with and without them.

Load the data

The electricity-price dataset, with covariate columns alongside the target.

Prepare the data

Renaming to the expected schema and isolating a single region. The pipeline expects timestamp, target, an optional item_id, and any covariate columns. We rename accordingly, pick one region, and split the covariates into a future_df that excludes the target.

Predict with and without covariates

Two forecasts from the same history, differing only in the covariates. Running the pipeline twice, once including the covariate columns and once dropping them, isolates exactly how much the extra information helps.

Comparing the Forecasts

Side by side: does knowing the future help?

Without covariates

History only.
Without covariates

With covariates

The same horizon, now conditioned on the known future inputs.
With covariates