SlideShare a Scribd company logo
Time Series Modeling and
Forecasting
Mohamed Baddar
Data scientist - Careem Networks GmbH
mbaddar2@gmail.com
https://twitter.com/mbaddar2
https://mbaddards.blogspot.com/
Contents
A gentle introduction for time series analysis and forecasting, in this session we
introduce:
1. Application for time series analysis and forecasting
2. Visual analysis of time series
3. Stationarity of time series
4. Different Time Series models
5. Time series data preprocessing
6. Building Time Series Model
7. Evaluating Models
8. Demo
9. Questions
2
1. Applications of time series analysis
● Economic/Sales forecasting
● Stock market analysis
● User Behavior analysis
● Process and quality control
● Inventory Studies
● Weather Forecasting
● Workload projections
● Census Analysis
3
References:
http://www.itl.nist.gov/div898/handbook/pmc/section4/pmc41.htm
The Main idea behind time series analysis step:
Systematically Isolating each “assumed” component of the time series and identify
it as a “reproducible pattern” till the remainder becomes unexplainable white noise
4
2. Visual Analysis
Human eye and brain are one of the most complex analysis tools
What quick answers can we get from visual analysis
● Is there any abnormal values (outliers)
● Any detectable trend, seasonality
● For cross time series analysis (are the two serieses behaving in the same
way)
5
4. Stationarity of a Time Series
● Strict stationarity
○ Joint distribution of (Y_t, Y_t+1, … Y_t+n) is the same as (Y_t+k,Y_t+1+k, … Y_t+n+k)
Where 0<=t,n,k<=N , t+n+k<=N
○ In other words , the joint distribution of a n-window of the data doesn’t change as the window
moves over the series
○ Practically , hard to estimate the complete joint distribution of the moving n-windows, so
practically we use mean and variance
● Weak stationarity
○ u and sigma are the same for the window n at different K’s (formula to add)
○ Our next objective is to “Stationarize the time series”
■ Making mean stable over time
■ Making variance stable over time
6
5. Different Time Series Models
● Error , Trend , Seasonality Model
○ Y = F(E,T,S)
○ Different combinations
○ Additive : Y = T+S+E
○ Multiplicative Y = T.S.E
● ARIMA model
○ Main signal modeled as Autoregressive Moving average integrated model
■ AR :
■ MA :
■ I
7
Time Series Data Transformation
● Make series stationary (as possible)
● Log transformation
○ Y_t = B0*u_t*S_t
○ Log(Y_t) = Log(B0)+log(u_t)+log(S_t)
○ Log makes variance stable (independent from mean value or trend)
● Box-cox transformation
8
Moving average
● Help reduce outliers effect and transient fluctuations
9
Differencing
● For discrete data is the same as differentiation for continuous data
● Idea is to remove nth order trend with nth order differencing
● Practically applying differencing 2 times is sufficient to stationarize the time
series
10
Seasonality adjustment
● Trend Seasonal Error (ETS) model
○ Estimate seasonal index for each period (month of year)
○ De-seasonalize by either subtracting or dividing by seasonal index
11
Holt-Winters seasonal method
● Model trend and seasonality using exponential smoothing
● Three main components:
○ Level
○ Trend
○ Seasonal
12
13
Holt Winter modeling and forecast example (R Air-Passengers Data)
Fitted Model Sample forecast Predictes vs test
Holt Winter modeling and forecast example (AirPassengers Data)
● Default parameters used
● Forecast for future 12 months
● Test data = 1 year (should be >= on period)
● RMSE used to test performance
● RMSE to naive forecast (simple random walk) can be used as a benchmark
● More details in the notebook
14
General Approach for time series modeling and forecasting
1. Plotting
2. Check stationarity
3. Data Transformations
4. Seasonal , trend decomposition
5. AR and MA model checking
6. Residual checking
7. Building time series model
a. Separate data into train and test
b. Build model and forecast based on train data
c. Apply performance measures on test data
8. Grid search and rolling origin usually used to get the best model
15
Ad

More Related Content

What's hot (20)

Time series, forecasting, and index numbers
Time series, forecasting, and index numbersTime series, forecasting, and index numbers
Time series, forecasting, and index numbers
Shakeel Nouman
 
