I did time series forecasting analysis with ExponentialSmoothing in python. I used statsmodels.tsa.holtwinters.
model = ExponentialSmoothing(df, seasonal='mul', seasonal_periods=12).fit()
pred = model.predict(start=df.index[0], end=122)
plt.plot(df_fc.index, df_fc, label='Train')
plt.plot(pred.index, pred, label='Holt-Winters')
plt.legend(loc='best')
I want to take confidence interval of the model result. But I couldn't find any function about this in "statsmodels.tsa.holtwinters - ExponentialSmoothing". How to I do that?

From this answer from a GitHub issue, it is clear that you should be using the new
ETSModelclass, and not the old (but still present for compatibility)ExponentialSmoothing.ETSModelincludes more parameters and more functionality thanExponentialSmoothing.To calculate confidence intervals, I suggest you to use the
simulatemethod ofETSResults:Basically, calling the
simulatemethod you get a DataFrame withn_repetitionscolumns, and withn_steps_predictionsteps (in this case, the same number of items in your training data-sety). Then, you calculate the confidence intervals with DataFramequantilemethod (remember theaxis='columns'option). You could also calculate other statistics from thedf_simul.I also checked the source code:
simulateis internally called by theforecastmethod to predict steps in the future. So, you could also predict steps in the future and their confidence intervals with the same approach: just useanchor='end', so that the simulations will start from the last step iny.To be fair, there is also a more direct approach to calculate the confidence intervals: the
get_predictionmethod (which usessimulateinternally). But I do not really like its interface, it is not flexible enough for me, I did not find a way to specify the desired confidence intervals. The approach with thesimulatemethod is pretty easy to understand, and very flexible, in my opinion.If you want further details on how this kind of simulations are performed, read this chapter from the excellent Forecasting: Principles and Practice online book.