Programmingempire
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
- Although there are many benefits of time series analysis, the most important one is predicting future outcomes.
- Also, it is beneficial in trend analysis.
- Basically, a time series analysis helps us in detecting patterns in the data.
- Besides, a time series analysis can also uncover the noise and outliers in the data.
- 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')
df=mydata['Temperature']
df.plot()
pl.show()
Output

The following image shows a screenshot of the 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
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
Deep Learning Methods for Object Detection
Image Contrast Enhancement using Histogram Equalization
Transfer Learning and its Applications
Examples of OpenCV Library in Python
Understanding Blockchain Concepts
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
- Angular
- ASP.NET
- C
- C#
- C++
- CSS
- Dot Net Framework
- HTML
- IoT
- Java
- JavaScript
- Kotlin
- PHP
- Power Bi
- Python
- Scratch 3.0
- TypeScript
- VB.NET