Time series Forecasting
Time series ForecastingTime series Forecasting
Time series Forecasting
Roma Agrawal Sit
 
Lesson 2 stationary_time_series
Lesson 2 stationary_time_seriesLesson 2 stationary_time_series
Lesson 2 stationary_time_series
ankit_ppt
 
Trend adjusted exponential smoothing forecasting metho ds
Trend adjusted exponential smoothing forecasting metho dsTrend adjusted exponential smoothing forecasting metho ds
Trend adjusted exponential smoothing forecasting metho ds
Kiran Hanjar
 
1634 time series and trend analysis
1634 time series and trend analysis1634 time series and trend analysis
1634 time series and trend analysis
Dr Fereidoun Dejahang
 
Winters Method
Winters MethodWinters Method
Winters Method
3abooodi
 
Time Series, Moving Average
Time Series, Moving AverageTime Series, Moving Average
Time Series, Moving Average
SOMASUNDARAM T
 
Time Series Analysis - Modeling and Forecasting
Time Series Analysis - Modeling and ForecastingTime Series Analysis - Modeling and Forecasting
Time Series Analysis - Modeling and Forecasting
Maruthi Nataraj K
 
Exponential Weighting Moving Average.
 Exponential Weighting Moving Average. Exponential Weighting Moving Average.
Exponential Weighting Moving Average.
Syed Waqar Hussain Shah
 
Machine Learning - Time Series Part 2
Machine Learning - Time Series Part 2Machine Learning - Time Series Part 2
Machine Learning - Time Series Part 2
Rupak Roy
 
Machine Learning - Time Series
Machine Learning - Time Series Machine Learning - Time Series
Machine Learning - Time Series
Rupak Roy
 
2b. forecasting linear trend
2b. forecasting   linear trend2b. forecasting   linear trend
2b. forecasting linear trend
Sudipta Saha
 
Time series Analysis
Time series AnalysisTime series Analysis
Time series Analysis
Habibullah Bahar University College
 
Chapter 18 Part I
Chapter 18 Part IChapter 18 Part I
Chapter 18 Part I
Matthew L Levy
 
Trend analysis - Lecture Notes
Trend analysis - Lecture NotesTrend analysis - Lecture Notes
Trend analysis - Lecture Notes
Dr. Nirav Vyas
 
Dr. Syed Muhammad Ali Tirmizi - Special topics in finance lec 5
Dr. Syed Muhammad Ali Tirmizi - Special topics in finance   lec 5Dr. Syed Muhammad Ali Tirmizi - Special topics in finance   lec 5
Dr. Syed Muhammad Ali Tirmizi - Special topics in finance lec 5
Dr. Muhammad Ali Tirmizi., Ph.D.
 
Mba 532 2011_part_3_time_series_analysis
Mba 532 2011_part_3_time_series_analysisMba 532 2011_part_3_time_series_analysis
Mba 532 2011_part_3_time_series_analysis
Chandra Kodituwakku
 
Deseasonalizing Forecasts
Deseasonalizing ForecastsDeseasonalizing Forecasts
Deseasonalizing Forecasts
ahmad bassiouny
 
Time Series Analysis - 1 | Time Series in R | Time Series Forecasting | Data ...
Time Series Analysis - 1 | Time Series in R | Time Series Forecasting | Data ...Time Series Analysis - 1 | Time Series in R | Time Series Forecasting | Data ...
Time Series Analysis - 1 | Time Series in R | Time Series Forecasting | Data ...
Simplilearn
 
Time Series
Time SeriesTime Series
Time Series
yush313
 
Time series, forecasting, and index numbers
Time series, forecasting, and index numbersTime series, forecasting, and index numbers
Time series, forecasting, and index numbers
Shakeel Nouman
 
Lesson 2 stationary_time_series
Lesson 2 stationary_time_seriesLesson 2 stationary_time_series
Lesson 2 stationary_time_series
ankit_ppt
 
Trend adjusted exponential smoothing forecasting metho ds
Trend adjusted exponential smoothing forecasting metho dsTrend adjusted exponential smoothing forecasting metho ds
Trend adjusted exponential smoothing forecasting metho ds
Kiran Hanjar
 
