0% found this document useful (0 votes)
16 views35 pages

TSF - Week 1 - MLSR

TSF

Uploaded by

Amit Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views35 pages

TSF - Week 1 - MLSR

TSF

Uploaded by

Amit Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 35

Time Series

Forecasting
(Time Series Analysis)
Week-1

Proprietary content. ©Great Learning. All Rights Reserved.


Unauthorized use or distribution prohibited.
DSBA Curriculum
Design

Domain
Foundations Core Courses
Applications

• Data Science • Advanced Statistics • Financial Risk


Using Python • Data Mining Analytics
• Statistical • Predictive • Marketing Retail
Methods for Modelling Analytics
Decision Making • Machine Learning
• Time Series
Forecasting
• Data Visualization
Proprietary content. ©Great Learning. All Rights Reserved.
• SQL
Unauthorized use or distribution prohibited.
LEARNING OBJECTIVE
OF THIS SESSION
• Time Series and its
components

• Decomposition of Time Series

Proprietary content. ©Great Learning. All Rights Reserved.


Unauthorized use or distribution prohibited.
TRY ANSWERING THE FOLLOWING

● If the Time Series data has


missing values, we are
allowed to drop those data
points from our analysis. –
True or False? Discuss.

● The residuals in a
decomposition of a Time
Series give us the
idiosyncratic part of the
series which is not picked up
by the Trend and Seasonality.
Proprietary content. ©Great Learning. All Rights Reserved.
Unauthorized use or distribution prohibited.
What is Time Series?
• A time series is a sequence of measurements on the same variable collected
over time

• Time series is a technique for forecasting


(You use past data/observations to predict the future)

• Example :
• Daily stock price of a company
• Weekly cash withdrawal from your nearest ATM
• Monthly sales volume
• Annual GDP for a country

Proprietary content. ©Great Learning. All Rights Reserved. Una


uthorized use or distribution prohibited.
Why Forecast?
• Every organization faces internal and external risks, such as high competition, failure of technology, labor
unrest, inflation, recession, and change in government laws.

• Forecast is necessary to lessen the adverse effects of risks

Benefits of Forecasting
• It helps in setting business targets/goals
• Understand the past behavior
• Plan for the future
• Evaluate the current accomplishment

Proprietary content. ©Great Learning. All Rights Reserved. Una


uthorized use or distribution prohibited.
Why do you need another technique for
forecasting?
• Because not all data are the same, or similar. Because different types of data possess different
features, different methods of forecast becomes applicable

Independent variable
Dependent
variable Month Sales
Price Promotion Adv Sales Jan 250
121 10 300 1000 Feb 300
115 12 250 2300 Mar 372
117 5 275 1900 April 179
125 10 600 1400 May 185
127 15 479 1300 June 194
135 25 450 1350
July ?
127 19 410 ?

Prediction Prediction
One Dependent variable – Sales
Sales = 23 -0.42 Price+ 0.16Promotion+0.03 Adv
Proprietary content. ©Great Learning. All Rights Reserved. Una
uthorized use or distribution prohibited.
What are the features of Time-Series
• Data are not independent
• Data should be equally spaced, that is, data should be available at regular
intervals
• Ordering is very important because there is dependency and changing the
order will change the meaning of the data

Month Sales Period Sales Month Sales


Jan 250 Jan 250 Jan 250
Feb 300 Feb 300 May 185
Mar 372 Feb 300
2016 372
April 179
2017 179 April 179
May 185
Q3 185 Mar 372
June 194
Q1 194 June 194
July ?

Proprietary content. ©Great Learning. All Rights Reserved. Una


uthorized use or distribution prohibited.
What is NOT a Time Series
• Data collected on multiple items at the same point of time is not a
time series!
Example: NSE average on a single day

• When time periods are not the same: For example in a single time
series both yearly and quarterly data cannot be mixed

Proprietary content. ©Great Learning. All Rights Reserved. Una


uthorized use or distribution prohibited.
Steps in Forecasting
• Problem definition
Before a forecasting problem is taken up, decision needs to be made regarding the forecast horizon -
Period/Tenure/Range to forecast
a) Long term (5-10 yrs.)
b) Mid-term (1-5 yrs.)
c) Short-term (2 weeks –for few months)

