데이터분석/분석-지도학습

holt-winter 선형추세+계절알고리즘 #비선형적 계절성 추정

씩씩한 IT블로그 2021. 1. 5. 11:31
반응형

 

holt-winter 알고리즘

비선형적 계절성을 추정하는데 사용한다. 

(1) additive seasonal meathod

 

(2) multiplicative seasonal meathod

 

코드

import pandas as pd
from statsmodels.tsa.api import ExponentialSmoothing
import matplotlib.pyplot as plt

location = './Data/BikeSharingDemand/Bike_Sharing_Demand_Full.csv'
raw_all = pd.read_csv(location)

# Holt-Winter's Seasonal
target = raw_all.loc[:24*7*2, 'count']
target.plot(marker='o', color='black', legend=True, figsize=(20,6), ylim=(0,400))

fit1 = ExponentialSmoothing(target, seasonal_periods=24, trend='add', seasonal='add').fit(use_boxcox=True)
fcast1 = fit1.forecast(24).rename("Non-damped")
fcast1.plot(marker='o', color='blue', legend=True)
fit1.fittedvalues.plot(style='--', color='blue')

fit2 = ExponentialSmoothing(target, seasonal_periods=24, trend='add', seasonal='add', damped=True).fit(use_boxcox=True)
fcast2 = fit2.forecast(24).rename("Damped")
fcast2.plot(marker='o', color='red', legend=True)
fit2.fittedvalues.plot(style='--',  color='red')

plt.show()

 

*출처 : 패스트캠퍼스 "파이썬을 활용한 시계열 데이터분석 A-Z"

반응형