Winters Method
Winters MethodWinters Method
Winters Method
3abooodi
 
Time Series, Moving Average
Time Series, Moving AverageTime Series, Moving Average
Time Series, Moving Average
SOMASUNDARAM T
 
Time Series Analysis - Modeling and Forecasting
Time Series Analysis - Modeling and ForecastingTime Series Analysis - Modeling and Forecasting
Time Series Analysis - Modeling and Forecasting
Maruthi Nataraj K
 
Machine Learning - Time Series Part 2
Machine Learning - Time Series Part 2Machine Learning - Time Series Part 2
Machine Learning - Time Series Part 2
Rupak Roy
 
Machine Learning - Time Series
Machine Learning - Time Series Machine Learning - Time Series
Machine Learning - Time Series
Rupak Roy
 
2b. forecasting linear trend
2b. forecasting   linear trend2b. forecasting   linear trend
2b. forecasting linear trend
Sudipta Saha
 
Trend analysis - Lecture Notes
Trend analysis - Lecture NotesTrend analysis - Lecture Notes
Trend analysis - Lecture Notes
Dr. Nirav Vyas
 
Dr. Syed Muhammad Ali Tirmizi - Special topics in finance lec 5
Dr. Syed Muhammad Ali Tirmizi - Special topics in finance   lec 5Dr. Syed Muhammad Ali Tirmizi - Special topics in finance   lec 5
Dr. Syed Muhammad Ali Tirmizi - Special topics in finance lec 5
Dr. Muhammad Ali Tirmizi., Ph.D.
 
Mba 532 2011_part_3_time_series_analysis
Mba 532 2011_part_3_time_series_analysisMba 532 2011_part_3_time_series_analysis
Mba 532 2011_part_3_time_series_analysis
Chandra Kodituwakku
 
Deseasonalizing Forecasts
Deseasonalizing ForecastsDeseasonalizing Forecasts
Deseasonalizing Forecasts
ahmad bassiouny
 
Time Series Analysis - 1 | Time Series in R | Time Series Forecasting | Data ...
Time Series Analysis - 1 | Time Series in R | Time Series Forecasting | Data ...Time Series Analysis - 1 | Time Series in R | Time Series Forecasting | Data ...
Time Series Analysis - 1 | Time Series in R | Time Series Forecasting | Data ...
Simplilearn
 
Time Series
Time SeriesTime Series
Time Series
yush313
 

Similar to Demand time series analysis and forecasting (20)

stock market prediction
stock market predictionstock market prediction
stock market prediction
SRIGINES
 
Descriptionsordernametypeformatvallabvarlab1location_idint8.0gNum.docx
Descriptionsordernametypeformatvallabvarlab1location_idint8.0gNum.docxDescriptionsordernametypeformatvallabvarlab1location_idint8.0gNum.docx
Descriptionsordernametypeformatvallabvarlab1location_idint8.0gNum.docx
carolinef5
 
Descriptionsordernametypeformatvallabvarlab1location_idint8.0gNum.docx
Descriptionsordernametypeformatvallabvarlab1location_idint8.0gNum.docxDescriptionsordernametypeformatvallabvarlab1location_idint8.0gNum.docx
Descriptionsordernametypeformatvallabvarlab1location_idint8.0gNum.docx
donaldp2
 
Descriptionsordernametypeformatvallabvarlab1location_idint8.0gNum.docx
Descriptionsordernametypeformatvallabvarlab1location_idint8.0gNum.docxDescriptionsordernametypeformatvallabvarlab1location_idint8.0gNum.docx
Descriptionsordernametypeformatvallabvarlab1location_idint8.0gNum.docx
cuddietheresa
 
Time series
Time seriesTime series
Time series
Haitham Ahmed
 
Stationarity and Seasonality in Univariate Time Series.pdf
Stationarity and Seasonality in Univariate Time Series.pdfStationarity and Seasonality in Univariate Time Series.pdf
Stationarity and Seasonality in Univariate Time Series.pdf
charlessmithshd
 
