# Exponential Smoothing: A Beginner's Guide to Getting Started

###
By
Community /
Developer

May 24, 2023

#### Navigate to:

Exponential smoothing is a time series forecasting method that uses an exponentially weighted average of past observations to predict future values.

This method assigns more weight to recent observations and less to older observations, allowing the forecast to adapt to changing trends in the data.

The resulting forecast is a smoothed version of the original time series less affected by random fluctuations or noise in the data.

In this post, we’ll look at the basics of exponential smoothing, including how it works, the types of exponential smoothing, and how to implement exponential smoothing in Python.

## What is exponential smoothing?

Exponential smoothing is a technique that’s used to forecast time series data by smoothing out fluctuations in the data. The technique was first introduced by Robert Goodell Brown in 1956 and then further developed by Charles Holt in 1957. It has since become one of the most widely used methods for forecasting.

The basic idea behind exponential smoothing is to give more weight to recent observations than to older observations. This is achieved by assigning weights to each observation, with the weights decreasing exponentially as the observations become older. The weights are then used to calculate a weighted moving average of the data, which is used as the forecast for the next period.

Exponential smoothing is based on the assumption that the future values of a time series are a function of its past values. The method works well when the time series has a trend and/or a seasonal component, but it can also be used for data that’s stationary (i.e., without trend or seasonality).

## Exponential smoothing forecasting

Exponential smoothing is a method of forecasting that uses a weighted average of past observations to predict future values. The weights assigned to past observations are exponential, with more recent observations having a higher weight than older observations.

## Types of exponential smoothing

There are several types of exponential smoothing methods, each with its own formulae and assumptions. The most commonly used methods include:

### 1. Simple Exponential Smoothing

Simple exponential smoothing (SES), also known as single exponential smoothing, is the simplest form of exponential smoothing. It assumes that the time series has no trend or seasonality.

The forecast for the next period is based on the weighted average of the previous observation and the forecast for the current period.

The formula for simple exponential smoothing is:

s_{(t)} = αx_{(t)} + (1-α)s_{t-1}

where

- s
_{(t)}is the smoothed value at time t, - x
_{(t)}is the observed value at time t, - s
_{t-1}is the previous smoothed statistic, and - α is the smoothing parameter between 0 and 1.

The smoothing parameter α controls the weight given to the current observation and the previous forecast.

A high value of α gives more weight to the current observation, while a low value of α gives more weight to the previous forecast.

### 2. Holt’s linear exponential smoothing

Holt’s linear exponential smoothing, also known as double exponential smoothing, is used to forecast time series data that has a linear trend but no seasonal pattern. This method uses two smoothing parameters: α for the level (the intercept) and β for the trend.

The formulas for double exponential smoothing are:

s_{t} = αx_{t} + (1 – α)(s_{t-1} + b_{t-1})

β_{t} = β(s_{t} – s_{t-1}) + (1 – β)b_{t-1}

where

- bt is the slope and best estimate of the trend at time t,
- α is the smoothing parameter of data (0 < α < 1), and
- β is the smoothing parameter for the trend (0 < β < 1).

Holt’s method is more accurate than SES for time series data with a trend, but it doesn’t work well for time series data with a seasonal component.

### 3. Holt-Winters’ exponential smoothing

Holt-Winters’ exponential smoothing, also referred to as triple exponential smoothing, is used to forecast time series data that has both a trend and a seasonal component. It uses three smoothing parameters: α for the level (the intercept), β for the trend, and γ for the seasonal component.

The triple exponential smoothing formulas are given by:

where:

- s
_{t}= smoothed statistic; it’s the simple weighted average of current observation Y_{t} - s
_{t-1}= previous smoothed statistic - α = smoothing factor of data (0 < α < 1)
- t = time period
- b
_{t}= best estimate of a trend at time t - β = trend smoothing factor (0 < β <1)
- c
_{t}= seasonal component at time t - γ = seasonal smoothing parameter (0 < γ < 1)

Holt-Winters’ method is the most accurate of the three methods, but it’s also the most complex. It requires more data and more computation than the other methods.

## When to use exponential smoothing

Exponential smoothing is most useful for time series data that has a consistent trend, seasonality, and random fluctuations.

It’s particularly useful for short to medium-term forecasting of business metrics such as sales, revenue, and customer traffic. It’s also useful for monitoring and predicting seasonal changes in industries such as tourism, agriculture, and energy.

Here are some other common situations where exponential smoothing can be useful:

