Forecasting

ARIMA-modellen in Python

James Fulton

Climate informatics researcher

De volgende waarde voorspellen

Neem een AR(1)-model

$y_t = a_1 y_{t-1} + \epsilon_t$

Voorspel de volgende waarde

$y_t = 0.6\; \text{x} \; 10 + \epsilon_t$

$y_t = 6.0 + \epsilon_t$

Onzekerheid van de voorspelling

$ 5.0 < y_t < 7.0$

ARIMA-modellen in Python

Eénstapsvoorspellingen

ARIMA-modellen in Python

Eénstapsvoorspellingen maken

# Make predictions for last 25 values
results = model.fit()

# Make in-sample prediction forecast = results.get_prediction(start=-25)
ARIMA-modellen in Python

Eénstapsvoorspellingen maken

# Make predictions for last 25 values
results = model.fit()

# Make in-sample prediction forecast = results.get_prediction(start=-25)
# forecast mean mean_forecast = forecast.predicted_mean

Voorspelde gemiddelde is een pandas Series

2013-10-28    1.519368
2013-10-29    1.351082
2013-10-30    1.218016
ARIMA-modellen in Python

Betrouwbaarheidsintervallen

# Get confidence intervals of forecasts
confidence_intervals = forecast.conf_int()

Methode voor betrouwbaarheidsintervallen geeft een pandas DataFrame

                                 lower y                       upper y
2013-09-28                     -4.720471                     -0.815384
2013-09-29                     -5.069875                      0.112505
2013-09-30                     -5.232837                      0.766300
2013-10-01                     -5.305814                      1.282935
2013-10-02                     -5.326956                      1.703974
ARIMA-modellen in Python

Voorspellingen plotten

plt.figure()

# Plot prediction
plt.plot(dates, 
         mean_forecast.values, 
         color='red', 
         label='forecast')

# Shade uncertainty area plt.fill_between(dates, lower_limits, upper_limits, color='pink') plt.show()
ARIMA-modellen in Python

Voorspellingen plotten

ARIMA-modellen in Python

Dynamische voorspellingen

ARIMA-modellen in Python

Dynamische voorspellingen maken

results = model.fit()
forecast = results.get_prediction(start=-25, dynamic=True)
# forecast mean
mean_forecast = forecast.predicted_mean

# Get confidence intervals of forecasts
confidence_intervals = forecast.conf_int()
ARIMA-modellen in Python

Out-of-sample forecasten

forecast = results.get_forecast(steps=20)
# forecast mean
mean_forecast = forecast.predicted_mean

# Get confidence intervals of forecasts
confidence_intervals = forecast.conf_int()
ARIMA-modellen in Python

Out-of-sample forecasten

forecast = results.get_forecast(steps=20)

ARIMA-modellen in Python

Laten we oefenen!

ARIMA-modellen in Python

Preparing Video For Download...