in afa/core.py [0:0]
def exsmooth(y, horiz, **kwargs):
"""
"""
alpha = kwargs.get("alpha", 0.2)
if len(y) > 8:
y = np.trim_zeros(y, trim ='f')
if len(y) == 0:
y = np.zeros(1)
extra_periods = horiz-1
f = [y[0]]
# Create all the m+1 forecast
for t in range(1,len(y)-1):
f.append((1-alpha)*f[-1]+alpha*y[t])
# Forecast for all extra months
for t in range(extra_periods):
# Update the forecast as the last forecast
f.append(f[-1])
yp = np.array(f[-horiz:]).clip(0)
# if use_log:
# yp = np.exp(yp)
return yp