IRJET- Analysis of Crucial Oil Gas and Liquid Sensor Statistics and Productio...
IRJET- Analysis of Crucial Oil Gas and Liquid Sensor Statistics and Productio...IRJET- Analysis of Crucial Oil Gas and Liquid Sensor Statistics and Productio...
IRJET- Analysis of Crucial Oil Gas and Liquid Sensor Statistics and Productio...
IRJET Journal
 
Machine learning Investigative Reporting NorthBaySolutions.pdf
Machine learning Investigative Reporting NorthBaySolutions.pdfMachine learning Investigative Reporting NorthBaySolutions.pdf
Machine learning Investigative Reporting NorthBaySolutions.pdf
ssusera5352a2
 
Seasonal Decomposition of Time Series Data
Seasonal Decomposition of Time Series DataSeasonal Decomposition of Time Series Data
Seasonal Decomposition of Time Series Data
Programming Homework Help
 
Stock market analysis using supervised machine learning
Stock market analysis using supervised machine learningStock market analysis using supervised machine learning
Stock market analysis using supervised machine learning
Priyanshu Gandhi
 
Module 5.pptx (Data science in engineering)
Module 5.pptx (Data science in engineering)Module 5.pptx (Data science in engineering)
Module 5.pptx (Data science in engineering)
JhaJee5
 
Time Series Weather Forecasting Techniques: Literature Survey
Time Series Weather Forecasting Techniques: Literature SurveyTime Series Weather Forecasting Techniques: Literature Survey
Time Series Weather Forecasting Techniques: Literature Survey
IRJET Journal
 
Automatic Forecasting at Scale
Automatic Forecasting at ScaleAutomatic Forecasting at Scale
Automatic Forecasting at Scale
Sean Taylor
 
Predicting Stock Market Price Using Support Vector Regression
Predicting Stock Market Price Using Support Vector RegressionPredicting Stock Market Price Using Support Vector Regression
Predicting Stock Market Price Using Support Vector Regression
Chittagong Independent University
 
IC2IT 2013 Presentation
IC2IT 2013 PresentationIC2IT 2013 Presentation
IC2IT 2013 Presentation
Chittagong Independent University
 
IC2IT 2013 Presentation
IC2IT 2013 PresentationIC2IT 2013 Presentation
IC2IT 2013 Presentation
Chittagong Independent University
 
Clock report management system project report.pdf
Clock report management system project report.pdfClock report management system project report.pdf
Clock report management system project report.pdf
Kamal Acharya
 
Clock report management system project report.pdf
Clock report management system project report.pdfClock report management system project report.pdf
Clock report management system project report.pdf
Kamal Acharya
 
SFScon 2020 - Geri Skenderi - Statistical forecasting with exogenous factors
SFScon 2020 - Geri Skenderi - Statistical forecasting with exogenous factorsSFScon 2020 - Geri Skenderi - Statistical forecasting with exogenous factors
SFScon 2020 - Geri Skenderi - Statistical forecasting with exogenous factors
South Tyrol Free Software Conference
 
Planning Mode Simulator: A simulation tool for studying ALMA's scheduling be...
 Planning Mode Simulator: A simulation tool for studying ALMA's scheduling be... Planning Mode Simulator: A simulation tool for studying ALMA's scheduling be...
Planning Mode Simulator: A simulation tool for studying ALMA's scheduling be...
Arturo Hoffstadt
 
stock market prediction
stock market predictionstock market prediction
stock market prediction
SRIGINES
 
Descriptionsordernametypeformatvallabvarlab1location_idint8.0gNum.docx
Descriptionsordernametypeformatvallabvarlab1location_idint8.0gNum.docxDescriptionsordernametypeformatvallabvarlab1location_idint8.0gNum.docx
Descriptionsordernametypeformatvallabvarlab1location_idint8.0gNum.docx
carolinef5
 
Descriptionsordernametypeformatvallabvarlab1location_idint8.0gNum.docx
Descriptionsordernametypeformatvallabvarlab1location_idint8.0gNum.docxDescriptionsordernametypeformatvallabvarlab1location_idint8.0gNum.docx
Descriptionsordernametypeformatvallabvarlab1location_idint8.0gNum.docx
donaldp2
 
