Deep-learning time-series forecasting on PyTorch Lightning · TFT / N-BEATS / DeepAR · verified against PyTorch Forecasting 1.x (2026)

PyTorch Forecasting cheat sheet

PyTorch Forecasting makes state-of-the-art deep forecasting practical: wrap a pandas DataFrame in a TimeSeriesDataSet (handling encoder/decoder windows, categorical encoding, normalization, and multiple series), build a model with .from_dataset(), and train it with the PyTorch Lightning Trainer. Flagship model is the Temporal Fusion Transformer (TFT) with built-in interpretability. This sheet targets PyTorch Forecasting 1.x (now under the sktime org).

setup & concept TimeSeriesDataSet models & training predict & interpret tuning gotcha most common

Verified 2026-08-24 against the official docs at pytorch-forecasting.readthedocs.io and the sktime/pytorch-forecasting repo (1.x). Built on PyTorch Lightning; input is a long-format pandas DataFrame.

Outline

Almost all the work is in configuring the TimeSeriesDataSet correctly. Once that's right, model + Lightning training is boilerplate.

Data

  1. 1 · Install & the flow
  2. 2 · TimeSeriesDataSet
  3. 3 · Validation & dataloaders

Model

  1. 4 · from_dataset & models
  2. 5 · Train with Lightning

Use

  1. 6 · Predict
  2. 7 · Interpret (TFT)

Optimize

  1. 8 · LR find & tuning
  2. 9 · Gotchas
  3. Worth memorizing

Data

The dataset object does the heavy lifting.

1Install & the flow1.x
2TimeSeriesDataSetthe core config
3Validation & dataloadersderive, don't rebuild

Model & Training

Build from the dataset, train with Lightning.

4from_dataset & modelsarchitecture
5Train with Lightningpl.Trainer

Predict & Interpret

Forecast, and understand the TFT.

6Predictforecast
7Interpret (TFT)why it forecasts

Optimize

Find a learning rate and tune.

8LR find & tuninghyperparameters
!Common gotchasread before shipping

Worth memorizing

DataFrame → TimeSeriesDataSet → from_dataset → Trainer.fitthe whole pipeline
group_ids identify each seriesencoder=lookback, prediction=horizon lengths
known vs unknown realsknown = available in the future; unknown = only up to now (incl. the target)
GroupNormalizer per seriesscaling inverted automatically at predict
from_dataset to derive val/testkeeps encoders & normalizers consistent
build models with .from_dataset()TFT / N-BEATS / N-HiTS / DeepAR
it's a LightningModuleplain pl.Trainer.fit; gradient_clip_val for TFT
predict(mode="raw") + interpret_outputTFT variable importance & attention
contiguous integer time_idxnot a datetime; no gaps