• Gathering information
a) Understanding historical pattern of data
b) Using past knowledge forecasting for future
If volume of data is limited, forecasts will not be reliable enough
If data is available for very long past, data may not be useful at all

Proprietary content. ©Great Learning. All Rights Reserved. Una


uthorized use or distribution prohibited.
Steps in forecasting contd…
Do we need 35 years for data to predict for next one year?

Series not stable

V
o
L

Series stable

Proprietary content. ©Great Learning. All Rights Reserved. Una


Years
uthorized use or distribution prohibited.
Steps in forecasting contd1…
• Exploratory Data Analysis(EDA)
Plotting the time series, decomposition, treating missing values, understanding the pattern, unusual
observations etc
• Selecting and using the model
One needs to prepare the data and use algorithms Like Holt winters, ARIMA etc to make prediction
• Evaluating the model
Checking the accuracy of the prediction and reducing the errors

Proprietary content. ©Great Learning. All Rights Reserved. Una


uthorized use or distribution prohibited.
Poll Time

Proprietary content. ©Great Learning. All Rights Reserved. Una


uthorized use or distribution prohibited.
Components of Time Series
• Based on the pattern of the data, time series has been split into 3
components
1) Trend
2) Seasonality
3) Irregular component

Proprietary content. ©Great Learning. All Rights Reserved. Una


uthorized use or distribution prohibited.
Time Series and its 3 Components
An ordered sequence of values of a variable at equally spaced time intervals. Various
examples of time series are as follows:

trend

seasonality

residual

Proprietary content. ©Great Learning. All Rights Reserved.


Unauthorized use or distribution prohibited.
Trend
• Long term movement of a series: either increasing or decreasing

Upward Trend
Downward Trend
Proprietary content. ©Great Learning. All Rights Reserved. Una
uthorized use or distribution prohibited.
Seasonality
• Representing intra-year stable fluctuations repeatable year after
year with respect to timing, direction and magnitude

Proprietary content. ©Great Learning. All Rights Reserved. Una


uthorized use or distribution prohibited.
Characteristics of Time Series
• Trend : Positive or Negative
• Seasonality: patterns within a year
• Outliers : Does it have extreme values
• Long run cycle: Did you notice something happened over a period of
time
• Abrupt change : Have you noticed a sudden change

Proprietary content. ©Great Learning. All Rights Reserved. Una


uthorized use or distribution prohibited.
Example 1:

Trend : Initial years Outliers : No Long run cycle: from 1974 to 1980

Seasonality: No Abrupt change : Yes


Proprietary content. ©Great Learning. All Rights Reserved. Una
uthorized use or distribution prohibited.
Example 2

Trend : Upward Outliers : No Long run cycle: No

Seasonality: Yes Abrupt change : No

Proprietary content. ©Great Learning. All Rights Reserved. Una


uthorized use or distribution prohibited.
Example 3

Trend : Yes -increasing Outliers : No Long run cycle: Yes

Seasonality: Yes Abrupt change : No


Proprietary content. ©Great Learning. All Rights Reserved. Una
uthorized use or distribution prohibited.
Example 4

Trend : Yes at beginning Outliers : Yes Long run cycle: Yes

Seasonality: Yes Abrupt change : Yes

Proprietary content. ©Great Learning. All Rights Reserved. Una


uthorized use or distribution prohibited.
Decomposition
• Visualization of plots helps in understanding pattern but does not help in quantification
• Decomposition helps in comparing the long-term movement of the series (Trend) vis-
a-vis short-term movement (seasonality) to understand which has the higher influence
• Yt : time series value (actual data) at period t.
• St : seasonal component (index) at period t.
• Tt : trend cycle component at period t.
• It : irregular (remainder) component at period t

Proprietary content. ©Great Learning. All Rights Reserved. Una


uthorized use or distribution prohibited.
Decomposition
• Additive model:
Observation = Trend + Seasonality + Error
Yt = Tt + St + It
Useful when the seasonal variation is relatively constant over time
Multiplicative model:
Observation = Trend * Seasonality * Error
Yt = Tt * St * It
Multiplicative models are more realistic. Here seasonal variation is NOT constant