Descriptionsordernametypeformatvallabvarlab1location_idint8.0gNum.docx
Descriptionsordernametypeformatvallabvarlab1location_idint8.0gNum.docxDescriptionsordernametypeformatvallabvarlab1location_idint8.0gNum.docx
Descriptionsordernametypeformatvallabvarlab1location_idint8.0gNum.docx
cuddietheresa
 
Stationarity and Seasonality in Univariate Time Series.pdf
Stationarity and Seasonality in Univariate Time Series.pdfStationarity and Seasonality in Univariate Time Series.pdf
Stationarity and Seasonality in Univariate Time Series.pdf
charlessmithshd
 
IRJET- Analysis of Crucial Oil Gas and Liquid Sensor Statistics and Productio...
IRJET- Analysis of Crucial Oil Gas and Liquid Sensor Statistics and Productio...IRJET- Analysis of Crucial Oil Gas and Liquid Sensor Statistics and Productio...
IRJET- Analysis of Crucial Oil Gas and Liquid Sensor Statistics and Productio...
IRJET Journal
 
Machine learning Investigative Reporting NorthBaySolutions.pdf
Machine learning Investigative Reporting NorthBaySolutions.pdfMachine learning Investigative Reporting NorthBaySolutions.pdf
Machine learning Investigative Reporting NorthBaySolutions.pdf
ssusera5352a2
 
Stock market analysis using supervised machine learning
Stock market analysis using supervised machine learningStock market analysis using supervised machine learning
Stock market analysis using supervised machine learning
Priyanshu Gandhi
 
Module 5.pptx (Data science in engineering)
Module 5.pptx (Data science in engineering)Module 5.pptx (Data science in engineering)
Module 5.pptx (Data science in engineering)
JhaJee5
 
Time Series Weather Forecasting Techniques: Literature Survey
Time Series Weather Forecasting Techniques: Literature SurveyTime Series Weather Forecasting Techniques: Literature Survey
Time Series Weather Forecasting Techniques: Literature Survey
IRJET Journal
 
Automatic Forecasting at Scale
Automatic Forecasting at ScaleAutomatic Forecasting at Scale
Automatic Forecasting at Scale
Sean Taylor
 
Predicting Stock Market Price Using Support Vector Regression
Predicting Stock Market Price Using Support Vector RegressionPredicting Stock Market Price Using Support Vector Regression
Predicting Stock Market Price Using Support Vector Regression
Chittagong Independent University
 
Clock report management system project report.pdf
Clock report management system project report.pdfClock report management system project report.pdf
Clock report management system project report.pdf
Kamal Acharya
 
Clock report management system project report.pdf
Clock report management system project report.pdfClock report management system project report.pdf
Clock report management system project report.pdf
Kamal Acharya
 
SFScon 2020 - Geri Skenderi - Statistical forecasting with exogenous factors
SFScon 2020 - Geri Skenderi - Statistical forecasting with exogenous factorsSFScon 2020 - Geri Skenderi - Statistical forecasting with exogenous factors
SFScon 2020 - Geri Skenderi - Statistical forecasting with exogenous factors
South Tyrol Free Software Conference
 
Planning Mode Simulator: A simulation tool for studying ALMA's scheduling be...
 Planning Mode Simulator: A simulation tool for studying ALMA's scheduling be... Planning Mode Simulator: A simulation tool for studying ALMA's scheduling be...
Planning Mode Simulator: A simulation tool for studying ALMA's scheduling be...
Arturo Hoffstadt
 
Ad

Recently uploaded (20)

1. Briefing Session_SEED with Hon. Governor Assam - 27.10.pdf
1. Briefing Session_SEED with Hon. Governor Assam - 27.10.pdf1. Briefing Session_SEED with Hon. Governor Assam - 27.10.pdf
1. Briefing Session_SEED with Hon. Governor Assam - 27.10.pdf
Simran112433
 
chapter 4 Variability statistical research .pptx
chapter 4 Variability statistical research .pptxchapter 4 Variability statistical research .pptx
chapter 4 Variability statistical research .pptx
justinebandajbn
 
Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...
Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...
Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...
gmuir1066
 
Developing Security Orchestration, Automation, and Response Applications
Developing Security Orchestration, Automation, and Response ApplicationsDeveloping Security Orchestration, Automation, and Response Applications
Developing Security Orchestration, Automation, and Response Applications
VICTOR MAESTRE RAMIREZ
 
