Time Series- Basic Concepts before you start
By: Namrata Kapoor
Tags: Artificial Intelligence, Machine Learning, Time Series Forecasting, Data Science, Time Series Analysis

Time Series- Basic Concepts before you start

We always want to know what will happen in future, and if we can predict the important information of the future it is even more interesting.

Image Source

We always want to know what will happen in future, and if we can predict the important information of future it is even more interesting.

Time Series data is a set of observations taken during a time period. Time-Series in machine learning is a predictive tool to forecast upcoming information. It involves working on time, like year, month, day and hour to derive important information and take decisions based on it.

Examples can be stock market data, weather data that is recorded per day, vital stats data like steps.

Forecasting or Predicting Time Series data is a challenging task and is more complex than machine learning.

In Machine learning the dependent feature was predicted based on a number of features that are independent while in time series we have to predict future observation depending on past observations, that is, independent features are observations in time series only.

Prediction methodologies can be various like

1) Mean of past observations, which gives the same weightage to all past data.

2) Weighted mean of past observations in which more weightage is given to recent observation and less weightage is given to older data.

Also, factors like below make it more challenging:

1) Seasonality: Seasonality means data observations based on season like winters, summers, or festival. The best example of seasonality is the sales of Air Conditioners which is on peak in summer season in North India. We need to capture the seasonality of data to predict or forecast the future sale.

2) Trend: Trend example can be of a company having an upward or downward trend based on some news, merger or annual results, this is basically trend of the company which can be going on for some time and will continue so for more time. It may take longer periods than season for trend to set up. Another example can be consumption of electricity in India which going up because of more and more gadgets at home, it may come down in sometime if there is again a new gadgets coming in which consume less of energy. Trends dies out after a long time.

3) Irregularity: Unpredicted observations can be because of anything unpredictable like natural calamity, a war or a pandemic like COVID -19 which made markets to crash in the month of March 2020.

Stationary Data:

Time series data needs to be stationary before someone can start working on them.

Now, what do we mean by stationary data? Stationary data means, it should have constant mean and constant variance.

If data is not stationary there are many methods to make it stationary, few are as below:

1) De-Trending: To remove the trend component out of data observations, seeing if it is linear, exponential or constant.

2) Differencing: To remove seasonality from data, like if data is seasonal month-wise, it can be done by subtracting the data lag-wise with 12 as lag difference.

3) Logging: Doing Log of Observations can help in making the trend linear from exponential.

Types of Time Series

It is important to know what kind of time series data we are seeing, for example below is example of simple 2 types of time series data additive and multiplicative.

Image by Author

Image by Author

By knowing about our data we decide that how it will be decomposed into various factors like trend seasonality as we see different graphs here for additive and multiplicative data.

In Additive data component of Seasonality, Trend and irregularity are additive in nature, Value= Base + Trend X+ Seasonality + Irregularity.

While in multiplicative these components are multiplicative in nature i.e,

Value= Base X Trend X Seasonality X Irregularity.

Data Smoothing

Data smoothing uses algorithms to remove any noise from data to recognize patterns.

Smoothing by Rolling Stats

Rolling Stats can exhibit trend in the data. Moving average, if window is 2 and we apply it to data below then at t1 it’s NULL and at t2 its (20+25)/2=22.5

If mean at a particular time is (25+40)/2, it should be almost similar to (35+30)/2 if it is stationary.

Similarly it applies to variance.