**Time series forecasting**— One of the most common applications of exponential smoothing is in time series forecasting. If you have historical data for a particular variable over time, such as sales or website traffic, you can use exponential smoothing to forecast the future values of that variable.-
**Inventory management**— Exponential smoothing can be used to forecast demand for products or services, which can be helpful in inventory management. By forecasting demand, businesses can make sure they have enough inventory on hand to meet customer needs without overstocking, which can be expensive. -
**Finance**— It can be used in finance to forecast stock prices, interest rates, and other financial variables. This can be helpful for investors who are trying to make informed decisions about buying and selling stocks or other financial instruments. **Marketing**— It’s also used to forecast the effectiveness of marketing campaigns. By tracking the results of past campaigns and using exponential smoothing to forecast future performance, marketers can optimize their campaigns to achieve the best possible results.

## Why exponential smoothing is popular

Exponential smoothing is considered one of the most widely used time series forecasting methods due to its simplicity and effectiveness.

Unlike other methods, exponential smoothing can adapt to changes in data trends. It also provides accurate predictions by assigning different weights to different time periods based on their importance.

Exponential smoothing is computationally efficient, making it ideal for large datasets.

Additionally, it’s widely used in business forecasting, as it provides accurate and reliable forecasts for a range of applications, including demand forecasting, sales forecasting, and financial forecasting.

## Exponential smoothing in Python

Python has several libraries that can be used for exponential smoothing, including Pandas, Statsmodels, and Prophet. These libraries provide various functions and methods for implementing different types of exponential smoothing methods.

### The dataset

For this example, we’ll be using the AirPassengers dataset, which is a time series dataset that contains the monthly number of airline passengers from 1949 to 1960. You can download the dataset from this link.

### Setting up the environment

To get started, we need to set up our environment. We’ll be using Python 3, so make sure you have it installed. Alternatively, you can use Google Colab and go straight to importing the libraries.

Next, install these libraries using pip:

`pip install pandas matplotlib`

Once you’ve installed the necessary libraries, you can import them into your Python script:

```
import pandas as pd
import matplotlib.pyplot as plt
```

### Loading the data

After setting up the environment, we can load the AirPassengers dataset into a pandas DataFrame using the read_csv function:

`data = pd.read_csv('airline-passengers.csv', parse_dates=['Month'], index_col='Month')`

We can then inspect the first few rows of the DataFrame using the head function:

`print(data.head())`

This will output:

### Visualizing the data

Before we apply simple exponential smoothing to the data, let’s visualize it to get a better understanding of its properties. We can use the **plot** function of pandas to create a line plot of the data:

```
plt.plot(data)
plt.xlabel('Year')
plt.ylabel('Number of Passengers')
plt.show()
```

This will produce a plot of the number of passengers over time:

We can see that the number of passengers appears to be increasing over time, with some seasonality as well.

### Performing SES

Now that we’ve loaded and visualized the data, we can perform simple exponential smoothing using the **SimpleExpSmoothing** function from the **statsmodels** library. Then, we’ll create an instance of the **SimpleExpSmoothing** class, passing in the data as an argument, and then fit the model to the data using the **fit** method:

```
from statsmodels.tsa.api import SimpleExpSmoothing
model = SimpleExpSmoothing(data)
model_fit = model.fit()
```

This will calculate the smoothing parameters and fit the model to the data.

### Making predictions

Finally, we can use the **forecast** method of the model to make predictions for future values of the time series, where the argument represents the number of periods to forecast.

```
forecast = model_fit.forecast(6)
print(forecast)
```

This will produce a forecast for the next six months:

Based on the forecast given, we can then assume that over the next six months, there will be approximately 432 airline passengers.

## Wrapping up

Exponential smoothing is a powerful method for time series forecasting that allows for accurate predictions of future values based on past observations.

It’s a simple and efficient method that can be used for a wide range of time series data.

In this post, we provided a beginner’s guide to exponential smoothing, explaining the basics of the method, its types, and how to use it for forecasting.

However, there are more advanced techniques and approaches to discover beyond the scope of this post.

If you’re interested in learning more, be sure to check out this Python time series forecasting tutorial. It’s a great resource that can help you deepen your understanding of this topic and take your forecasting skills to the next level with InfluxDB.

### About the author

This post was written by Israel Oyetunji. Israel is a frontend developer with a knack for creating engaging UI and interactive experiences. He has proven experience developing consumer-focused websites using HTML, CSS, Javascript, React JS, SASS, and relevant technologies. He loves writing about tech and creating how-to tutorials for developers.