Cleaned_Lecture 6666666_Simulation_I.pdf
Cleaned_Lecture 6666666_Simulation_I.pdfCleaned_Lecture 6666666_Simulation_I.pdf
Cleaned_Lecture 6666666_Simulation_I.pdf
alcinialbob1234
 
03 Daniel 2-notes.ppt seminario escatologia
03 Daniel 2-notes.ppt seminario escatologia03 Daniel 2-notes.ppt seminario escatologia
03 Daniel 2-notes.ppt seminario escatologia
Alexander Romero Arosquipa
 
IAS-slides2-ia-aaaaaaaaaaain-business.pdf
IAS-slides2-ia-aaaaaaaaaaain-business.pdfIAS-slides2-ia-aaaaaaaaaaain-business.pdf
IAS-slides2-ia-aaaaaaaaaaain-business.pdf
mcgardenlevi9
 
VKS-Python-FIe Handling text CSV Binary.pptx
VKS-Python-FIe Handling text CSV Binary.pptxVKS-Python-FIe Handling text CSV Binary.pptx
VKS-Python-FIe Handling text CSV Binary.pptx
Vinod Srivastava
 
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptxmd-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
fatimalazaar2004
 
Stack_and_Queue_Presentation_Final (1).pptx
Stack_and_Queue_Presentation_Final (1).pptxStack_and_Queue_Presentation_Final (1).pptx
Stack_and_Queue_Presentation_Final (1).pptx
binduraniha86
 
LLM finetuning for multiple choice google bert
LLM finetuning for multiple choice google bertLLM finetuning for multiple choice google bert
LLM finetuning for multiple choice google bert
ChadapornK
 
VKS-Python Basics for Beginners and advance.pptx
VKS-Python Basics for Beginners and advance.pptxVKS-Python Basics for Beginners and advance.pptx
VKS-Python Basics for Beginners and advance.pptx
Vinod Srivastava
 
Just-In-Timeasdfffffffghhhhhhhhhhj Systems.ppt
Just-In-Timeasdfffffffghhhhhhhhhhj Systems.pptJust-In-Timeasdfffffffghhhhhhhhhhj Systems.ppt
Just-In-Timeasdfffffffghhhhhhhhhhj Systems.ppt
ssuser5f8f49
 
AI Competitor Analysis: How to Monitor and Outperform Your Competitors
AI Competitor Analysis: How to Monitor and Outperform Your CompetitorsAI Competitor Analysis: How to Monitor and Outperform Your Competitors
AI Competitor Analysis: How to Monitor and Outperform Your Competitors
Contify
 
GenAI for Quant Analytics: survey-analytics.ai
GenAI for Quant Analytics: survey-analytics.aiGenAI for Quant Analytics: survey-analytics.ai
GenAI for Quant Analytics: survey-analytics.ai
Inspirient
 
Data Analytics Overview and its applications
Data Analytics Overview and its applicationsData Analytics Overview and its applications
Data Analytics Overview and its applications
JanmejayaMishra7
 
Conic Sectionfaggavahabaayhahahahahs.pptx
Conic Sectionfaggavahabaayhahahahahs.pptxConic Sectionfaggavahabaayhahahahahs.pptx
Conic Sectionfaggavahabaayhahahahahs.pptx
taiwanesechetan
 
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnTemplate_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
cegiver630
 
C++_OOPs_DSA1_Presentation_Template.pptx
C++_OOPs_DSA1_Presentation_Template.pptxC++_OOPs_DSA1_Presentation_Template.pptx
C++_OOPs_DSA1_Presentation_Template.pptx
aquibnoor22079
 
Calories_Prediction_using_Linear_Regression.pptx
Calories_Prediction_using_Linear_Regression.pptxCalories_Prediction_using_Linear_Regression.pptx
Calories_Prediction_using_Linear_Regression.pptx
TijiLMAHESHWARI
 
1. Briefing Session_SEED with Hon. Governor Assam - 27.10.pdf
1. Briefing Session_SEED with Hon. Governor Assam - 27.10.pdf1. Briefing Session_SEED with Hon. Governor Assam - 27.10.pdf
1. Briefing Session_SEED with Hon. Governor Assam - 27.10.pdf
Simran112433
 
