$ show sktime/pytorch-forecasting
pytorch-forecasting is a deep learning library for time series forecasting, providing implementations of state-of-the-art models such as Temporal Fusion Transformer, N-BEATS, N-HiTS, DeepAR, PatchTST, TiDE, TimeXer, and many others. Built on PyTorch and PyTorch Lightning, it offers a complete pipeline from data preprocessing (TimeSeriesDataSet, encoders, samplers) through model training (with GPU support, callbacks, hyperparameter tuning via optuna) to prediction and evaluation (point, quantile, and distributional metrics). The library supports multivariate forecasting, static and time-varying covariates, categorical features, and multiple targets. A major v2 refactoring is underway, introducing a new data module layer and simplified package interface, though the v2 API is explicitly marked as experimental and unstable. The codebase is well-tested with automated integration tests across all models and metrics, and employs a composition pattern for metrics (supporting weighting, aggregation, and distribution losses) and a layered architecture for models (base classes, package containers, building blocks).
The LLM identified 4 files worth highlighting for reuse:
Implements the mLSTM (Matrix LSTM) cell from the xLSTM paper, a novel recurrent architecture that uses memory matrices and exponential gating. The layer is fully self-contained, only depends on torch, and can be extracted and used in any PyTorch project requiring advanced recurrent cells.
Defines the base classes for all metrics (Metric, MultiHorizonMetric, DistributionLoss, MultiLoss, CompositeMetric) with support for weighting, aggregation, masking, and distribution mapping. The clean abstraction enables composing metrics via + and * operators and standardizes rescaling, prediction extraction, and quantile calculation. This pattern is reusable for any project needing flexible, composable evaluation metrics.
Provides time-series-specific normalizers including GroupNormalizer, EncoderNormalizer, MultiNormalizer, and NaNLabelEncoder. These handle group-wise scaling (by id), encoding of unknown categories, and multi-target normalization with transformation options (log, softplus, relu). The classes are isolated, parameterized, and can be reused in any time series data pipeline without the rest of the library.
Implements a KolmogorovβArnold Network (KAN) layer using B-spline basis functions. This is a non-obvious, cutting-edge neural network building block that can replace standard linear layers. The implementation is self-contained (only torch dependencies) and can be extracted for use in other projects exploring learnable activation functions.