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)
Top Articles
12 Best gig economy platforms for your side hustle | Outsource Accelerator
9+ Best Gig Economy Platforms: Ranked & Reviewed
Brett Cooper Wikifeet
Orange County's diverse vegan Mexican food movement gains momentum
Ippa 番号
Whmi.com News
Hill & Moin Top Workers Compensation Lawyer
Ecolab Mppa Charges
Bullocks Grocery Weekly Ad
Sam's Club Key Event Dates 2023 Q1
Blaire White's Transformation: Before And After Transition
Rules - LOTTOBONUS - Florida Lottery Bonus Play Drawings & Promotions
Where Is The Nearest Five Below
Offsale Roblox Items are Going Limited… What’s Next? | Rolimon's
O'reilly Auto Parts Near Me Open Now
Does Publix Have Sephora Gift Cards
How a 1928 Pact Actually Tried to Outlaw War
123Movies Evil Dead
The Blind Showtimes Near Showcase Cinemas Springdale
KINOPOLIS Bonn-Bad Godesberg – Mehr Kino geht nicht
Dive into Hearts and Adventure: Top 10 Lexi Heart Books to Experience
Elmira Star Gazette Obit
Downloadhub Downloadhub
E41.Ultipro.com
Dollar Tree Hours Saturday
Watch My Best Friend's Exorcism Online Free
Black Adam Showtimes Near Linden Boulevard Multiplex Cinemas
Dom's Westgate Pizza Photos
Pokio.io
Courtney Callaway Matthew Boynton
Theatervoorstellingen in Roosendaal, het complete aanbod.
Diminutiv: Definition, Bedeutung und Beispiele
Best Upscale Restaurants In Denver
Rainfall Map Oklahoma
Pho Outdoor Seating Near Me
Pixel Run 3D Unblocked
80 For Brady Showtimes Near Brenden Theatres Kingman 4
Exterior Ballistics Calculator
La Monja 2 Pelicula Completa Tokyvideo
Re/Max Houses For Sale
Delta Incoming Flights Msp
Fandafia
Viewfinder Mangabuddy
Meg 2: The Trench Showtimes Near Phoenix Theatres Laurel Park
Matt Laubhan Salary
Slmd Skincare Appointment
1984 Argo JM16 GTP for sale by owner - Holland, MI - craigslist
Legend Of Krystal Forums
424-385-0597 phone is mostly reported for Text Message!
Skip The Games Mil
The Eye Doctors North Topeka
Konami announces TGS 2024 lineup, schedule
Latest Posts
Article information

Author: Horacio Brakus JD

Last Updated:

Views: 6578

Rating: 4 / 5 (51 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Horacio Brakus JD

Birthday: 1999-08-21

Address: Apt. 524 43384 Minnie Prairie, South Edda, MA 62804

Phone: +5931039998219

Job: Sales Strategist

Hobby: Sculling, Kitesurfing, Orienteering, Painting, Computer programming, Creative writing, Scuba diving

Introduction: My name is Horacio Brakus JD, I am a lively, splendid, jolly, vivacious, vast, cheerful, agreeable person who loves writing and wants to share my knowledge and understanding with you.