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
