Member-only story

STL decomposition : How to do it from Scratch?

Figure out what STL decomposition is and how it works.

Rajat Sharma
Towards Data Science
5 min readNov 10, 2019

--

This article will help you understand what is STL decomposition and how to do it from scratch. At the end, I will use statsmodel library too, to get the results in seconds.

What is STL decomposition?

So, STL stands for Seasonal and Trend decomposition using Loess. This is a statistical method of decomposing a Time Series data into 3 components containing seasonality, trend and residual.

Now, what is a Time Series data? Well, it is a sequence of data points that varies across a continuous time axis. Below is an example of a time series data where you can see the time axis is at an hour level and value of stock varies across the time.

Now let’s talk about trend. Trend gives you a general direction of the overall data. From the above example, I can say that from 9:00am to 11:00am there is a downward trend and from 11:00am to 1:00pm there is an upward trend and after 1:00pm the trend is constant.

--

--

Towards Data Science
Towards Data Science

Published in Towards Data Science

Your home for data science and AI. The world’s leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals.

Rajat Sharma
Rajat Sharma

Written by Rajat Sharma

Student Reviewer and Mentor @ Udacity | Book my services 👉🏻 https://topmate.io/rajatsharma369007

Responses (5)