## What is Seasonality in Time Series Data?

A time series data is said to be seasonal if specific patterns appear on a cyclical basis. The cycle repeating over time may signal important information in forecasting.

A cycle structure in a time series may or may not be seasonal. If it consistently repeats at the same frequency, it is seasonal, otherwise it is not seasonal and is called a cycle.- Page 6, Introductory Time Series with R

## Types of Seasonality

There can be many types of seasonality based on their repeating cycle. For example:

- Hourly
- Daily
- Weekly
- Monthly
- Quarterly
- Annually

## Why Do We Need to Detect Seasonality?

- Understanding the seasonal component can help in improving the performance of the machine learning model.

## How to Detect Seasonality?

The most popular method to detect seasonality components is **decomposing** the time series data.

### Time Series Decomposition

The time series data is decomposed into three components: **trend**, **seasonal** and **residual**.

### 1. Trend

The consistently increasing or decreasing values in a series. It is used to find trend in the time series data under consideration i.e uptrend or downtrend.

### 2. Seasonal

The repeating short-term cycle in the series. It is used to find seasonality in the data.

### 3. Residual

If the trend or seasonality component is removed from a time series data, whatever is left over is called residual.

### Naive Decomposition

In Naive Decomposition, we find the linear relationship between the three components (trend, seasonal, residual) and the observed time series. There are two main approaches to naive decomposition: **additive** and **multiplicative**.

### 1. Additive Decomposition

from random import randrange from matplotlib import pyplot from statsmodels.tsa.seasonal import seasonal_decompose series=[i+randrange(10) for i in range(1,100)] result=seasonal_decompose(series,model="additive",period=1) result.plot() pyplot.show()

observed = trend + seasonality + residual

### 2. Multiplicative Decomposition

series = [i*2 for i in range(1,100)] result= seasonal_decompose(series, model="multiplicative",period=1) result.plot() pyplot.show()

observed = trend * seasonality * residual

## How to Remove Seasonality?

The process of removing the seasonality from a time series data is called **seasonal adjustment** or **deseasonalizing**.

A time series data with removed seasonality is calledseasonal stationarydata.

One of the popular methods for seasonal adjustment is **differencing**.

### Differencing

In this method, the level of data (weekly, monthly, yearly ) is found. The current value is subtracted from the level of data. For example, if the weekly data is available, then every value is subtracted by 7.