Holt Winter's Method for Time Series Analysis (2024)

Time series analysis is a popular field of data science and machine learning that decomposes historical data to identify trends, seasonality, and noise to forecast future trends. Time series forecasting algorithms range from simple techniques like moving averages and exponential smoothing to deep learning methods like recurrent neural networks and XG Boost. Hybrid forecasting techniques that combine multiple approaches are also commonly used to improve accuracy. Independent variables, such as discount percentages or temperature, can influence predictions. The choice of algorithm depends on the data set and the business problem at hand. Time series analysis is critical for making informed decisions based on historical data.

This article was published as a part of theData Science Blogathon

Table of contents

  • What is Holt Winter’s Method?
  • Example with Code
  • Missing Values Treatment
  • Outlier Detection and Treatment
  • Limitations of Holt-Winter’s Technique
  • Final Thought
  • Frequently Asked Questions

What is Holt Winter’s Method?

Holt-Winters is a model of time series behavior. Forecasting always requires a model, and Holt-Winters is a way to model three aspects of the time series:

  • A typical value (average)
  • A slope (trend) over time
  • A cyclical repeating pattern (seasonality)

Real-world data like that of demand data in any industry generally has a lot of seasonality and trends. When forecasting demands in such cases requires models which will account for the trend and seasonality in the data as the decision made by the business is going to be based on the result of this model. For such cases, Holt winter’s method is one of the many time series prediction methods which can be used for forecasting.

Holt-Winters Triple Exponential Smoothing Formula Explained

Holt-Winter’s Exponential Smoothing as named after its two contributors: Charles Holt and Peter Winter’s is one of the oldest time series analysis techniques which takes into account the trend and seasonality while doing the forecasting. This method has 3 major aspects for performing the predictions. It has an average value with the trend and seasonality. The three aspects are 3 types of exponential smoothing and hence the hold winter’s method is also known as triple exponential smoothing.

Let us look at each of the aspects in detail.

  • Exponential Smoothing: Simple exponential smoothing as the name suggest is used for forecasting when the data set has no trends or seasonality.
  • Holt’s Smoothing method: Holt’s smoothing technique, also known as linear exponential smoothing, is a widely known smoothing model for forecasting data that has a trend.
  • Winter’s Smoothing method: Winter’s smoothing technique allows us to include seasonality while making the prediction along with the trend.

Hence the Holt winter’s method takes into account average along with trend and seasonality while making the time series prediction.

Forecast equation^yt+h|t=ℓt+hbt

Level equationℓt=αyt+(1−α)(ℓt−1+bt−1)

Trend equationbt=β∗(ℓt−ℓt−1)+(1−β∗)bt−1

Where ℓtℓt is an estimate of the level of the series at time tt,

btbt is an estimate of the trend of the series at time tt,

αα is the smoothing coefficient

Also Read: This is How Experts Predict the Future of AI

Example with Code

Let us look at Holt-Winter’s time series analysis with an example. We have the number of visitors on a certain website for few days, let us try to predict the number of visitors for the next 3 days using the Holt-Winter’s method. Below is the code in python

The first step to any model building is exploratory data analysis or EDA, lets look at the data and try to clean it before fitting a model onto it.

Missing Values Treatment

#counting the number of missing data pointsvisitors = pd.read_excel('website_visitors.xlsx',index_col='month', parse_dates=True)Visitors_df_missing = (visitors.[ 'no_of_visits']=nan).sum()Print(Visitors.head())
Holt Winter's Method for Time Series Analysis (1)
#Replace the missing values with the mean valuevisitors ['no_of_visits'].fillna(value= visitors ['no_of_visits'].mean(), inplace=True)

Outlier Detection and Treatment

