top of page

What is Time Series Analysis in Machine Learning?

What is a time series?

  • A collection of data recorded over a period of time (weekly, monthly, quarterly, etc.)

  • An analysis of history, it can be used by management to make current decisions and plans based on long-term forecasting

  • Usually assumes past pattern to continue into the future

Time Series Analysis

- Time Series: Ordered sequence of equally spaced values over time

- Time Series Analysis: Accounts for the internal structure of observations taken over time

  • Trend

  • Seasonality

  • Cycles

  • Random

- Goals

  • To identify the internal structure of the time series

  • To forecast future events

- Example: Based on sales history, what will next December sales be?

Businesses perform sales forecasting to look ahead in order to plan their investments, launch new products, decide when to close or withdraw products, etc. The sales forecasting process is a critical one for most businesses. Part of the sales forecasting process is to examine the past. How well did we do in the last few months or what were our sales in the same time period for the last few years? Time Series Analysis provides a scientific methodology for sales forecasting. Time Series Analysis is the analysis of sequential data across equally spaced units of time. Time Series is a basic research methodology in which data for one or more variables are collected for many observations at different time periods. The main objectives in Time Series Analysis are:

  • To understand the underlying structure of the time series by breaking it down to its components.

  • Fit a mathematical model and then proceed to forecast the future

The time periods are usually regularly spaced and the observations may be either univariate or multivariate. Univariate time series are those where only one variable is measured over time, whereas multivariate time series are those, where multiple variables are measured simultaneously.

Components of a Time Series

  • Secular Trend – the smooth long term direction of a time series

  • Cyclical Variation – the rise and fall of a time series over periods longer than one year

  • Seasonal Variation – Patterns of change in a time series within a year which tends to repeat each year

  • Irregular Variation – unpredictable but identifiable

Cyclical Variation – Sample Chart

Seasonal Variation – Sample Chart

Seasonal Variation

  • One of the components of a time series

  • Seasonal variations are fluctuations that coincide with certain seasons and are repeated year after year

  • Understanding seasonal fluctuations help plan for sufficient goods and materials on hand to meet varying seasonal demand

  • Analysis of seasonal fluctuations over a period of years help in evaluating current sales

The Moving Average Method

  • Useful in smoothing time series to see its trend

  • Basic method used in measuring seasonal fluctuation

  • Applicable when time series follows fairly linear trend that have definite rhythmic pattern.

Box-Jenkins Method: What is it?

Models historical behavior to forecast the future

- Applies ARMA (Autoregressive Moving Averages)

  • Input: Time Series

- Accounting for Trends and Seasonality components

  • Output: Expected future value of the time series

What is ARIMA Model?

- This acronym is descriptive, capturing the key aspects of the model itself:

  • AR: Autoregression. A model that uses the dependent relationship between an observation and some number of lagged observations.

  • I: Integrated. The use of differencing of raw observations (e.g. subtracting an observation from an observation at the previous time step) in order to make the time series stationary.

  • MA: Moving Average. A model that uses the dependency between an observation and a residual error from a moving average model applied to lagged observations.

- A standard notation is used of ARIMA(p,d,q) where the parameters are substituted with integer values to quickly indicate the specific ARIMA model being used.

- The parameters of the ARIMA model are defined as follows:

  • p: The number of lag observations included in the model, also called the lag order.

  • d: The number of times that the raw observations are differenced, also called the degree of differencing.

  • q: The size of the moving average window, also called the order of moving average.

Use Cases


  • Next month's sales

  • Tomorrow's stock price

  • Hourly power demand

Modeling a Time Series

  • Let's model the time series as

Yt =Tt +St +Rt, t=1,...,n.

- Tt: Trend term

  • Air travel steadily increased over the last few years

- St: The seasonal term

  • Air travel fluctuates in a regular pattern over the course of a year

- Rt: Random component

  • To be modeled with ARMA

Stationary Sequences

- the random component is a stationary sequence

  • Constant mean

  • Constant variance

  • Autocorrelation does not change over time

- Constant correlation of a variable with itself at different times

- In practice, to obtain a stationary sequence, the data must be:

  • De-trended

  • Seasonally adjusted


- In this example, we see a linear trend, so we fit a linear model

  • Tt = m·t + b

- The de-trended series is then

  • Y1t = Yt – Tt

Trend in a time series is a slow, gradual change in some property of the series over the whole interval under investigation.

De-trending is a pre-processing step to prepare time series for analysis by methods that assume stationarity.

A simple linear trend can be removed by subtracting a least-squares-fit straight line. In the example shown we fit a linear model and obtain the difference. The graph shown next is a de-trended time series.

More complicated trends might require different procedures such a fitting a non-linear model such as a quadratic or a exponential model.

Use a Linear Trend Model if the first differences are more or less constant [ (y2-y1) = (y3-y2) = ……. = (yn-yn-1) ]

Use a Quadratic Trend Model if the second differences are more or less constant. [ (y3-y2) – (y2-y1) = ………= (yn-yn-1)-(yn-1-yn-2) ]

Use an Exponential Trend Model if the percentage differences are more or constant. [ ((y2-y1) /y1 ) * 100% = …….((yn-yn-1)/yn-1 ) * 100%

To get help in Time Series Forecasting you can contact us or send your project requirement details at:


bottom of page