Pa - PPT Unit 4
Pa - PPT Unit 4
PREDICTIVE ANALYTICS
Unit: 4
Forecasting models
Mr. Sovers Singh Bisht
Assistant Professor
B-Tech 5TH Sem DS-DEPT
ONLINE & Offline (Sec A, B) NIET
12/21/2024 2
THE CONCEPT LEARNING
Evaluation Scheme TASK
PROGRAM ELECTIVES BUCKET
DS
Mobility CRM-RPA
Full Stack
Management
Data Analytics Development
Python Web Mobile Application CRM Fundamentals
Development with Development
Program Django
Elective 1 Predictive Analytics
Program Design Patterns Development in Swift CRM Administration
Elective 2 Web Technologies Fundamentals
Advanced Java Development in Swift CRM Development
Programming Explorations and Data
Program Programming for Collections
Elective 3 Data Analytics
Web Development Augmented Reality and Robotics Process
Program Social Media using MEAN Stack Virtual Reality Automation (RPA)
Elective 4 Analytics
Web Development Game Programming Robotics Process
using MERN Stack Automation (RPA)
Program Natural language Implementation
Elective 5 Processing
PREDICTIVE ANALYTICS
LTP Credits
3–0–0 3
PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12
CO1 2 2 1 2 1 0 0 0 0 0 0 2
CO2 2 2 3 2 1 0 0 0 0 0 0 1
CO3 2 1 2 1 2 0 0 0 0 0 0 1
CO4 2 2 1 2 2 0 0 0 0 0 0 2
CO5 3 2 2 2 2 0 0 0 0 0 0 2
Average 2.2 1.8 1.8 1.8 1.6 0 0 0 0 0 0 1.6
PSO’s
At the end of the program, the student will be able to-
PEO’s
The graduates of B.Tech Data Science program will-
SECTION – B CO
Prerequisites:
• Linux/ Windows operating system.
Recap:
• Discussion about Data Science Environments.
For instance, data mining involves the analysis of large sets of data to detect patterns
from it. Text analysis does the same, except for large blocks of text.
Weather forecasts
Creating video games
Translating voice to text for mobile phone messaging
Customer service
Investment portfolio development
https://www.youtube.com/watch?v=4y6fUC56KPw
https://www.youtube.com/watch?v=JOArz7wggkQ
12/21/2024 Dr. Priyanka Chandani UNIT 01 21
CONTENT
CONTENTS
Forecasting models:
Trend analysis
Cyclical and Seasonal analysis smoothing
Moving averages
Box-Jenkins
Holt-winters
Autocorrelation
ARIMA
Examples: Applications of Time Series in financial markets.
Objective:
In this topic we learn about Trend analysis that will allows you to
predict what's going to happen, based on what's already happened.
It provides businesses with information regarding marketing and
sales performance, product development, spending, and more.
Enabling businesses to make data-driven decisions with regard to
future events.
Recap:
• Forecasting models
• What is a forecasting model?
• Forecasting models are one of the many tools businesses use to predict
outcomes regarding sales, supply and demand, consumer behavior and
more. These models are especially beneficial in the field of sales and
marketing. There are several forecasting methods businesses use that
provide varying degrees of information. From the simple to the complex,
the appeal of using forecasting models comes from having a visual
reference of expected outcomes.
• Four common types of forecasting models
• While there are numerous ways to forecast business outcomes, there are
four main types of models or methods that companies use to predict
actions in the future. You'll have a better understanding of how
companies use these methods to enhance their business practices and
improve the customer experience with the following examples of
common forecasting models:
12/21/2024 SOVERS SINGH BISHT UNIT 01 25
THE CONCEPT LEARNING TASK
Trend analysis
1. Have your time-based data available for use (time series and values series).
2. Input the compiled data involving time or duration in the first column.
3. Insert remaining values you want to forecast in the next column.
4. Select relevant data
5. Click the Data tab, then select Forecast Group, then choose Forecast Sheet.
6. Access the sheet, then select the line or bar graph option you want to use.
7. In the Forecast End box, determine your end date and hit Create.
• Once you've set up your forecasting model, you will then move onto interpreting it to
formulate your best estimation of the future.
Econometric model
• Those employed in the field of economics often use an econometric model to forecast
changes in supply and demand, as well as prices. These models incorporate complex data
and knowledge throughout the process of creation. Like the name infers, this type of
statistical model proves valuable when predicting future developments in the economy.
• Here is the basic structure behind this type of model:
• 1. Trend analysis
• What Is Trend Analysis?
• Trend analysis is a technique used in technical analysis that attempts to
predict future stock price movements based on recently observed trend
data. Trend analysis uses historical data, such as price movements and
trade volume, to forecast the long-term direction of market sentiment.
• KEY TAKEAWAYS
• • Trend analysis tries to predict a trend, such as a bull market run,
and then ride that trend until data suggests a trend reversal, such as a
bull-to-bear market.
• • Trend analysis is based on the idea that what has happened in the
past gives traders an idea of what will happen in the future.
• • Trend analysis focuses on three typical time horizons: short-;
intermediate-; and long-term.
• What Is a Trend?
• A trend is the overall direction of a market during a specified period of time. Trends can be
both upward and downward, relating to bullish and bearish markets, respectively. While
there is no specified minimum amount of time required for a direction to be considered a
trend, the longer the direction is maintained, the more notable the trend. Trends are
identified by drawing lines, known as trendlines, that connect price action making higher
highs and higher lows for an uptrend, or lower lows and lower highs for a downtrend.
• What Are Examples of Trend Trading Strategies?
• Trend trading strategies attempt to isolate and extract profit from trends by combining a
variety of technical indicators along with the financial instrument's price action. Typically,
these include moving averages, momentum indicators, and trendlines, and chart patterns.
• Moving averages strategies involve entering into long, or short, positions when the short-
term moving average crosses above, or below, a long-term moving average. Momentum
indicator strategies involve entering into positions when a security is exhibiting strong
momentum and exiting when that wanes. Trendlines and chart pattern strategies involve
entering long, or short, positions when a security is trending higher, or lower, and placing a
stop-loss below, or above, key trendline support levels to exit the trade.
Objective:
In this topic we learn about Structured data that is clearly defined
and searchable types of data, while unstructured data is usually
stored in its native format. Structured data is quantitative, while
unstructured data is qualitative. Structured data is often stored in
data warehouses, while unstructured data is stored in data lakes
Recap:
Revision of basic statistical approaches.
Objective:
In this topic we learn about moving average is a calculation used to
analyze data points by creating a series of averages of different
subsets of the full data set. In finance, a moving average (MA) is a
stock indicator that is commonly used in technical analysis.
Recap:
Revision of basic statistical approaches.
• 4. Moving averages
• What Is a Moving Average (MA)?
• In statistics, a moving average is a calculation used to analyze
data points by creating a series of averages of different subsets
of the full data set. In finance, a moving average (MA) is a stock
indicator that is commonly used in technical analysis. The
reason for calculating the moving average of a stock is to help
smooth out the price data by creating a constantly updated
average price.
• By calculating the moving average, the impacts of random,
short-term fluctuations on the price of a stock over a specified
time frame are mitigated.
• KEY TAKEAWAYS
• • A moving average (MA) is a stock indicator that is commonly
used in technical analysis.
• • The reason for calculating the moving average of a stock is
to help smooth out the price data over a specified period of time
by creating a constantly updated average price.
• • A simple moving average (SMA) is a calculation that takes
the arithmetic mean of a given set of prices over the specific
number of days in the past; for example, over the previous 15,
30, 100, or 200 days.
• • Exponential moving averages (EMA) is a weighted average
that gives greater importance to the price of a stock in more
recent days, making it an indicator that is more responsive to
new information.
12/21/2024 SOVERS SINGH BISHT UNIT 01 48
THE CONCEPT LEARNING TASK
Moving averages
• Moving Average
• Understanding a Moving Average (MA)
• Moving average is a simple, technical analysis tool. Moving averages are usually calculated
to identify the trend direction of a stock or to determine its support and resistance levels.
It is a trend-following—or lagging—indicator because it is based on past prices.
• The longer the time period for the moving average, the greater the lag. So, a 200-day
moving average will have a much greater degree of lag than a 20-day MA because it
contains prices for the past 200 days. The 50-day and 200-day moving average figures for
stocks are widely followed by investors and traders and are considered to be important
trading signals.
• Moving averages are a totally customizable indicator, which means that an investor can
freely choose whatever time frame they want when calculating an average. The most
common time periods used in moving averages are 15, 20, 30, 50, 100, and 200 days. The
shorter the time span used to create the average, the more sensitive it will be to price
changes. The longer the time span, the less sensitive the average will be.
• Investors may choose different time periods of varying lengths to calculate moving
averages based on their trading objectives. Shorter moving averages are typically used for
short-term trading, while longer-term moving averages are more suited for long-term
investors.
• The calculation for EMA puts more emphasis on the recent data points. Because of
this, EMA is considered a weighted average calculation.
• In the figure below, the number of time periods used in each average is identical–15–
but the EMA responds more quickly to the changing prices than the SMA. You can
also observe in the figure that the EMA has a higher value when the price is rising
than the SMA (and it falls faster than the SMA when the price is declining). This
responsiveness to price changes is the main reason why some traders prefer to use
the EMA over the SMA.
• Example of a Moving Average
• The moving average is calculated differently depending on the type: SMA or EMA.
Below, we look at a simple moving average (SMA) of a security with the following
closing prices over 15 days:
• • Week 1 (5 days): 20, 22, 24, 25, 23
• • Week 2 (5 days): 26, 28, 26, 29, 27
• • Week 3 (5 days): 28, 30, 27, 29, 28
• A 10-day moving average would average out the closing prices for the first 10 days as
the first data point. The next data point would drop the earliest price, add the price
on day 11 and take the average.
12/21/2024 SOVERS SINGH BISHT UNIT 01 52
THE CONCEPT LEARNING TASK
Box-Jenkins
Objective:
In this topic we learn about the Box-Jenkins Model which can
analyze several different types of time series data for forecasting
purposes. Its methodology uses differences between data points to
determine outcomes. The methodology allows the model to identify
trends using auto regresssion, moving averages, and seasonal
differencing to generate forecasts.
Recap:
Revision of basic statistical approaches.
• Autocorrelation Function
• The stationary assumption allows us to make simple statements about the
correlation between two successive values, Xt and Xt k . This correlation is
called the autocorrelation of lag k of the series. The autocorrelation function
displays the autocorrelation on the vertical axis for successive values of k on the
horizontal axis. The following figure shows the autocorrelation function of the
sunspot data.
Objective:
In this topic we learn about the Holt-Winters method uses
exponential smoothing to encode lots of values from the past and
use them to predict “typical” values for the present and future.
Exponential smoothing refers to the use of an exponentially
weighted moving average (EWMA) to “smooth” a time series.
Recap:
Revision of basic statistical approaches.
• Time series anomaly detection is a complicated problem with plenty of practical methods. It’s easy
to get lost in all of the topics it encompasses. Learning them is certainly an issue, but implementing
them is often more complicated. A key element of anomaly detection is forecasting—taking what
you know about a time series, either based on a model or its history, and making decisions about
values that arrive later.
• You know how to do this already. Imagine someone asked you to forecast the prices for a certain
stock, or the local temperature over the next few days. You could draw out your prediction, and
chances are it’s a pretty good one. Your brain works amazingly well for problems like this, and our
challenge is to try to get computers to do the same.
• If you take an introductory course on time series, you’ll learn how to forecast by fitting a model to
some sample data, and then using the model to predict future values. In practice, especially when
monitoring systems, this approach doesn’t work well, if at all! Real systems rarely fit mathematical
models. There’s an alternative. You can do something a lot simpler with exponential smoothing.
• st=αxt+(1−α)st−1
• In the late 1950s, Charles Holt recognized the issue with the simple EWMA model with time
series with trend. He modified the simple exponential smoothing model to account for a linear
trend. This is known as Holt’s exponential smoothing. This model is a little more complicated. It
consists of two EWMAs: one for the smoothed values of xt, and another for its slope. The terms
level and trend are also used.
• st=αxt+(1−α)(st−1+bt−1)
• bt=β(st−st−1)+(1−β)bt−1
12/21/2024 SOVERS SINGH BISHT UNIT 01 59
THE CONCEPT LEARNING TASK
Holt-winters
• To forecast with this model, you have to make a slight adjustment. Because
there’s another term for the slope, you’ll have to consider that in the forecast.
Suppose you’re trying to forecast the value in m time steps in the future. The
formula for the m-step-ahead forecast, Ft+m, is:
• Ft+m=st+mbt
• Notice how it’s essentially the formula for a line. What if your time series
doesn’t have a linear trend, but rather some sort of seasonality? For this, you’ll
need yet another EWMA.
The three aspects of the time series behavior—value, trend, and seasonality—are
expressed as three types of exponential smoothing, so Holt-Winters is called
triple exponential smoothing. The model predicts a current or future value by
computing the combined effects of these three influences. The model requires
several parameters: one for each smoothing (ɑ, β, γ), the length of a season, and
the number of periods in a season.
Objective:
In this topic we learn about Autocorrelation which represents the
degree of similarity between a given time series and a lagged version
of itself over successive time intervals. Autocorrelation measures the
relationship between a variable's current value and its past values.
Recap:
• Autocorrelation
• What Is Autocorrelation?
• Autocorrelation is a mathematical representation of the degree of
similarity between a given time series and a lagged version of itself
over successive time intervals. It's conceptually similar to the
correlation between two different time series, but autocorrelation
uses the same time series twice: once in its original form and once
lagged one or more time periods.
• For example, if it's rainy today, the data suggests that it's more likely
to rain tomorrow than if it's clear today. When it comes to investing,
a stock might have a strong positive autocorrelation of returns,
suggesting that if it's "up" today, it's more likely to be up tomorrow,
too.
• Naturally, autocorrelation can be a useful tool for traders to utilize;
particularly for technical analysts.
12/21/2024 SOVERS SINGH BISHT UNIT 01 64
THE CONCEPT LEARNING TASK
Autocorrelation
• KEY TAKEAWAYS
• • Autocorrelation represents the degree of similarity between a given time
series and a lagged version of itself over successive time intervals.
• • Autocorrelation measures the relationship between a variable's current
value and its past values.
• • An autocorrelation of +1 represents a perfect positive correlation, while
an autocorrelation of negative 1 represents a perfect negative correlation.
• • Technical analysts can use autocorrelation to measure how much
influence past prices for a security have on its future price.
• Autocorrelation
• Understanding Autocorrelation
• Autocorrelation can also be referred to as lagged correlation or serial correlation,
as it measures the relationship between a variable's current value and its past
values.
• As a very simple example, take a look at the five percentage values in the chart
below. We are comparing them to the column on the right, which contains the
same set of values, just moved up one row.
12/21/2024 SOVERS SINGH BISHT UNIT 01 65
THE CONCEPT LEARNING TASK
Autocorrelation
Monday 10% 5%
Tuesday 5% -2%
Friday -5%
Objective:
In this topic we learn about an autoregressive integrated moving
average, or ARIMA, is a statistical analysis model that uses time
series data to either better understand the data set or to predict
future trends. A statistical model is autoregressive if it predicts
future values based on past values.
Recap:
• ARIMA Parameters
• Each component in ARIMA functions as a parameter with a standard
notation. For ARIMA models, a standard notation would be ARIMA with p,
d, and q, where integer values substitute for the parameters to indicate the
type of ARIMA model used. The parameters can be defined as:
• • p: the number of lag observations in the model; also known as the lag
order.
• • d: the number of times that the raw observations are differenced; also
known as the degree of differencing.
• • q: the size of the moving average window; also known as the order of
the moving average.
• In a linear regression model, for example, the number and type of terms
are included. A 0 value, which can be used as a parameter, would mean that
particular component should not be used in the model. This way, the
ARIMA model can be constructed to perform the function of an ARMA
model, or even simple AR, I, or MA models.
12/21/2024 SOVERS SINGH BISHT UNIT 01 72
THE CONCEPT LEARNING TASK
ARIMA
• Because ARIMA models are complicated and work best on very large data sets,
computer algorithms and machine learning techniques are used to compute
them.
• Autoregressive Integrated Moving Average (ARIMA) and Stationarity
• In an autoregressive integrated moving average model, the data are differenced
in order to make it stationary. A model that shows stationarity is one that shows
there is constancy to the data over time. Most economic and market data show
trends, so the purpose of differencing is to remove any trends or seasonal
structures.
• Seasonality, or when data show regular and predictable patterns that repeat
over a calendar year, could negatively affect the regression model. If a trend
appears and stationarity is not evident, many of the computations throughout
the process cannot be made with great efficacy.
•
• A one-time shock will affect subsequent values of an ARIMA model infinitely
into the future. Therefore, the legacy of the financial crisis lives on in today’s
autoregressive models.
12/21/2024 SOVERS SINGH BISHT UNIT 01 73
THE CONCEPT LEARNING TASK
ARIMA
• Special Considerations
• ARIMA models are based on the assumption that past values have some residual effect
on current or future values. For example, an investor using an ARIMA model to
forecast stock prices would assume that new buyers and sellers of that stock are
influenced by recent market transactions when deciding how much to offer or accept
for the security.
• Although this assumption will hold under many circumstances, this is not always the
case. For example, in the years prior to the 2008 Financial Crisis, most investors were
not aware of the risks posed by the large portfolios of mortgage-backed securities
(MBS) held by many financial firms.
• During those times, an investor using an autoregressive model to predict the
performance of U.S. financial stocks would have had good reason to predict an
ongoing trend of stable or rising stock prices in that sector. However, once it became
public knowledge that many financial institutions were at risk of imminent collapse,
investors suddenly became less concerned with these stocks' recent prices and far
more concerned with their underlying risk exposure. Therefore, the market rapidly
revalued financial stocks to a much lower level, a move that would have utterly
confounded an autoregressive model.
12/21/2024 SOVERS SINGH BISHT UNIT 01 74
THE CONCEPT
Examples: Applications LEARNING
of Time TASK markets
Series in financial
Objective:
In this topic we learn about some application areas of time series in
financial market.
Recap:
Revision of basic statistical approaches.
Assignment
1. What is meant by the term stationary, as applied to a time series model? Explain
how the notation I (0) and I (1) is related to the concept of stationarity. Give one
example of a stationary model and one of a non-stationary model.
2. What are unit root tests and why are they important?
3. What stylized features of financial data cannot be explained using linear
models? Which of these features could be modeled using an ARCH/GARCH
process?
4. How do we use machine leaning models for univariate time series data? (other
than AR and MA terms)?
5. Explain Box-Jenkins in detail?
6. What do you understand by autocorrelation? How is it useful?
7. Explain the concept of smoothing time series in detail?
8. List all applications of time series in financial markets?
9. Can Non-Sequential Deep Learning Models outperform Sequential Models in
Time-Series Forecasting?
10. Compare some Forecasting Techniques for Stationary and Non-stationary Time-
Series?
12/21/2024 SOVERS SINGH BISHT UNIT 01 82
Faculty VideoTHE
Links, You tube &LEARNING
CONCEPT NPTEL VideoTASK
Links and Online
Courses Details
3) The last period’s forecast was 70 and demand was 60. What is the simple exponential
smoothing forecast with alpha of 0.4 for the next period.
A) 63.8
B) 65
C) 62
D) 66
5) Which of the following is not a necessary condition for weakly stationary time series?
• A) Mean is constant and does not depend on time
• B) Autocovariance function depends on s and t only through their difference |s-t|
(where t and s are moments in time)
• C) The time series under considerations is a finite variance process
• D) Time series is Gaussian
13) If the demand is 100 during October 2016, 200 in November 2016, 300 in December 2016, 400 in
January 2017. What is the 3-month simple moving average for February 2017?
A) 300
B) 350
C) 400
D) Need more information
15) Suppose, you are a data scientist at Analytics Vidhya. And you observed the views on the articles
increases during the month of Jan-Mar. Whereas the views during Nov-Dec decreases.
Does the above statement represent seasonality?
A) TRUE
B) FALSE
C) Can’t Say
12/21/2024 SOVERS SINGH BISHT UNIT 01 86
THE CONCEPT
GlossaryLEARNING
Questions TASK
A) Only 3
B) 1 and 2
C) 2 and 3
D) 1 and 3
A) Naive approach
B) Exponential smoothing
C) Moving Average
D)None of the above
A) Seasonality
B) Trend
C) Cyclical
D) Noise
E) None of the above
A) Seasonality
B) Cyclical
C) No difference between Seasonality and Cyclical
5) Adjacent observations in time series data (excluding white noise) are independent
and identically distributed (IID).
A) TRUE
B) FALSE
12/21/2024 Dr. Priyanka Chandani UNIT 01 88
THE CONCEPT LEARNING
Semester Paper TASK
2.“R for Everyone: Advanced Analytics and Graphics” by Lander, J., Addison-Wesley Data & Analytics
Series, 1 edition, 2013.
Thank You