ETS (Exponential Smoothing) › Example: Forecasting Monthly Sales
Machine Learning from ScratchAll chapters ETS (Exponential Smoothing) › Example: Forecasting Monthly SalesOne section · Sections in this chapter4 / 8 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Let's work through a detailed, step-by-step example that demonstrates exponential smoothing in action. This hands-on walkthrough will help you understand exactly how the method processes data and generates forecasts.
The scenario: You're managing a retail store and need to forecast next month's sales to plan inventory. You have 10 months of historical sales data showing a clear upward trend. Let's see how exponential smoothing can help you make this forecast.
Given Data (Monthly Sales in thousands of dollars):
| Month | Sales | Month | Sales |
|---|---|---|---|
| 1 | 100 | 6 | 120 |
| 2 | 105 | 7 | 125 |
| 3 | 110 | 8 | 130 |
| 4 | 115 | 9 | 135 |
| 5 | 118 | 10 | 140 |
Looking at this data, we can see sales are increasing steadily, from 100 in month 1 to 140 in month 10. This upward trend is exactly the kind of pattern where exponential smoothing can be effective, though we'll use simple exponential smoothing here to keep the example clear (in practice, you might use Holt's method for this trending data).
Step 1: Initialize the forecast
Before we can start applying the exponential smoothing formula, we need an initial forecast for the first period. Since we have no prior data to work with, a common approach is to use the first observation as the initial forecast:
This initialization assumes that the first observation is our best guess for what the forecast would have been. In practice, there are other initialization methods (like using the average of the first few observations), but using the first observation is simple and often works well.
Step 2: Choose the smoothing parameter
The choice of is important. For this example, let's use . This means:
- 30% weight goes to the current observation (we're moderately responsive to new data)
- 70% weight goes to the previous forecast (we maintain stability from historical patterns)
This moderate value is a good starting point for data with a trend, as it balances responsiveness to the upward movement with stability against random fluctuations. In practice, you might try different values and choose the one that minimizes forecast errors.
Step 3: Calculate forecasts using the exponential smoothing formula
Now we'll apply the formula recursively:
Let's trace through each calculation to see exactly how the method works:
Month 2: We forecast month 2 using month 1's actual sales and our initial forecast:
where and .
Since both the actual value and initial forecast were 100, the forecast remains 100. Notice that the actual sales in month 2 were 105, so our forecast of 100 was too low by 5 units.
Month 3: Now we use month 2's actual sales (105) and our previous forecast (100):
where and .
The forecast increases slightly to 101.5. The 30% weight on the higher actual value pulls the forecast up, but the 70% weight on the previous forecast keeps it relatively stable. The actual sales in month 3 were 110.
Month 4: Continuing the pattern:
where and .
The forecast continues to increase, gradually catching up to the upward trend. Notice how each new observation pulls the forecast upward, but the method maintains stability by giving substantial weight to the previous forecast.
Month 5:
Month 6:
Month 7:
Month 8:
Month 9:
Month 10:
Observing the pattern: Notice how the forecasts gradually increase over time, tracking the upward trend in the data. The method is "learning" from each new observation, adjusting the forecast upward as it sees consistently higher sales. However, because gives only 30% weight to new observations, the forecasts lag behind the actual values. This is the characteristic behavior of simple exponential smoothing on trending data.
Step 4: Calculate the forecast for Month 11
Now we can forecast the next month (month 11) using month 10's actual sales:
Our forecast for month 11 is 129.544 thousand dollars. This forecast incorporates all the historical information through the recursive formula, with recent observations (especially month 10's sales of 140) having the most influence.
Step 5: Calculate forecast errors and evaluate performance
To assess how well our model performed, we need to measure the forecast errors. Let's calculate the error for each period where we made a forecast:
| Month | Actual | Forecast | Error | |Error| | Error² | |-------|--------|----------|-------|-------|--------| | 2 | 105 | 100.000 | 5.000 | 5.000 | 25.000 | | 3 | 110 | 101.500 | 8.500 | 8.500 | 72.250 | | 4 | 115 | 104.050 | 10.950| 10.950| 119.903| | 5 | 118 | 107.335 | 10.665| 10.665| 113.742| | 6 | 120 | 110.535 | 9.465 | 9.465 | 89.586 | | 7 | 125 | 113.375 | 11.625| 11.625| 135.141| | 8 | 130 | 116.863 | 13.137| 13.137| 172.581| | 9 | 135 | 120.804 | 14.196| 14.196| 201.526| | 10 | 140 | 125.063 | 14.937| 14.937| 223.114|
Understanding the errors: Notice that all errors are positive, meaning we consistently under-forecasted. This is exactly what we'd expect with simple exponential smoothing on trending data because the method lags behind the upward trend. The errors also increase over time, which reflects that the gap between the forecast and actual values widens as the trend continues.
Calculating summary metrics:
Mean Absolute Error (MAE):
where is the number of forecast periods (months 2 through 10), is the actual value at time , and is the forecast for time .
The MAE of 10.941 tells us that, on average, our forecasts were off by about 10.9 thousand dollars. This is a straightforward measure that treats all errors equally.
Mean Squared Error (MSE):
where is the number of forecast periods, is the actual value at time , and is the forecast for time . The MSE penalizes larger errors more heavily than smaller ones because it squares the forecast errors.
The MSE of 127.316 penalizes larger errors more heavily. Since our errors increase over time, the MSE is higher than it would be if errors were more evenly distributed.
Step 6: Interpret the results
The exponential smoothing model with produces a forecast of 129.544 thousand dollars for Month 11.
What the forecast tells us:
- The model has learned from the historical upward trend and projects it forward
- The forecast of 129.544 is higher than month 10's forecast (125.063), showing the continued upward movement
- However, it's lower than month 10's actual sales (140), showing the lag characteristic of simple exponential smoothing on trending data
What the errors tell us:
- The MAE of 10.941 indicates that, on average, forecasts are off by about 10.9 thousand dollars
- Relative to sales levels around 100-140, this represents approximately 8-9% error
- The consistent positive errors suggest we might benefit from using Holt's method (double exponential smoothing) to better capture the trend
Key insights from this example:
- Exponential smoothing gradually adapts to trends, but with a lag
- The recursive formula efficiently incorporates all historical information
- The smoothing parameter controls the balance between responsiveness and stability
- Error analysis reveals systematic patterns (like consistent under-forecasting) that can guide model improvement
This example demonstrates exponential smoothing in action, showing how the method processes data step-by-step to create forecasts that balance recent observations with historical patterns.