liveBook · Manning

Darts

As explained in Outlier Detection in Python

Darts is a Python library for time-series forecasting and related model evaluation and manipulation tasks.

Darts is a Python library for forecasting time series with models such as ARIMA, while supporting evaluation and investigation of forecast behavior. section 17.2.6

A practical Darts workflow:

  • Convert a dataframe containing timestamps and values into a Darts TimeSeries object. section 17.2.6
  • Fit ARIMA on historical values, reserve a final interval, and predict that interval. section 17.2.6
  • Plot forecasts with quantile bounds and evaluate predictions using measures such as MAPE. section 17.2.6

Forecasting the final 60 days

Create a TimeSeries from timestamped values, configure ARIMA(p=7, d=2, q=2), fit it on all but the last 60 observations, and predict those 60 points. The forecast preserves weekly structure but increasingly relies on the mean; accuracy depends on parameter tuning. section 17.2.6

Listing 17.7 Forecasting values using Darts with ARIMA
from darts import TimeSeries
from darts.models import ARIMA
 
df['timestamp'] = df.index                                         #1
series = TimeSeries.from_dataframe(df, "timestamp", "Values")
 
model = ARIMA(p=7, d=2, q=2)                                       #2
model.fit(series[:-60])
pred = model.predict(60)                                           #3
 
pred.plot(label="forecast", low_quantile=0.05, high_quantile=0.95) #4
plt.legend()
plt.show()

Use the complete Python listing for dataframe conversion, ARIMA fitting, prediction, and forecast plotting. section 17.2.6

How Outlier Detection in Python covers it

How deep it goes
Demonstrates dataframe conversion, model fitting, prediction, plotting, and evaluation, while deferring parameter tuning to experimentation.
Examples
Uses synthetic daily data, weekly and annual lag features, held-out forecasts, plotted intervals, and a deliberately injected outlier.
What it assumes
Assumes Python dataframe and plotting familiarity, while demonstrating the required TimeSeries conversion and train-predict split.
What you can do after
Apply Darts to convert timestamped data, fit ARIMA, generate forecasts, plot uncertainty, and compare predictions with MAPE.
How it connects
Connects ARIMA with Exponential Smoothing, Random Forest regression, lag features, TimeSeries objects, and MAPE.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Outlier Detection in Python. The section links point to the parts of the book it draws on.