For example, if I had the following time series:
x = [1999, 2000, 2001, ... , 2015]
annual_sales = [10000000, 1500000, 1800000, ... , 2800000]
How would I forecast sales for year 2016 using Holt-Winters method in Python?
Thus, on the basis of these results, the Holt-Winters additive model is more efficient in predicting the prices of agricultural products than the ARIMA model. In this study, we looked at forecasting agricultural commodity prices using the time series model.
The Holt-Winters method uses exponential smoothing to encode lots of values from the past and use them to predict “typical” values for the present and future. Exponential smoothing refers to the use of an exponentially weighted moving average (EWMA) to “smooth” a time series.
I found the only difference between ARIMA and Exponential smoothing model is the weight assignment procedure to its past lag values and error term. In that case Exponential should be considered much better that ARIMA due to its weight assigning method.
Exponential smoothings methods are appropriate for non-stationary data (ie data with a trend and seasonal data). ARIMA models should be used on stationary data only. One should therefore remove the trend of the data (via deflating or logging), and then look at the differenced series.
You could use ExponentialSmoothing from Statsmodels.tsa as such:
import pandas as pd
import statsmodels.tsa.holtwinters as hw
d = {'Year':x, 'Sales':annual_sales}
sales_df = pd.DataFrame(d)
sales_df['Year] = pd.to_datetime(sales_df['Year])
sales_df.set_index('Year', inplace=True)
model = hw.ExponentialSmoothing(sales_df).fit()
Once the model is generated, you can use predict()
.
It does seem, however, that it is only available for the latest version of statsmodels. See here. In my Windows 10 Anaconda based Python 3.6 installation, I use statsmodels 0.9.0 in which it works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With