Darts: User-Friendly Modern Machine Learning for Time Series

Julien Herzen, Francesco Lässig, Samuele Giuliano Piazzetta, Thomas Neuer, Léo Tafti, Guillaume Raille, Tomas Van Pottelbergh, Marek Pasieka, Andrzej Skrodzki, Nicolas Huguenin, Maxime Dumonal, Jan Koscisz, Dennis Bader, Frédérick Gusset, Mounir Benheddi, Camila Williamson, Michal Kosinski, Matej Petrik, Gaël Grosch

Abstract

Darts is a Python library that unifies classical forecasting and modern deep learning under a single, scikit-learn-like API. It simplifies the complex workflow of time series modeling, allowing practitioners to train "global" models across thousands of series and generate probabilistic forecasts with minimal boilerplate code.

Introduction

Time series forecasting is critical for industries ranging from energy management to retail logistics. However, the field has historically been split into two worlds. On one side are classical statistical methods, which are robust but often limited to modeling a single series at a time. On the other are modern machine learning and deep learning (DL) approaches, which can learn complex patterns across massive datasets but often require bespoke, low-level code to handle data slicing, scaling, and covariate alignment.

Darts addresses this fragmentation by providing a high-level abstraction that makes switching between a simple Exponential Smoothing model and a complex multi-horizon Deep Learning model as easy as changing a single line of code.

Methods and Architecture

The core of Darts is built on several key architectural choices designed for robustness and ease of use:

  • The TimeSeries Object: Instead of raw NumPy arrays, Darts uses a dedicated container based on xarray. This ensures data integrity (e.g., guaranteed sorted time indices) and handles dimensions for "time," "components" (multivariate columns), and "samples" (for probabilistic data).
  • Unified API: Every model implements a standard fit() and predict() interface. This allows for seamless backtesting, ensembling, and model comparison.
  • Global Model Support: Unlike classical models, Darts' ML models are "global," meaning they can be trained on a collection of hundreds or thousands of different series simultaneously to learn shared patterns.
  • Covariate Handling: The library explicitly distinguishes between past covariates (data known only up to the present) and future covariates (data known into the future, like weather forecasts), reducing the risk of "data leakage."
  • Probabilistic Forecasting: Rather than just predicting a single point, many Darts models can output distributions by storing Monte Carlo samples directly in the TimeSeries object.

Key Insights

The "Scikit-Learn" philosophy for time series is the central innovation of Darts. By standardizing input/output as TimeSeries objects, the library handles the "plumbing" of neural networks (windowing, slicing, batching) internally. Furthermore, TimeSeries objects are immutable, which prevents accidental data corruption during complex preprocessing pipelines—a common source of bugs in forecasting. This model-agnosticism makes it trivial to create hybrid ensembles, combining the outputs of statistical models and neural networks.

Results and Usage

The library's utility is demonstrated by its ability to handle complex tasks with minimal code. For instance, a Temporal Convolutional Network (TCN) can be trained on multiple distinct datasets simultaneously to produce probabilistic outputs.

A probabilistic forecast generated using Darts, showing the original series (black) and the forecast (blue) with shaded uncertainty intervals.

As illustrated in the figure, Darts provides built-in visualization tools to plot forecasts alongside the original series, including confidence intervals (e.g., 10th and 90th percentiles). The library also includes a darts.datasets module for easy access to standard benchmarks like the AirPassengers and MonthlyMilk datasets, and it is designed to scale to large industrial datasets using lazy data loading.

Limitations and Future Work

While Darts is a powerful tool, it remains an evolving project. Future work includes better support for static covariates (metadata like store location), the creation of a "Model Zoo" for transfer learning (similar to Hugging Face), and expanded filtering modules for state estimation and noise reduction.

Summary updated

BibTeX
@article{herzen2022darts,
  author = {Julien Herzen and Francesco Lässig and Samuele Giuliano Piazzetta and Thomas Neuer and Léo Tafti and Guillaume Raille and Tomas Van Pottelbergh and Marek Pasieka and Andrzej Skrodzki and Nicolas Huguenin and Maxime Dumonal and Jan Koscisz and Dennis Bader and Frédérick Gusset and Mounir Benheddi and Camila Williamson and Michal Kosinski and Matej Petrik and Gaël Grosch},
  title = {{Darts: User-Friendly Modern Machine Learning for Time Series}},
  journal = {J. Mach. Learn. Res.},
  year = {2022},
}
Figure