Exponential Smoothing in Python — ELI5

Think about how you decide what jacket to wear tomorrow.

You probably think about today’s weather the most. Yesterday’s weather matters a little. Last week’s weather? Barely crosses your mind. And what it was like three months ago? Irrelevant. You naturally give more weight to recent experience and less weight to older memories.

Exponential smoothing does the same thing with numbers. When it looks at past data to predict the future, it trusts recent values the most and gradually cares less and less about older ones. The word “exponential” describes how quickly the importance fades — it drops off fast, like a ball rolling downhill.

Here is the neat part: you get to decide how quickly old data is forgotten. If your data changes quickly (like daily stock prices), you want to focus heavily on the most recent values. If your data is stable (like yearly population growth), you want to remember further back.

The simplest version just smooths out the bumps and predicts that tomorrow will be like a weighted average of the past. But fancier versions can also track trends (is the number going up?) and seasons (does it spike every December?). These are called Holt’s method and Holt-Winters, after the people who invented them.

Python makes this easy. You feed your numbers into a function, it figures out the best weights, and out comes a forecast.

The one thing to remember: Exponential smoothing predicts the future by trusting recent data more than old data — like your brain naturally does when deciding what to wear tomorrow.

pythontime-seriesexponential-smoothingforecasting

See Also