darts is a Python library for easy manipulation and forecasting of time series. It contains a variety of models, from classics such as ARIMA to deep neural networks. The models can all be used in the same way, using fit() and predict() functions, similar to scikit-learn. The library also makes it easy to backtest models, and combine the predictions of several models and external regressors. Darts supports both univariate and multivariate time series and models, and the neural networks can be trained on multiple time series.
Once your environment is set up you can install darts using pip:
pip install darts
For more detailed install instructions you can refer to our installation guide at the end of this page.
TimeSeries object from a Pandas DataFrame, and split it in train/validation series:
import pandas as pd from darts import TimeSeries df = pd.read_csv('AirPassengers.csv', delimiter=",") series = TimeSeries.from_dataframe(df, 'Month', '#Passengers') train, val = series.split_after(pd.Timestamp('19580101'))
Fit an exponential smoothing model, and make a prediction over the validation series' duration:
from darts.models import ExponentialSmoothing model = ExponentialSmoothing() model.fit(train) prediction = model.predict(len(val))
import matplotlib.pyplot as plt series.plot(label='actual') prediction.plot(label='forecast', lw=2) plt.legend() plt.xlabel('Year')
We invite you to go over the example and tutorial notebooks in the examples directory.
Currently, the library contains the following features:
- Exponential smoothing,
- ARIMA & auto-ARIMA,
- Facebook Prophet,
- Theta method,
- FFT (Fast Fourier Transform),
- Recurrent neural networks (vanilla RNNs, GRU, and LSTM variants),
- Temporal convolutional network.
Data processing: Tools to easily apply (and revert) common transformations on time series data (scaling, boxcox, …)
Metrics: A variety of metrics for evaluating time series' goodness of fit; from R2-scores to Mean Absolute Scaled Error.
Backtesting: Utilities for simulating historical forecasts, using moving time windows.
Regressive Models: Possibility to predict a time series from several other time series (e.g., external regressors), using arbitrary regressive models
Multivariate Support: Tools to create, manipulate and forecast multivariate time series.