# Darts — User-Friendly Time Series Forecasting and Anomaly Detection > A Python library for easy manipulation and forecasting of time series, supporting both classical statistical models and modern deep learning architectures with a unified API. ## Install Save as a script file and run: # Darts — User-Friendly Time Series Forecasting and Anomaly Detection ## Quick Use ```bash pip install darts ``` ```python from darts.datasets import AirPassengersDataset from darts.models import ExponentialSmoothing series = AirPassengersDataset().load() model = ExponentialSmoothing() model.fit(series) prediction = model.predict(12) ``` ## Introduction Darts is an open-source Python library developed by Unit8 that makes time series forecasting accessible to both beginners and experts. It wraps a wide range of models — from ARIMA and exponential smoothing to N-BEATS and Temporal Fusion Transformer — behind a consistent, easy-to-use API centered around its own TimeSeries data structure. ## What Darts Does - Provides a unified `fit()`/`predict()` interface across 30+ forecasting models - Supports probabilistic forecasting with confidence intervals and quantile predictions - Handles multivariate, multi-step, and hierarchical time series natively - Includes built-in anomaly detection and scoring modules - Offers data preprocessing utilities for scaling, missing value handling, and feature engineering ## Architecture Overview Darts is built around the `TimeSeries` class, an immutable wrapper over xarray that stores time-indexed data with optional static covariates. Models inherit from base classes (`LocalForecastingModel`, `GlobalForecastingModel`) that define the training interface. Deep learning models use PyTorch Lightning under the hood, enabling GPU training, early stopping, and learning rate scheduling out of the box. ## Self-Hosting & Configuration - Install via `pip install darts` or `pip install "u8darts[all]"` for all optional dependencies - Use `darts[torch]` to include PyTorch-based models only - Configure deep learning models with `pl_trainer_kwargs` for PyTorch Lightning options - Set `num_loader_workers` for parallel data loading during training - Export trained models with `model.save()` and reload with `Model.load()` ## Key Features - Consistent API across statistical, machine learning, and deep learning models - First-class support for covariates (past and future external variables) - Backtesting and evaluation with `historical_forecasts()` and multiple metrics - Ensemble models and pipeline composition for stacking approaches - Rich plotting utilities built on matplotlib ## Comparison with Similar Tools - **sktime** — Broader ML task coverage; Darts focuses on making forecasting simple - **statsmodels** — Lower-level statistical API; Darts wraps statsmodels with a friendlier interface - **GluonTS** — AWS probabilistic forecasting; Darts is framework-agnostic and easier to start - **Prophet** — Single model optimized for business series; Darts offers 30+ model choices - **NeuralForecast** — Pure neural focus; Darts mixes classical and deep models ## FAQ **Q: Can Darts handle multiple time series at once?** A: Yes. Global models in Darts can be trained on multiple series simultaneously and transfer learned patterns across them. **Q: Does Darts support GPU training?** A: Yes. All deep learning models leverage PyTorch Lightning and can be trained on GPUs by passing appropriate trainer kwargs. **Q: What data formats does Darts accept?** A: Darts accepts pandas DataFrames, NumPy arrays, or its native TimeSeries objects. **Q: Is Darts suitable for production use?** A: Yes. Models can be serialized, and the library supports reproducible pipelines suitable for deployment. ## Sources - https://github.com/unit8co/darts - https://unit8co.github.io/darts/ --- Source: https://tokrepo.com/en/workflows/asset-9fc23920 Author: Script Depot