2
$\begingroup$

I have to code the "Forecast.ETS" function from excel in Python to predicts a future values based on existing (historical) values. In the Excel documentation they write that it is based on the AAA version of the Exponential Smoothing (ETS) algorithm.

Excel Documentation:

Microsoft: Calculates or predicts a future value based on existing (historical) values by using the AAA version of the Exponential Smoothing (ETS) algorithm. The predicted value is a continuation of the historical values in the specified target date, which should be a continuation of the timeline.

Python Documentation: ETS models in python the specific ETS model for AAA is the Holt-Winters.

Coding that: Data would be daily data and we want to predict 50 days

data = [533.0,769.0,1014.0,1362.0,1368.0,1490.0,1493.0,1570.0,2240.0,2543.0,2617.0,
        3180.0,3401.0,3452.0,3513.0,3666.0,3710.0,3961.0,4029.0,4084.0,4217.0,4464.0,
        5109.0,5198.0,5279.0,5731.0,5923.0,6169.0,6361.0,6455.0,6713.0,6885.0,7267.0,7422.0,
        7670.0,8300.0,8401.0,8430.0,8850.0,10162.0,10366.0,10640.0,10820.0,
        10892.0,10940.0,11282.0,11403.0,12150.0,12637.0,13173.0]

index_values = pd.date_range('2021-01-15', '2021-03-05', freq="D")
data_analysis = pd.Series(data, index=index_values)

model = ETSModel(data_analysis, error="add", trend="add", seasonal="add",damped_trend=True, 
seasonal_periods=7)
fit = model.fit()

pred = fit.get_prediction(start='2021-03-05', end='2021-05-14')
df_prediction = pred.summary_frame(alpha=0.25)
df_prediction

the output from python look like this:

             mean             pi_lower       pi_upper
2021-03-06  13632.805132    13341.737194    13923.873071
2021-03-07  13899.410604    13461.334446    14337.486761
2021-03-08  14189.704924    13620.755823    14758.654025
2021-03-09  14609.667134    13915.355002    15303.979266
2021-03-10  14825.921265    14008.092306    15643.750223

The same algorith in Excel return that data:

            mean    pi_lower pi_upper
2021-03-06  13386   12910    13862
2021-03-07  13631   12990    14271
2021-03-08  13876   13105    14647
2021-03-09  14121   13238    15003
2021-03-10  14365   13383    15347

So the predictions are very similar but not the same, is this normal, should I be worried, is this to be expected because excel requires "int" and the python method needs float ?

$\endgroup$
3
  • 2
    $\begingroup$ There could be all sorts of differences in the fitting of the model leading to slightly different parameters and estimated initial states, so check those. Also, you've set the Python version to use a damped trend, which is not the "standard" AAA ETS model, so are you sure Excel also does this? $\endgroup$
    – Chris Haug
    Commented Jul 1, 2021 at 12:39
  • $\begingroup$ Hi @ChrisHaug Excel is using AAA and my Modelin Python ist using AAA too.. I update the Questin with both documentations, thanks for reply :) $\endgroup$ Commented Jul 2, 2021 at 7:25
  • 1
    $\begingroup$ Your Python implementation is not using AAA, it has damped_trend = True. The statsmodels documentation you link to is misleading because in the Holt-Winters section, they present the AAA model but then the code sample uses a damped trend without comment. You can see in the output of code chunk [10] that the model is "ETS(AAdA)", not "ETS(AAA)". $\endgroup$
    – Chris Haug
    Commented Jul 2, 2021 at 13:10

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.