import seaborn as sns sns.boxplot(x= visitors ['no_of_visits'])
Holt Winter's Method for Time Series Analysis (2)
#calculating the z score
visitors [‘z_score’] = visitors. 'no_of_visits' - visitors. 'no_of_visits'.mean())/visitors. 'no_of_visits'.std(ddof=0)
#exclude the rowl with z score more than 3visitors [(np.abs(stats.zscore(visitors [‘z_score’])) < 3)]
Holt Winter's Method for Time Series Analysis (3)
#re-sampling the data to monthly bucketsvisitors.set_index('date', inplace=True)visitors.resample('MS').sum()

Now our EDA is completed and the data set is ready for modelling

# Lets import all the required libraries
import pandas as pdfrom matplotlib import pyplot as pltfrom statsmodels.tsa.seasonal import seasonal_decomposefrom statsmodels.tsa.seasonal import seasonal_decompose from statsmodels.tsa.holtwinters import SimpleExpSmoothing from statsmodels.tsa.holtwinters import ExponentialSmoothing
# Input the visitors data using pandasvisitors = pd.read_excel('website_visitors.xlsx',index_col='month', parse_dates=True)print(visitors.shape)print(visitors.head()) # print the data framevisitors[['no_of_visits']].plot(title='visitors Data')
Holt Winter's Method for Time Series Analysis (4)
Holt Winter's Method for Time Series Analysis (5)
visitors.sort_index(inplace=True) # sort the data as per the index
# Decompose the data frame to get the trend, seasonality and noisedecompose_result = seasonal_decompose(visitors['no_of_visits'],model='multiplicative',period=1)decompose_result.plot()plt.show()
Holt Winter's Method for Time Series Analysis (6)
# Set the value of Alpha and define x as the time periodx = 12alpha = 1/(2*x)
# Single exponential smoothing of the visitors data setvisitors['HWES1'] = SimpleExpSmoothing(visitors['no_of_visits']).fit(smoothing_level=alpha,optimized=False,use_brute=True).fittedvalues visitors[['no_of_visits','HWES1']].plot(title='Holt Winters Single Exponential Smoothing grpah')
Holt Winter's Method for Time Series Analysis (7)
# Double exponential smoothing of visitors data set ( Additive and multiplicative)
visitors['HWES2_ADD'] = ExponentialSmoothing(visitors['no_of_visits'],trend='add').fit().fittedvaluesvisitors['HWES2_MUL'] = ExponentialSmoothing(visitors['no_of_visits'],trend='mul').fit().fittedvaluesvisitors[['no_of_visits','HWES2_ADD','HWES2_MUL']].plot(title='Holt Winters grapg: Additive Trend and Multiplicative Trend')
# Split into train and test settrain_visitors = visitors[:9]test_visitors = visitors[9:]
# Fit the modelfitted_model = ExponentialSmoothing(train_visitors['no_of_visits'],trend='mul',seasonal='mul',seasonal_periods=2).fit()test_predictions = fitted_model.forecast(5)train_visitors['no_of_visits'].plot(legend=True,label='TRAIN')test_visitors['no_of_visits'].plot(legend=True,label='TEST',figsize=(6,4))test_predictions.plot(legend=True,label='PREDICTION')plt.title('Train, Test and Predicted data points using Holt Winters Exponential Smoothing')
Holt Winter's Method for Time Series Analysis (8)

Basically, there are 2 models multiplicative and additive. The additive model is based on the principle that the forecasted value for each data point is the sum of the baseline values, its trend, and the seasonality components.

Similarly, the multiplicative model calculates the forecasted value for each data point as the product of the baseline values, its trend, and the seasonality components.

Limitations of Holt-Winter’s Technique

In spite of giving the best forecasting result the Holt-Winter’s method still has certain shortcomings. One major limitation of this algorithm is the multiplicative feature of the seasonality. The issue of multiplicative seasonality is how the model performs when we have time frames with very low amounts. A time frame with a data point of 10 or 1 might have an actual difference of 9 but there is a relative difference of about 1000%, so the seasonality, which is expressed as a relative term could change drastically and should be taken care of of of when building the model.

Final Thought

