09.10.2023 Views

Advanced Data Analytics Using Python_ With Machine Learning, Deep Learning and NLP Examples ( 2023)

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 6 Time Series

Here, b1, often referred to as the permanent component, is the initial

weight of the seasonality; b2 represents the trend, which is linear in this

case.

However, there is no standard implementation of the Holt-Winters

model in Python. It is available in R (see Chapter 1 for how R’s Holt-

Winters model can be called from Python code).

Removing Seasonality from a Time Series

There are two ways of removing seasonality from a time series.

• By filtering

• By differencing

By Filtering

The series {x t } is converted into another called {y t } with the linear operation

shown here, where {a r } is a set of weights:

Y t = ∑ +s r=-qa r x t+r

To smooth out local fluctuations and estimate the local mean, you

should clearly choose the weights so that ∑ a r = 1; then the operation is

often referred to as a moving average. They are often symmetric with

s = q and a j = a -j . The simplest example of a symmetric smoothing filter is

the simple moving average, for which a r = 1 / (2q+1) for r = -q, …, + q.

The smoothed value of x t is given by the following:

1

Sm(x t ) =

2q + 1

∑+q r=-qx t+r

125

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!