E N D
Module 5Time Series Forecasting • 5.1 Taxonomy of Time Series Forecasting methods, Time Series Decomposition • 5.2 Smoothening Methods: Average method, Moving Average smoothing, Time series analysis using linear regression, ARIMA Model, Performance Evaluation: Mean Absolute Error, Root Mean Square Error, Mean Absolute Percentage Error, Mean Absolute Scaled Error • 5.3 Self-Learning Topics: Evaluation parameters for Classification, regression and clustering.
FROM • https://neptune.ai/blog/time-series-forecasting
What is a time series? • Time-series are a sequence of data points organized in time order.
Time series are everywhere • Finance: we’re trying to predict perhaps stock prices over time, asset prices, different macroeconomic factors that will have a large effect on our business objectives.
Time series are everywhere • E-commerce: we’re trying to predict future page views compared to what happened in the past, and whether it’s trending up, down, or if there’s seasonality. • Same with new users, how many new users are you getting/losing over time?
Time series are everywhere • Business: we’re trying to predict the number of transactions, future revenue, and future inventory levels that you will need.
Time series decomposition • Time series decomposition involves thinking of a series as a combination of level, trend, seasonality, and noise components.
Time series decomposition • Decomposition provides a useful abstract model for thinking about time series generally and for better understanding problems during time series analysis and forecasting.
Time series decomposition • One of the fundamental topics in time series is time series decomposition: • Components of time series data • Seasonal patterns and trends • Decomposition of time series data
What are the components of time series? • Trend: • Seasonality • Residual
What are the components of time series? • Trend: change direction over a period of time
What are the components of time series? • Seasonality: seasonality is about periodic behavior, spikes or drops caused by different factors, for example: • Naturally occurring events, like weather fluctuations
What are the components of time series? • Seasonality: • Business or administrative procedures, like start or end of a fiscal year • Social and cultural behavior, like holidays or religious observances • Calendar events, like the number of Mondays per month or holidays shifting year to year
What are the components of time series? • Residual: irregular fluctuations that we cannot predict using trend or seasonality.
Decomposition models • Additive modelMultiplicative model • Pseudo-additive models
Decomposition models • Additive model • The additive model assumes the observed time series is the sum of components: • Observation = trend + seasonality • Additive models are used when the magnitude of seasonal and residual values are independent of the trend.
Additive model • In the above example, we can see that seasonality in the residuals doesn’t increase or decrease as the trend increases, but rather it stays constant all the way.
Additive model • Looking at this plot, and subtracting out the straight line that is the trend, we can imagine that we just have the straight added on the seasonal component that says the same no matter what that trend is.
Multiplicative model • Multiplicative model • The multiplicative model assumes the observed time series is a product of its components: • Observation = trend * seasonality * residual
Multiplicative model • We can transform the multiplicative model to an additive model by applying a log transformation: • log(time * seasonality * residual) = log(Time) + log(seasonality) + log(residual) • These are used if the magnitudes of seasonal and residual values fluctuate with the trend.
Multiplicative model • In the above image, we see the trend increases, so we’re trending up. • The seasonal component is also trending up with the trend.
Multiplicative model • This means that it’s likely a multiplicative model, so we should divide out that trend, and then we would end up with more reasonable looking (more consistent) seasonality.
Pseudo-additive models • Pseudo-additive models combine the elements of both additive and multiplicative models.
Pseudo-additive models • They can be useful when: • Time series values are close to or equal to zero • We expect features related to the multiplicative model • Division by zero often becomes a problem when this is the case
Stationary and autocorrelation • What is stationarity? • For time series data to be stationary, the data must exhibit three properties over time: • 1. Constant Mean: • 2. Constant Variance: • 3. Constant Autocorrelation Structure:
1. Constant Mean: • 1. Constant Mean: • A stationary time series will have a constant mean throughout the entire series.
1. Constant Mean: • As an example, if we were to draw the mean of the series, this holds as the mean throughout all of the time.
1. Constant Mean: • A good example where the mean wouldn’t be constant is if we had some type of trend. • With an upward or downward trend, for example, the mean at the end of our series would be noticeably higher or lower than the mean at the beginning of the series.
. Constant Variance: • 2.Constant Variance: • A stationary time series will have a constant variance throughout the entire series.
3. Constant Autocorrelation Structure: • Autocorrelation simply means that the current time series measurement is correlated with a past measurement. • For example, today’s stock price is often highly correlated with yesterday’s price.
3. Constant Autocorrelation Structure: • The time interval between correlated values is called LAG. • Suppose we wanted to know if today’s stock price correlated better with yesterday’s price, or the price from two days ago.
3. Constant Autocorrelation Structure: • We could test this by computing the correlation between the original time series and the same series delayed by one time interval.
3. Constant Autocorrelation Structure: • So, the second value of the original time series would be compared with the first of the delayed. • The third original value would be compared with the second of the delayed, and so on.
3. Constant Autocorrelation Structure: • Performing this process for a lag of 1 and a lag of 2, respectively, would yield two correlation outputs. • This output would tell which lag is more correlated. • That is autocorrelation in a nutshell.
Time series smoothing • Smoothing is a process that often improves our ability to forecast series by reducing the impact of noise.
Why is smoothing important? • Smoothing is an important tool that lets us improve forward-looking forecasts. • Consider the data in the below graph.
Why is smoothing important? • How could we forecast what will happen in one, two, or three steps into the future? • One solution is to calculate the mean of the series and predict the value in the future.
Why is smoothing important • But, using the mean to predict future values doesn’t seem like a good way, and we might not get accurate predictions. • Instead, we employ a technique called exponential smoothing.
Single Exponential Smoothing • Single Exponential Smoothing, also called Simple Exponential Smoothing, is a time series forecasting method for univariate data without a trend or seasonality.
Single Exponential Smoothing • It requires a single parameter, called alpha (a), also called the smoothing factor or smoothing coefficien
Single Exponential Smoothing • This parameter controls the rate at which the influence of observations at prior time steps decays exponentially. • Alpha is often set to a value between 0 and 1.
Single Exponential Smoothing • Large values mean that the model pays attention mainly to the most recent past observations, whereas smaller values mean more of the history is taken into account when making a prediction.