Holt winter’s algorithm has wide areas of application. It is used in various business problems mainly because of two reasons one of which is its simple implementation approach and the other one is that the model will evolve as our business requirements change.

Holt Winter’s time series model is a very powerful prediction algorithm despite being one of the simplest models. It can handle the seasonality in the data set by just calculating the central value and then adding or multiplying it to the slope and seasonality, We just have to make sure to tune in the right set of parameters, and viola, we have the best fitting model. Always remember to check the efficiency of the model using the MAPE (mean absolute percentage error) value or the RMSE(Root mean squared error) value, and the accuracy may depend on the business problem and the data set available to train and test the model.

The media shown in this article are not owned by Analytics Vidhya and are used at the Author’s discretion.

Frequently Asked Questions

Q1. What is the Holt-Winters algorithm?

A. The Holt-Winters algorithm is a time-series forecasting method that uses exponential smoothing to make predictions based on past observations. The method considers three components of a time series: level, trend, and seasonality, and uses them to make forecasts for future periods.

Q2. Why is Holt-Winters method used?

A. The Holt-Winters method is used for time-series forecasting because it can capture trends and seasonality in the data, making it particularly useful for predicting future values of a time series that exhibit these patterns. The method is also relatively simple and can produce accurate forecasts.

Q3. What are the three parameters of Holt-Winters?

A. The three parameters of the Holt-Winters method are alpha, beta, and gamma. Alpha represents the level smoothing factor, beta represents the trend smoothing factor, and gamma represents the seasonality smoothing factor. These parameters are given to past observations when making predictions for future time periods.

Q4. What is Holt-Winters filtering?

A. Holt-Winters filtering is a method of smoothing a time series using the Holt-Winters algorithm. The method involves taking a weighted average of past observations to produce a smoothed value for each time period in the series. The alpha, beta, and gamma smoothing factors determine the weights assigned to each observation. This smoothing process can remove noise and highlight trends and seasonality in the data, making it easier to make predictions and identify patterns in the time series.

blogathonHolt Winter's MethodTime Series Analysis

S

Snehal_bm26 Apr, 2023

AlgorithmIntermediatePythonStructured DataSupervised

Holt Winter's Method for Time Series Analysis (2024)

FAQs

Holt Winter's Method for Time Series Analysis? ›

The Holt-Winters method uses exponential smoothing to encode lots of values from the past and use them to predict “typical” values for the present and future. Exponential smoothing refers to the use of an exponentially weighted moving average (EWMA) to “smooth” a time series.

What is Holt-Winters method of time series analysis? ›

Holt-Winters time series model can either be of additive or multiplicative seasonality. With additive model, the behavior is linear where changes over time are consistently made by the same amount, like a linear trend. In this situation, the linear seasonality has the same amplitude and frequency.

What is the formula for Holt's winter method? ›

Holt-Winters' multiplicative method

The component form for the multiplicative method is: ^yt+h|t=(ℓt+hbt)st+h−m(k+1)ℓt=αytst−m+(1−α)(ℓt−1+bt−1)bt=β∗(ℓt−ℓt−1)+(1−β∗)bt−1st=γyt(ℓt−1+bt−1)+(1−γ)st−m.

What is the winter's method of forecasting? ›

Winter's method assumes that the time series has a level, trend and seasonal component. A forecast with Winter's exponential smoothing can be expressed as: The forecast equation is the extenuation of both the SES and HES methods, finally augmented with the inclusion of the Seasonal, S, component.

What is the Holts and Winters model? ›

Holt's Smoothing method: Holt's smoothing technique, also known as linear exponential smoothing, is a widely known smoothing model for forecasting data that has a trend. Winter's Smoothing method: Winter's smoothing technique allows us to include seasonality while making the prediction along with the trend.

What is the difference between Arima and Holt-winters? ›

The study found that both of the studied models (Holt-Winters and ARIMA) performed well in predicting rice price values. However, in the model comparison, although by very little difference, the Holt-Winters additive model was closer to the actual data.

