simple exponential smoothing with python and statsmodels

I have tried to implement a SES model with Python to forecast time series data. But still, I've not been successful yet. Hier the code:

df = pd.read_csv('C:/UniBw/7_HT2018/Bachelorarbeit/data/average-annual-temperature-centr.csv', nrows = 121)
train = df[:101]
test = df[100:]

#Aggregating the dataset at yearly level
df.Timestamp = pd.to_datetime(df.Year,format='%Y',errors='ignore') 
df.index = df.Timestamp
df = df.resample('365D').mean()
test.Timestamp = pd.to_datetime(test.Year,format='%Y',errors='ignore') 
test.index = test.Timestamp 
test = test.resample('365D').mean()

from statsmodels.tsa.api import ExponentialSmoothing, SimpleExpSmoothing, Holt
y_hat_avg = test.copy()
fit2 = SimpleExpSmoothing(np.asarray(train['temperature'])).fit(smoothing_level=0.6)
y_hat_avg['temperature'] = fit2.forecast(len(test))
plt.plot(y_hat_avg['temperature'], label='SES')
plt.plot(df.temperature, label='Actual')
plt.title('Average Annual Temperature, central England, 1851 – 1970 (yearly data)')

And hier what I've got:enter image description here

Could anyone help me please?


0 Answers simple exponential smoothing with python and statsmodels