# Good libraries for exponential time series smoothing

I've a pandas series which contains the daily load consumption of a city for a year. I wish to forecast the load consumption for next year.As a result , I'm making use of exponential time series.

The problem is apart from statsmodels' SimpleExpSmoothing , ExponentialSmoothing and Holt I couldn't find any other library which does this.

I work in Google Colab which uses Python 3.7 and the only version of Statsmodel which is compatible with Python 3.7 is 0.10.2 which has a lot of issues.

As a result , I'd like to know if there any other libraries which accomplish this task. (I'm too lazy to code this from scratch).

You can code exponential smoothing in less than 10 lines:

class ExpSmooth:
def __init__(self, a):
assert 0 <= a <= 1
self.a = a
self.y_smooth = 0

def smooth(self, Input):
self.y_smooth = self.a * Input + (1 - self.a) * self.y_smooth
return self.y_smooth


Then the smoothed values for each time step will be:

smoother = ExpSmooth(0.2)
smoothed = [smoother.smooth(y) for y in your_time_series]


You could probably use Pandas' apply method to apply smoother.smooth to each element of your time-series.

The Holt model adds one more smoothed state (so you'll have self.trend_smooth and self.nontrend_smooth) and a corresponding update equation. That should take about 10 quick and simple lines of code as well.

• With just a couple more lines you can add the bias correction (keeping track of the product of all smoothing terms a used so far and dividing self.y_smooth by 1 - that product before returning, so that (if desired) the series doesn't start out with a default value of 0 Commented Jan 27, 2022 at 14:27
• This looks great , just one doubt: I've to forecast around 8000 values (all hours in a year) , but the above given code only computes 1 value , am I correct ? Commented Jan 27, 2022 at 15:02
• @akshit.C, the part of the answer that starts with "Then the smoothed values for each time step will be" explains how to apply smoothing to the full time-series. Commented Jan 27, 2022 at 15:36