Forecasting with ARIMA
Once you have fitted an ARIMA model to your time series data, you can use it to forecast future values. The forecasting process involves projecting the time series beyond the observed data, using the model's learned parameters. ARIMA models not only provide point forecasts (the most likely future values) but also forecast intervals, which represent the range within which the true values are likely to fall with a certain probability (usually 95%).
Forecast intervals are important because they account for the uncertainty inherent in predicting future values. A narrower interval suggests higher confidence in the forecast, while a wider interval indicates more uncertainty. When interpreting ARIMA forecast plots, pay attention to both the predicted values and the intervals. The intervals typically widen as the forecast horizon increases, reflecting growing uncertainty further into the future.
1234567891011121314151617181920212223242526272829303132333435363738import pandas as pd import matplotlib.pyplot as plt from statsmodels.tsa.arima.model import ARIMA # Generate example time series data date_range = pd.date_range(start="2020-01-01", periods=100, freq="ME") data = pd.Series( [i + 10 * (i % 12 == 0) + 5 * (i % 6 == 0) for i in range(100)], index=date_range ) # Fit ARIMA model (order chosen for demonstration) model = ARIMA(data, order=(1, 1, 1)) fitted_model = model.fit() # Forecast next 12 periods forecast_result = fitted_model.get_forecast(steps=12) forecast = forecast_result.predicted_mean conf_int = forecast_result.conf_int() # Plot original data and forecasts with intervals plt.figure(figsize=(10, 6)) plt.plot(data, label="Observed") plt.plot(forecast.index, forecast, label="Forecast", color="orange") plt.fill_between( forecast.index, conf_int.iloc[:, 0], conf_int.iloc[:, 1], color="orange", alpha=0.3, label="95% Confidence Interval" ) plt.xlabel("Date") plt.ylabel("Value") plt.title("ARIMA Forecast with 95% Confidence Intervals") plt.legend() plt.tight_layout() plt.show()
Kiitos palautteestasi!
Kysy tekoälyä
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme
Can you explain how to interpret the ARIMA forecast plot?
What do the parameters (1, 1, 1) in the ARIMA model mean?
How can I choose the best ARIMA order for my own data?
Awesome!
Completion rate improved to 6.67
Forecasting with ARIMA
Pyyhkäise näyttääksesi valikon
Once you have fitted an ARIMA model to your time series data, you can use it to forecast future values. The forecasting process involves projecting the time series beyond the observed data, using the model's learned parameters. ARIMA models not only provide point forecasts (the most likely future values) but also forecast intervals, which represent the range within which the true values are likely to fall with a certain probability (usually 95%).
Forecast intervals are important because they account for the uncertainty inherent in predicting future values. A narrower interval suggests higher confidence in the forecast, while a wider interval indicates more uncertainty. When interpreting ARIMA forecast plots, pay attention to both the predicted values and the intervals. The intervals typically widen as the forecast horizon increases, reflecting growing uncertainty further into the future.
1234567891011121314151617181920212223242526272829303132333435363738import pandas as pd import matplotlib.pyplot as plt from statsmodels.tsa.arima.model import ARIMA # Generate example time series data date_range = pd.date_range(start="2020-01-01", periods=100, freq="ME") data = pd.Series( [i + 10 * (i % 12 == 0) + 5 * (i % 6 == 0) for i in range(100)], index=date_range ) # Fit ARIMA model (order chosen for demonstration) model = ARIMA(data, order=(1, 1, 1)) fitted_model = model.fit() # Forecast next 12 periods forecast_result = fitted_model.get_forecast(steps=12) forecast = forecast_result.predicted_mean conf_int = forecast_result.conf_int() # Plot original data and forecasts with intervals plt.figure(figsize=(10, 6)) plt.plot(data, label="Observed") plt.plot(forecast.index, forecast, label="Forecast", color="orange") plt.fill_between( forecast.index, conf_int.iloc[:, 0], conf_int.iloc[:, 1], color="orange", alpha=0.3, label="95% Confidence Interval" ) plt.xlabel("Date") plt.ylabel("Value") plt.title("ARIMA Forecast with 95% Confidence Intervals") plt.legend() plt.tight_layout() plt.show()
Kiitos palautteestasi!