простое экспоненциальное сглаживание с python и statsmodels - PullRequest
0 голосов
/ 01 ноября 2018

Я попытался реализовать модель SES с Python для прогнозирования данных временных рядов. Но все же я пока не добился успеха. Hier код:

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.figure(figsize=(16,8))
plt.plot(y_hat_avg['temperature'], label='SES')
plt.plot(df.temperature, label='Actual')
plt.legend(loc='best')
plt.title('Average Annual Temperature, central England, 1851 – 1970 (yearly data)')
plt.grid(True)
plt.show()

И вот что у меня есть: введите описание изображения здесь

Может ли кто-нибудь помочь мне, пожалуйста?

...