Time series forecasting involves model building on historical time-stamped data to make scientific predictions and drive future strategic decision-making. Time series forecasting has many uses in various domains including:

  • Predict consumer demand for every product
  • Forecasting pandemic spread, diagnosis, medication, and planning in healthcare
  • Anomaly detection, cyber security, and predictive maintenance
  • Predict if the current infrastructure can handle traffic in the near and far future

and many more.

Time series forecasting is a bit different from traditional machine learning use-case, as it involves a temporal ordering of the data that must be considered during feature engineering and modeling.

Motivation:

For training a time-series forecasting model, you end up in a situation where you use Pandas for pre-processing, statsmodel for seasonality and statistical tests, scikit-learn or Facebook Prophet for forecasting, and custom code to implement backtesting and model selection.

End-to-end time series forecasting becomes a tedious task for data scientists as different libraries have different APIs and data types. For traditional machine learning use-cases, we have the scikit-learn package, which provides a consistent API for end-to-end machine learning modeling.

Darts attempts to be a scikit-learn for time series, and its primary goal is to simplify the whole time series forecasting approach. In this article, we will discuss the darts package and its implementation.

Darts:

Darts is a Python library for easy manipulation and forecasting of time series. It offers implementations of a variety of models, from classics such as ARIMA to deep neural networks, that can be implemented the same way as scikit-learn models (using fit and predict APIs).

Some of the features of the Darts package are:

  • It's built around the immutable TimeSeries class
  • It has a unified and user-friendly scikit-learn-like APIs interface like fit() and predict()
  • It offers a variety of models from classical models to state-of-the-art ML/DL approaches
  • It provides APIs for end-to-end time series forecasting use-cases including data discovery, data preprocessing, forecasting, and model selection and evaluation.
None
(Source), Overview of Dart package

Forecasting with Darts:

Further, let's discuss, explore and implement the fundamental capabilities of the Darts package for the Air Passengers Dataset (open-source) that has Monthly Air Passengers Dataset, from 1949 to 1960.

Read TimeSeries:

Read the Air Passenger dataset and split it into training and validation data, and further visualize it.

None
(Image by Author), Visualize the Training and Validation data

Forecasting:

Darts offers the implementation of various classical and advanced time-series modeling techniques including ARIMA, Theta, Exponential Smoothing, N-Beats, Facebook Prophet, etc.

Follow the darts.models documentation to know more about each of the implementation.

None
(Image by Author), Visualize the Training, Validation, and Predicted data

Evaluation and Tuning:

Darts offers implementation to compute the performance of your model, and tune the hyperparameters of the estimator to get an optimized model.

Advanced Features:

  • Along with classical time-series models, Darts also offers state-of-the-art modern ML/DL functionalities.
  • Probabilistic Forecasting
  • Training on multiple series and large datasets
  • Support for multi-dimensional series. N-Beats modeling can be performed on multiple dimensional time series data.
  • Include external past and future data. Past and future covariates data can be passed during model training to improve the model performance.

Conclusion:

Darts is a handy package that offers user-friendly and modern ML implementation specific to time series use-cases.

Limitations of the Darts package can be the un-availability of static covariates, AutoML implementation, Anomaly Detection, and pre-trained models.

References:

[1] Darts documentation: https://unit8co.github.io/darts/#

[2] Air Passenger Data (open-source license): https://www.kaggle.com/datasets/rakannimer/air-passengers

Thank You for Reading