Time Series Analysis

Solomon
2 min readMar 17, 2022

--

This article describes high level overview of modelling time series data.

Temporal data

Any data that can be described as a function of time or data that has pattern which can be described in time can be thought of temporal data, for instance, if we have rainfall data in an area for 5 years, and if we can observe some pattern in that , e.g. for every 6 months there is 120 cm rain observed, then such data is said to be time series data/temporal data.

Types of time series data

We can categorize such data broadly as

  1. Trend (Increasing and Decreasing) — Clear long-term increase or decresases
  2. Seasonal — Time series affected by seasonal factors such as time of year
  3. Cyclic — Rises and falls over an unfixed period.

Data

The data should definitely have a feature which represents date/time along with other features and labels.

Analysis

The first step is to plot the target label if it is regression where x axis is the date and y axis being target data, which helps to visualise how the data varies as time changes.

Train Test Split

It is very important to split the data such that the first 80% records which is sorted by date should be considered as Train data and the remaining 20% as test data , which is like a simulation where test data is the future data. We can use sklearn train_test_split by turning off random shuffling or split the data manually using numpy indexing.

Windowing Data

If we are going to use just the labels as features to predict the future data, we need to window the data such that it can be converted into a supervised machine learning problem, for instance, if our problem statement is to predict the amount of rain for that day, we can group 15 days rain amount which is features to our model and the 16th day rain amount will be actual label. We can create such windows which is array of 16 elements, which can then be processed in modelling

Modelling

As a first cut approach, Naive model can be used which is nothing but using the next day data as the prediction, along with that, sequence models such as Conv1D, LSTM can be used for prediction.

--

--

Solomon
Solomon

Written by Solomon

Passionate about Data Science and applying Machine Learning,Deep Learning algorithms

Responses (1)