Simple Exponential Smoothing with a Tuned Alpha

medium
Unit 18 · Correlation & Forecasting0/2 to milestone

Simple exponential smoothing keeps a level ℓt=αyt+(1−α)ℓt−1\ell_t = \alpha y_t + (1-\alpha)\ell_{t-1}, starting from ℓ0=y0\ell_0 = y_0; the one-step-ahead forecast for yt+1y_{t+1} is ℓt\ell_t.

Implement:

  • ses(y, alpha) returning (levels, sse) where sse is the sum of squared one-step-ahead errors for t=1..n−1t = 1..n-1
  • fit_alpha(y, grid) returning the alpha in grid with the smallest SSE (first wins ties)
#forecasting#time-series#smoothing2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Simple Exponential Smoothing with a Tuned Alpha · TechGradify