chapter 4 Variability statistical research .pptx
chapter 4 Variability statistical research .pptxchapter 4 Variability statistical research .pptx
chapter 4 Variability statistical research .pptx
justinebandajbn
 
Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...
Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...
Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...
gmuir1066
 
Developing Security Orchestration, Automation, and Response Applications
Developing Security Orchestration, Automation, and Response ApplicationsDeveloping Security Orchestration, Automation, and Response Applications
Developing Security Orchestration, Automation, and Response Applications
VICTOR MAESTRE RAMIREZ
 
Cleaned_Lecture 6666666_Simulation_I.pdf
Cleaned_Lecture 6666666_Simulation_I.pdfCleaned_Lecture 6666666_Simulation_I.pdf
Cleaned_Lecture 6666666_Simulation_I.pdf
alcinialbob1234
 
IAS-slides2-ia-aaaaaaaaaaain-business.pdf
IAS-slides2-ia-aaaaaaaaaaain-business.pdfIAS-slides2-ia-aaaaaaaaaaain-business.pdf
IAS-slides2-ia-aaaaaaaaaaain-business.pdf
mcgardenlevi9
 
VKS-Python-FIe Handling text CSV Binary.pptx
VKS-Python-FIe Handling text CSV Binary.pptxVKS-Python-FIe Handling text CSV Binary.pptx
VKS-Python-FIe Handling text CSV Binary.pptx
Vinod Srivastava
 
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptxmd-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
fatimalazaar2004
 
Stack_and_Queue_Presentation_Final (1).pptx
Stack_and_Queue_Presentation_Final (1).pptxStack_and_Queue_Presentation_Final (1).pptx
Stack_and_Queue_Presentation_Final (1).pptx
binduraniha86
 
LLM finetuning for multiple choice google bert
LLM finetuning for multiple choice google bertLLM finetuning for multiple choice google bert
LLM finetuning for multiple choice google bert
ChadapornK
 
VKS-Python Basics for Beginners and advance.pptx
VKS-Python Basics for Beginners and advance.pptxVKS-Python Basics for Beginners and advance.pptx
VKS-Python Basics for Beginners and advance.pptx
Vinod Srivastava
 
Just-In-Timeasdfffffffghhhhhhhhhhj Systems.ppt
Just-In-Timeasdfffffffghhhhhhhhhhj Systems.pptJust-In-Timeasdfffffffghhhhhhhhhhj Systems.ppt
Just-In-Timeasdfffffffghhhhhhhhhhj Systems.ppt
ssuser5f8f49
 
AI Competitor Analysis: How to Monitor and Outperform Your Competitors
AI Competitor Analysis: How to Monitor and Outperform Your CompetitorsAI Competitor Analysis: How to Monitor and Outperform Your Competitors
AI Competitor Analysis: How to Monitor and Outperform Your Competitors
Contify
 
GenAI for Quant Analytics: survey-analytics.ai
GenAI for Quant Analytics: survey-analytics.aiGenAI for Quant Analytics: survey-analytics.ai
GenAI for Quant Analytics: survey-analytics.ai
Inspirient
 
Data Analytics Overview and its applications
Data Analytics Overview and its applicationsData Analytics Overview and its applications
Data Analytics Overview and its applications
JanmejayaMishra7
 
Conic Sectionfaggavahabaayhahahahahs.pptx
Conic Sectionfaggavahabaayhahahahahs.pptxConic Sectionfaggavahabaayhahahahahs.pptx
Conic Sectionfaggavahabaayhahahahahs.pptx
taiwanesechetan
 
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnTemplate_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
cegiver630
 
C++_OOPs_DSA1_Presentation_Template.pptx
C++_OOPs_DSA1_Presentation_Template.pptxC++_OOPs_DSA1_Presentation_Template.pptx
C++_OOPs_DSA1_Presentation_Template.pptx
aquibnoor22079
 
Calories_Prediction_using_Linear_Regression.pptx
Calories_Prediction_using_Linear_Regression.pptxCalories_Prediction_using_Linear_Regression.pptx
Calories_Prediction_using_Linear_Regression.pptx
TijiLMAHESHWARI
 
