Predicting with Time Series


In this post on Predicting with Time Series, I will explain how to build a Time Series model for predictions and Forecasting. To begin with, let us first understand the concept of Time Series and Time Series Analysis.

What is a Time Series?

In short, a Time Series spreads a sequence of data points over a period of time. Basically, time is an independent variable in a time series plot. In other words, a time series displays the sequence of data points in an order over a period of time.

Benefits of Time Series Analysis

  1. Although there are many benefits of time series analysis, the most important one is predicting future outcomes.
  2. Also, it is beneficial in trend analysis.
  3. Basically, a time series analysis helps us in detecting patterns in the data.
  4. Besides, a time series analysis can also uncover the noise and outliers in the data.
  5. By and large time series analysis provides us an important tool for forecasting.

Time Series Models

As can be seen, we can use both the statistical models as well as the Machine Learning models in time series forecasting. The following list shows some of the statistical models used in time series forecasting.

  • Autoregression
  • Moving Averages
  • Autoregressive Integrated Moving Average

While some of the Machine Learning models that we can use in time series forecasting are given below.

  • Multi-layer Perceptron Model
  • Random Forests
  • Long Short Term Memory (LSTM)

An Example of Predicting with Time Series

As an illustration of the time series analysis, consider the following example. Surely, we need a dataset of this example. Therefore, we download one of the publicly available weather history datasets from Kaggle. Since the dataset contains many fields, we need to extract the one indicating temperature values. The following code demonstrates how to plot time series.

import pandas as pd
import matplotlib.pyplot as pl
mydata = pd.read_csv('weatherHistory.csv')


A Simple Example of Time Series
A Simple Example of Time Series

The following image shows a screenshot of the dataset.

Weather History Dataset
Weather History Dataset

Although the above example is not using any statistical model, it shows the basic concept of the time series. However, the use of a statistical model helps us in extracting the important statistical information present in the data. Hence, we can identify the nature of the phenomenon represented by the data points.

Further Reading

Deep Learning Tutorial

Text Summarization Techniques

How to Implement Inheritance in Python

Find Prime Numbers in Given Range in Python

Running Instructions in an Interactive Interpreter in Python

Deep Learning Practice Exercise

Python Practice Exercise

Deep Learning Methods for Object Detection

Understanding YOLO Algorithm

What is Image Segmentation?

ImageNet and its Applications

Image Contrast Enhancement using Histogram Equalization

Transfer Learning and its Applications

Examples of OpenCV Library in Python

Examples of Tuples in Python

Python List Practice Exercise

Understanding Blockchain Concepts

Edge Detection Using OpenCV

Predicting with Time Series

Example of Multi-layer Perceptron Classifier in Python

Measuring Performance of Classification using Confusion Matrix

Artificial Neural Network (ANN) Model using Scikit-Learn

Popular Machine Learning Algorithms for Prediction

Long Short Term Memory – An Artificial Recurrent Neural Network Architecture

Python Project Ideas for Undergraduate Students

Creating Basic Charts using Plotly

Visualizing Regression Models with lmplot() and residplot() in Seaborn

Data Visualization with Pandas

A Brief Introduction of Pandas Library in Python

A Brief Tutorial on NumPy in Python


You may also like...