Why use Holt's method? ›

Holt's Linear Trend Method

Expanding the SES method, the Holt method helps you forecast time series data that has a trend. In addition to the level smoothing parameter α introduced with the SES method, the Holt method adds the trend smoothing parameter β*. Like with parameter α, the range of β* is also between 0 and 1.

What is the best forecasting method and why? ›

1. Straight-line Method. The straight-line method is one of the simplest and easy-to-follow forecasting methods. A financial analyst uses historical figures and trends to predict future revenue growth.

What is the simplified winter formula? ›

Winter's Formula

This is used to give an expected value for the patient's PCO2, which helps to assess whether or not the patient is adequately compensating for their acidotic state. Winter's formula yields the expected PCO2 = (HCO3 x 1.5) + 8 ± 2.

What is the winter's formula for? ›

Compensation: in a maximally-compensated metabolic acidosis (which takes about 12-24 hours), Winter's formula applies: Expected PaCO2 = (1.5 x serum HCO3)+(8±2); a shortcut to this formula is that the Expected PaCO2 is approximately equal to the last two digits of the pH ± 2.

What is the formula for seasonality in time series? ›

In an additive time-series model, the seasonal component is estimated as: S = Y – (T + C + I )

What is the Winter's method in Minitab? ›

Winters' Method calculates dynamic estimates for three components: level, trend, and seasonal. For example, a budget planner for a local business office uses a Winters' method analysis to predict water and electricity costs for the next three periods.

What are the time series forecasting methods? ›

Time series models are used to forecast events based on verified historical data. Common types include ARIMA, smooth-based, and moving average.

What is the formula for Holt-Winters method? ›

Holt-Winters' additive method

The equation for the seasonal component is often expressed as st=γ∗(yt−ℓt)+(1−γ∗)st−m.

What are the advantages of Holt-Winters model? ›

The Holt-Winters method offers several advantages for inventory forecasting. It's simple and intuitive, requiring just three parameters and a straightforward formula. Its flexibility allows it to handle various types of seasonality and adapt to data changes.

What is Holt-Winters additive model? ›

Is an extension of Holt's exponential smoothing that captures seasonality. This method produces exponentially smoothed values for the level of the forecast, the trend of the forecast, and the seasonal adjustment to the forecast.

What is the Holt methodology? ›

HOLT's proprietary methodology corrects subjectivity by converting income statement and balance sheet information into the company's internal rate of return (CFROI), a measure that more closely approximates a company's underlying economics.

What is the method of time series analysis? ›

Time series analysis is a specific way of analyzing a sequence of data points collected over an interval of time. In time series analysis, analysts record data points at consistent intervals over a set period of time rather than just recording the data points intermittently or randomly.

What is Holt Winters additive model? ›

Is an extension of Holt's exponential smoothing that captures seasonality. This method produces exponentially smoothed values for the level of the forecast, the trend of the forecast, and the seasonal adjustment to the forecast.

What is the seasonal naive method of time series? ›

Seasonal Naive Method

This method of forecasting is a variation of Naive method. Here, we assume the magnitude of seasonal patterns will remain constant. The future values are set to be equal to the last observed value from the same season. This method is used for highly seasonal time series data.

Top Articles
Latest Posts
Article information

Author: Lidia Grady

Last Updated:

Views: 6152

Rating: 4.4 / 5 (45 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Lidia Grady

Birthday: 1992-01-22

Address: Suite 493 356 Dale Fall, New Wanda, RI 52485

Phone: +29914464387516

Job: Customer Engineer

Hobby: Cryptography, Writing, Dowsing, Stand-up comedy, Calligraphy, Web surfing, Ghost hunting

Introduction: My name is Lidia Grady, I am a thankful, fine, glamorous, lucky, lively, pleasant, shiny person who loves writing and wants to share my knowledge and understanding with you.