STL decomposition simplified

Sivashankari Vaitheswaran
2 min readJun 7, 2021

This post will walk through an introductory example of STL analysis using the NASA turbofan Jet Engine dataset.

Seasonal and Trend Decomposition Using Loess (STL) is an acronym for Seasonal and Trend Decomposition Using Loess. This is a statistical method for breaking down Time Series data into three components: seasonality, trend, and residual. STL extracts smooth estimates of the three components using LOESS (locally estimated scatterplot smoothing). One of the major goals of decomposition is to evaluate seasonal impacts so that seasonally adjusted data may be created and presented. A seasonally adjusted value eliminates the seasonal influence from a measurement, making patterns more visible. The trend indicates the overall direction of the data, A random fluctuation or unanticipated change is referred to as Noise or Residual. This is something we can’t predict. It gives us deeper insights into our field of work and forecasting helps an individual in increasing the efficiency of output.

Loess regression is a method that uses local weighted regression to fit a smooth curve through points in a scatter plot. Loess curves highlight trends and cycles in data that a parametric curve could struggle to describe. The Loess regression algorithm can determine the smoothing parameter that best matches the data automatically.

In order for our model to perform properly, the data must all be on the same scale to avoid bias in the results, this process is known as Standardization. So, we ought to Standardize the data. I have standardized the NASA Turbofan Jet Engine Data Set and put it in another .csv file for simplicity. The 0th step would be to standardize the data and save it in a separate file for use in our analysis. Then, you may proceed with the following steps.

Step 1

The first step is to import all of the required libraries. We will make extensive use of libraries like Seaborn, sklearn, and matplotlib for STL analysis.

from sklearn.preprocessing import StandardScaler, MinMaxScaler
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import GridSearchCV
from sklearn.metrics import mean_squared_error
from sklearn.preprocessing import StandardScaler
from sklearn import preprocessing
import matplotlib.pyplot as plt
import seaborn as sns

Step 2

Read the downloaded .csv data and put it in a variable so you may retrieve it when necessary.

data = pd.read_csv (r'C:\Users\Siva Shankari\Downloads\archive (1)\CMaps\FD001_unit1.csv')

Step 3

Plot and visualize the chart once you have imported the STL package

from statsmodels.tsa.seasonal import STLs2=data.sensor2res = STL(s2,seasonal=13,period=12).fit()ax=res.plot()plt.show()

Output:

This figure is the STL graph obtained by using standardized data of sensor 2 using the NASA turbofan jet engine dataset.

--

--