1

Output graph I tried forecasting with holt-winters model but I keep getting a prediction that is not consistent with what I expect. I've attached the output graph.

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import statsmodels.tsa
from statsmodels.tsa.holtwinters import ExponentialSmoothing

#importing data
df=pd.read_csv('####.csv')

df=df.dropna()

df['Date']=pd.to_datetime(df['Date'],errors='coerce',format='%d-%m-%y') 

df.set_index(['Date'],inplace=True)

print(df)
train=df[0:24]

#train['Date']=pd.to_datetime(train['Date'],errors='coerce',format='%m-%d-%y') 

test=df[24:]
test=test.dropna()

#test['Date']=pd.to_datetime(test['Date'],errors='coerce',format='%m-%d-%y') 

y_hat_avg = test.copy()
y_hat_avg=y_hat_avg.dropna()
model = ExponentialSmoothing(np.asarray(train['REVPAR']),seasonal_periods=12 ,seasonal='mul').fit()

y_hat_avg['Holt_Winter'] = model.predict(start=24, end=30)
#y_hat_avg['Holt_Winter'] = model.forecast(len(test))

print(y_hat_avg)
plt.figure(figsize=(16,8))
pd.plotting.register_matplotlib_converters()
plt.plot( train.index,train['REVPAR'], label='Train')

plt.plot( test.index,test['REVPAR'], label='Test')

plt.plot(y_hat_avg.index,y_hat_avg['Holt_Winter'], label='Holt_Winter')
plt.legend(loc='best')
plt.show()

The predicted values don't match with the test values

Aastha Jha
  • 153
  • 1
  • 2
  • 14
  • Hi Aastha could you show what you predicted vs what you expected and explain what is off? It would help people answer your question – Daniel Butler Aug 10 '19 at 16:20
  • Hi @DanielButler I've attached an image of the output graph. I don't understand what I did wrong – Aastha Jha Aug 10 '19 at 17:53

0 Answers0