Price Forecasting Multivariate Updated
Price Forecasting Multivariate Updated
Report
Bachelor of Technology
in
Information Technology
Submitted by
Certificate
Date:Apr, 25 2020
Abstract
1 Introduction 1
2 Problem Statement 3
3 Literature Survey 4
5 Methodology 14
5.0.1 Recurrent Neural Network - RNN . . . . . . . . . . . . 15
5.0.2 Long Short Term Memory - LSTM . . . . . . . . . . . 16
5.0.3 Hidden Markov Models-HMM . . . . . . . . . . . . . . 18
5.0.4 Implementation Plan and Timeline . . . . . . . . . . . 19
6 Results 21
6.0.1 Outcomes . . . . . . . . . . . . . . . . . . . . . . . . . 21
Acknowledgements 33
References 34
i
Chapter 1
Introduction
1
Through this paper, we focus on short term electricity price forecasting
using Long short-term memory(LSTM), Recurrent Neural Network(RNN)
and also comparison between these two models. Both LSTM and RNN mod-
els forecasts prices for the next 6 hours. We have also implemented Hidden
Markov Model(HMM) for our problem and discussed the results in brief. We
are predicting the price variable for 6 hours ahead, by seeing data for 5 days
behind for both LSTM and RNN, while a training size of 7000 tuples is used
to predict a test set of 3000 tuples in HM Model.
2
Chapter 2
Problem Statement
3
Chapter 3
Literature Survey
4
the application of HMM on kernel bayes rule as well as Recurrent Neural
Networks. They concluded that in high speed networks with large traffic
requirements, these models can be very successful due to non requirement
of calculating traffic volume. Tie Liu in his paper on Application of Markov
Chains to Analyze and Predict the Time Series[10], applied Markov Chains to
analyse and predict time series using first-order discrete-time Markov Chains
for some cases and higher order Markov Chains for others. He summarised
that the accuracy of markov chain models for prediciton of time series is very
well.
Hippert et al. in a paper reviewed and evaluated traditional method us-
ing neural networks for Short-Term Load Forecasting[11]. Various other ap-
proaches like using support vector machine for load forecasting for a EUNITE
competition[12], using fuzzy neural networks[13], using knowledge-based ex-
pert systems[14] have been developed or the same analysis. Another approach
develops iterative reweighed least squares algorithm for short term power
system load forecasting[15]. Another research conducted by Mohamed A.
Abu-El-Magd et al. drew a comparison between online and offline methods
for short-term electric load forecasting. The load demand was also mod-
eled using multivariate time series analysis [16]. G. T. Heinemann and team
studied temperature sensitive and non-temoerature sensitive load and did a
regression analysis for the same [17].
5
Chapter 4
For the problem of price forecasting that we tried to solve, we used the
following two data sources :
1. ieso Power Data Directory. [1]
2. Climate and Weather Data, Canada. [2]
We constructed a data-set by combining data from these two data sources
for the region of Ontario, Canada.
The market demand and zone-wise demand is hourly data whereas the
real-time market data is available for every 5 minute interval. The availability
of data is as follows:-
1. Ontario and Market Demand - 2002-present, avg. file size = 153 kB
2. Zonal Demand - 2003-present, avg. file size = 429 kB
3. Real time market price report - 2010-present, avg. file size = 24 MB
As can be seen, for data to be available for all attributes, i.e. the years for
which data is available for all the three above mentioned reports, we have
taken the data for the years 2010-2019.
6
Column Name Datatype
Date datetime
Hour int
Market Demand int
Ontario Demand int
7
4.0.2 Climate and Weather Data, Canada
This data-set is provided by Government of Canada. The data-set contains
the weather data of Ontario, Canada. There are 20+ attributes in each file
such as temperature, dew point, humidity, etc. The data is in comma sepa-
rated values(.csv) format and each file contains hourly data for one particular
month in a year. The average size of each file is 119 kB.
8
4.0.3 Data Preprocessing
In ieso Power Data Directory data-set, not all three i.e Ontario and Market
Demand, Zonal Demand and Real time market price report were not avail-
able from 2002. As we have to combine all three we have used the data from
2010 to 2019. Climate and Weather Data is also available for these years.
• While Ontario and Market Demand, Zonal Demand and Climate and
Weather Data are in the form of hourly data, Real time market price
report is available for every 5 minute interval. Thus, one has to be
adjusted in the form of the other.
Linear interpolation is a linear function. Suppose two points (x0, y0) and
(x1, y1) exist, and an unknown function f, then interpolating a point between
two points, thus, the interpolated point f(x, y) can be denoted as:
f ( x, y) = f ( x0 ) + w · ( f ( x1 ) − f ( x0 ) )
= ( 1 − w) f ( x0 ) + w · f ( x1 )
Where w is denoted by:
y − y0 x − x0
w= =
y1 − y0 x1 − x0
9
In python, there is a in-built function interpolate() which is used to fill NA
values in the dataframe or series. interpolate() function takes arguments like
method of interpolation to be used and direction in which it has to perform
interpolation. Linear Interpolation can be done two directions in python:
forward and backward. We have used linear interpolation in backward direc-
tion as there were more missing values in the beginning of our dataset i.e in
the year 2010.
As we had hourly values and we needed values for every 5 minute in-
terval again it is similar to missing values problem and we have used linear
interpolation again to upsample the data. After upsampling the data and
combining both weather and electricity data the resulting dataset(Table 4.5)
had 170 columns and about 1.2 gigabytes in size.
10
Column Name Datatype
Date datetime
Hour int
Minute int
Market Demand float
Ontario Demand float
Regions(count=15)
10N float
30R float
ENGY float
Zones(count=10)
Zone Demand float
Longitude float
Latitude float
Station Name string
Temp float
Dew Point Temp float
Rel Hum float
Wind Dir (10s deg) float
Wind Spd (km/h) float
Visibility (km) float
Stn Press (kPa) float
Wind Chill float
11
• cov is the covariance
• σA is the standard deviation of A
Therefore, from all available attributes for weather data, we used Temp,
Dew Point Temp and Rel Hum as the relevant attributes, because these were
common amongst all above techniques used for feature selection. After re-
moving all the irrelevant attributes from our data-set, now we had 46 columns
and about 300 megabytes in size(Table 4.6).
12
Column Name Datatype
Date datetime
Hour int
Minute int
Market Demand float
Ontario Demand float
Ontario Price float
Zones(count=10)
Zone Demand float
Temp float
Dew Point Temp float
Rel Hum float
13
Chapter 5
Methodology
In this section we are going to explain the steps that we followed. The
methodology can be represented as the following pipeline:-
We started the process with the preparation of data, the steps to which
we have discussed in the previous section. Before explaining about each
algorithm, we shall explain the steps that were common to all of them. Our
data-set now had three columns namely-Date, Hour, Minute, upon combining
which, we got our time stamp, named ”period”, which we used as the index
of our data moving forward. To fill some missing values that might have been
left, we backward interpolated our data because the largest chunk of missing
data was present at the start of the year 2010.
In addition to these steps which were common for all three algorithms, to
make a comparative study between RNN and LSTM, we used similar model
definitions for both, about which we will be talking in the coming sections.
We used tensorflow’s open source library-HParam for hyperparameter tuning,
14
including number of cells in each layer, the optimiser function and the drop
rate.
We shall now look at each of the algorithms one by one.
Upon unrolling the loop, we might be able to see the working more clearly.
At each stage, the chunk of Neural Network - A, takes some input xt and
gives some output ht . The loop allows it to take some part of the output and
pass it to the next time step t+1.
RNNs have been applied to a variety of problem incuding but not limited
to speech recognition, image captioning, transation and others. But on the
question of prediction with time series data, a special type of RNN- Long
Short Term Memory of LSTM Networks have been used majorly. While
Long Short Term Memory networks have a clear advantage over observing
long term dependencies due to their innate feature of memory, for the prob-
lem of Short term forecasting we wanted to study if RNNs might just do the
trick as we won’t need to study dependencies over a long term.
15
Figure 5.3: an unrolled Recurrent Neural Network
16
below.
The key to LSTMs is the cell state which is the straight line running
through the repeating module. It is like a conveyor belt which runs through
the module with minor interactions which are controlled by gates. Gates are
composed of sigmoid neural net layers and multiplication pointwise functions.
They output numbers between 0 and 1 where 0 means do not let anything
through and 1 means let everything through.
The first step is the forget gate layer, which looks at the current cell state,
and from h(t-1) and x(t), decides how much part to keep and what to forget.
The next step is the input gate layer in which new information is added
to the cell state through a sigmoid neural net layer and a tanh function. In
the next step, these two layers are combined to give an update to the state.
The old cell state is now updated to the new cell state by first multiplying
17
In our model, we have used the following architecture. The results achieved
are discussed further in the paper.
Due to dearth of available resources and the complexity of solving the above
problems, we used a model similar to the one proposed by Nguyet Nguyen[20],
by using the the Bayesian information criterion, BIC to test the performances
of HMM with different numbers of states, variable between 2 and 15. Due to
the property of the above said model of prefering higher number of states to
18
Figure 5.7: hidden markov process
form complex models leads to overfitting and that can be seen in our results
which have high r2 values, above 0.99.
The excessive run times caused due to the lack of computational resources in
our personal systems lead us to using only 1/100th of our data set for pre-
diction. Thus we present HMM only for completion and not for comparison
to the above two stated algorithms.
19
Figure 5.8: our implementation plan and timeline
20
Chapter 6
Results
6.0.1 Outcomes
We will start the results with the tables of both Long Short Term Mem-
ory(LSTM) and Recurrent Neural Network(RNN) parameters. Then we pro-
ceed on to the comparative analysis of both via images. Then we present
the Table of Parameters of Hidden Markov Model(HMM) and in the end are
some of the images for sample outputs.
From the tables, it is easy to see that for short term load forecasting, a sim-
ple RNN model performs better than an LSTM Model. These results are
also illustrated in the graphs that follow. This can be attributed to the fact
that long term dependencies need not be considered in the case of short term
forecasting, therefore a simpler model outperforms the complex one.
21
Figure 6.1: LSTM results
22
Figure 6.2: RNN results
23
Figure 6.3: RMS comparison of RNN and LSTM
24
Figure 6.5: Training time comparison of RNN and LSTM
25
Figure 6.7: Runtime comparison of RNN and LSTM
26
27
Figure 6.8: HMM results
Figure 6.9: RMS of HMM
28
Figure 6.11: MAPE of HMM
29
Figure 6.13: Sample RNN Output
30
Figure 6.15: Sample HMM Output
31
Disposal of Comments given by
respected Board Members
during first evaluation
32
Acknowledgments
We are extremely grateful to our project supervisor Prof. Dr. O.P. Vyas for
his guidance and support at every stage of the project. We are also thank-
ful to all the friends who have supported and helped in every phase of the
project till now.
Thank you.
April 2020
Indian Institute of Information Technology, Allahabad
33
References
[3] Paras Mandal, et al., A new recursive neural network algorithm to fore-
cast electricity price for PJM day-ahead market, International Journal
of Energy Resource, Vol. 34 Issue 6, May 2010, pages 507-522.
[6] Israt Jahan, Sayeed Sajal, Stock Price Prediction using Recurrent Neural
Network (RNN) Algorithm on Time-Series Data, MIC Symposium-2018,
paper 55.
[7] Houda Bakir, Ghassen Chniti, and Hédi Zaher, E-Commerce Price Fore-
casting Using LSTM Neural Networks, International Journal of Machine
Learning and Computing, Vol. 8, No. 2, April 2018.
[8] Jian Zheng, Cencen Xu, Ziang Zhang and Xiaohua Li, ”Electric load
forecasting in smart grids using Long-Short-Term-Memory based Re-
current Neural Network,” 2017 51st Annual Conference on Information
Sciences and Systems (CISS), Baltimore, MD, 2017, pp. 1-6.
34
[9] Zhitang Chen, Jiayao Wen and Yanhui Geng, Predicting Future Traffic
using Hidden Markov Models, 2016 IEEE 24th International Confer-
ence on Network Protocols (ICNP) Workshop on Machine Learning in
Computer Networks (NetworkML 2016).
[10] Tie Liu, Application of Markov Chains to Analyze and Predict the Time
Series, Modern Applied Science, Specialized Scientific Research Program
on Scientific Research of high-level talents in Ankang University (Pro-
gram No. AYQDZR200705).
[11] Hippert, H.s Pedreira, Carlos Souza, Reinaldo. (2001). Neural Networks
for Short-Term Load Forecasting: A Review and Evaluation. Power Sys-
tems, IEEE Transactions on. 16. 44 - 55. 10.1109/59.910780.
[13] “Short term load forecasting using fuzzy neural networks”, IEEE Trans-
actions on Power Systems, Vol.10, No.3 August 1995.
[14] “Short term load forecasting for fast developing utility using knowledge-
based expert systems”, IEEE Transactions on Power Systems, Vol.17,
No.4, May 2002.
[15] “Short term power system load forecasting using the iteratively
reweighed least squares algorithm”, Electric power system research,
19(1990) pp.11-12
35
[19] L. R. .Rabiner, B. H. Juang, An Introduction to Hidden Markov Models,
1966.
[20] Nguyet Nguyen, Stock Price Prediction using Hidden Markov Model,
March 21, 2016.
[22] Weron, Rafal. (2014). Electricity price forecasting: A review of the state-
of-the-art with a look into the future. International Journal of Forecast-
ing. 30. 10.1016/j.ijforecast.2014.08.008.
36