Ejemplo n.º 1
0
def holtt(i, fc_periods, df):
    df = df
    hell = np.asarray(df.iloc[0:, 0])
    train = df.iloc[394:, 0]
    modelo = SimpleExpSmoothing(hell).fit(smoothing_level=.2, optimized=False)
    resultado = modelo.fittedvalues
    df['pronostico'] = resultado
    nombre = list(df.columns.values.tolist())
    fit1 = Holt(hell).fit(smoothing_level=0.35,
                          smoothing_slope=0.1,
                          optimized=True)
    print(fit1.summary())
    fcast1 = fit1.forecast(fc_periods)
    return (fcast1)
            'r2': r2
        },
        ignore_index=True)
end = timer()
print(f' Total time taken to complete grid search in seconds:{(end - start)}')
print(f' Below mentioned parameter gives least RMSE and r2')
df_results_moni.sort_values(by=['RMSE', 'r2']).head(1)

# In[57]:

fit1 = Holt(train, damped=False).fit(smoothing_level=0.9,
                                     smoothing_slope=0.6,
                                     damping_slope=0.1,
                                     optimized=False)
Forecast_custom_pred = fit1.forecast(30)
fit1.summary()

# In[58]:

timeseries_evaluation_metrics_func(test, Forecast_custom_pred)

# In[59]:

# Let’s check whether the double exponential smoothing is able to find the best parameters
fitESAUTO = Holt(train).fit(optimized=True, use_brute=True)
fitESAUTO.summary()

# In[60]:

fitESAUTOpred = fitESAUTO.forecast(30)
timeseries_evaluation_metrics_func(test, fitESAUTOpred)