Ad

Demand time series analysis and forecasting

  • 1. Time Series Modeling and Forecasting Mohamed Baddar Data scientist - Careem Networks GmbH [email protected] https://twitter.com/mbaddar2 https://mbaddards.blogspot.com/
  • 2. Contents A gentle introduction for time series analysis and forecasting, in this session we introduce: 1. Application for time series analysis and forecasting 2. Visual analysis of time series 3. Stationarity of time series 4. Different Time Series models 5. Time series data preprocessing 6. Building Time Series Model 7. Evaluating Models 8. Demo 9. Questions 2
  • 3. 1. Applications of time series analysis ● Economic/Sales forecasting ● Stock market analysis ● User Behavior analysis ● Process and quality control ● Inventory Studies ● Weather Forecasting ● Workload projections ● Census Analysis 3 References: http://www.itl.nist.gov/div898/handbook/pmc/section4/pmc41.htm
  • 4. The Main idea behind time series analysis step: Systematically Isolating each “assumed” component of the time series and identify it as a “reproducible pattern” till the remainder becomes unexplainable white noise 4
  • 5. 2. Visual Analysis Human eye and brain are one of the most complex analysis tools What quick answers can we get from visual analysis ● Is there any abnormal values (outliers) ● Any detectable trend, seasonality ● For cross time series analysis (are the two serieses behaving in the same way) 5
  • 6. 4. Stationarity of a Time Series ● Strict stationarity ○ Joint distribution of (Y_t, Y_t+1, … Y_t+n) is the same as (Y_t+k,Y_t+1+k, … Y_t+n+k) Where 0<=t,n,k<=N , t+n+k<=N ○ In other words , the joint distribution of a n-window of the data doesn’t change as the window moves over the series ○ Practically , hard to estimate the complete joint distribution of the moving n-windows, so practically we use mean and variance ● Weak stationarity ○ u and sigma are the same for the window n at different K’s (formula to add) ○ Our next objective is to “Stationarize the time series” ■ Making mean stable over time ■ Making variance stable over time 6
  • 7. 5. Different Time Series Models ● Error , Trend , Seasonality Model ○ Y = F(E,T,S) ○ Different combinations ○ Additive : Y = T+S+E ○ Multiplicative Y = T.S.E ● ARIMA model ○ Main signal modeled as Autoregressive Moving average integrated model ■ AR : ■ MA : ■ I 7
  • 8. Time Series Data Transformation ● Make series stationary (as possible) ● Log transformation ○ Y_t = B0*u_t*S_t ○ Log(Y_t) = Log(B0)+log(u_t)+log(S_t) ○ Log makes variance stable (independent from mean value or trend) ● Box-cox transformation 8
  • 9. Moving average ● Help reduce outliers effect and transient fluctuations 9
  • 10. Differencing ● For discrete data is the same as differentiation for continuous data ● Idea is to remove nth order trend with nth order differencing ● Practically applying differencing 2 times is sufficient to stationarize the time series 10
  • 11. Seasonality adjustment ● Trend Seasonal Error (ETS) model ○ Estimate seasonal index for each period (month of year) ○ De-seasonalize by either subtracting or dividing by seasonal index 11
  • 12. Holt-Winters seasonal method ● Model trend and seasonality using exponential smoothing ● Three main components: ○ Level ○ Trend ○ Seasonal 12
  • 13. 13 Holt Winter modeling and forecast example (R Air-Passengers Data) Fitted Model Sample forecast Predictes vs test
  • 14. Holt Winter modeling and forecast example (AirPassengers Data) ● Default parameters used ● Forecast for future 12 months ● Test data = 1 year (should be >= on period) ● RMSE used to test performance ● RMSE to naive forecast (simple random walk) can be used as a benchmark ● More details in the notebook 14
  • 15. General Approach for time series modeling and forecasting 1. Plotting 2. Check stationarity 3. Data Transformations 4. Seasonal , trend decomposition 5. AR and MA model checking 6. Residual checking 7. Building time series model a. Separate data into train and test b. Build model and forecast based on train data c. Apply performance measures on test data 8. Grid search and rolling origin usually used to get the best model 15