Proprietary content. ©Great Learning. All Rights Reserved. Una


uthorized use or distribution prohibited.
Example 1
Multiplicative decomposition Additive decomposition

Multiplicative - Random & Constant Additive –It shows a pattern


Proprietary content. ©Great Learning. All Rights Reserved. Una
uthorized use or distribution prohibited.
Example 2
Multiplicative decomposition Additive decomposition

Proprietary content. ©Great Learning. All Rights Reserved. Una


uthorized use or distribution prohibited.
Time Series Decomposition
• Decomposition procedures are
used in time series to describe
the trend and seasonal factors in Additive(Xt): Multiplicative(Xt):
a time series. = Trend + Seasonal + = Trend * Seasonal *
• One of the main objectives for Random Random
decomposition is to estimate
seasonal effects that can be used
to create and present seasonally
adjusted values.
• A seasonally adjusted value
removes the seasonal effect from
a value so that trends can be
seen more clearly.

• The additive model is useful


when the seasonal variation is
relatively constant over time.

• The multiplicative model is useful


Proprietary content. ©Great Learning. All Rights Reserved.
Unauthorized use or distribution prohibited.
when the seasonal variation
Residuals or Errors or White Noise
• Irregular fluctuations due to random or unforeseen circumstances /events for a short duration
e.g. pandemic, flood, earthquake etc. It is also known as White noise or error

• It is a random component and does not help in prediction

• It’s a part of the series that can’t be explained through systematic components , that is, trend
or seasonality

• It is assumed to have a normal distribution

Proprietary content. ©Great Learning. All Rights Reserved. Una


uthorized use or distribution prohibited.
Poll Time

Proprietary content. ©Great Learning. All Rights Reserved. Una


uthorized use or distribution prohibited.
Missing values
• Backward Fill (Next Observation Carried Backward)
• Forward Fill (Last Observation Carried Forward)
• Interpolation – Linear
• Interpolation – Spline

Proprietary content. ©Great Learning. All Rights Reserved. Una


uthorized use or distribution prohibited.
Industry Application – Time Series
Decomposition
• Energy demand forecasting: Time series decomposition can be
used to forecast energy demand by separating the trend and
seasonal patterns in historical energy consumption data from the
random noise.

• Financial analysis: Time series decomposition can be used to


analyze financial data, such as stock prices, by separating the trend
and seasonal patterns from the random noise.

• Climate analysis: Time series decomposition can be used to


analyze climate data, such as temperature and precipitation, by
separating the long-term trends and seasonal patterns from the
random noise.

• Epidemiology: Time series decomposition can be used to analyze


epidemiological data, such as the spread of diseases, by separating
the long-term trends and seasonal patterns from the random noise.
Proprietary content. ©Great Learning. All Rights Reserved.
Unauthorized use or distribution prohibited.
Case Study - Analysing Beer
Production in Australia

“Prediction is difficult, especially about the future.”

Keeping the above statement in mind, we will analyze the data and try to
understand the production of Beer across various years in Australia. We
will use descriptive statistics measures to do so. We will also do a plot of
the Time Series, decompose the Time Series data and try to understand
how beer production has changed over the past years.

Proprietary content. ©Great Learning. All Rights Reserved.


Unauthorized use or distribution prohibited.
ANY
QUESTIONS
Proprietary content. ©Great Learning. All Rights Reserved.
Unauthorized use or distribution prohibited.
DATA SCIENCE @
work
Apply Data Science at your workplace to gain some instant benefits:

• Get noticed by your management with your outstanding analysis backed by data
science.

• Create an impact in your organization by taking up small projects/initiatives to solve


critical issues using data science.

• Network with members from the data science vertical of your organization and seek
opportunities to contribute in small projects.

• Share your success stories with us and the world to position yourself as a subject matter
expert in data science.
Proprietary content. ©Great Learning. All Rights Reserved.
Unauthorized use or distribution prohibited.
Proprietary content. ©Great Learning. All Rights Reserved. Una
uthorized use or distribution prohibited.

You might also like