Gas Prices Prediction Using Neural Networks
In this project Neural Networks are used to predict gas prices in US based on price variation tendencies for last 6 years. Prediction made in April of 2008 (stay tuned, some of it actually turned out to be true:))
For performing the prediction I used Backpropagation, a nice and powerful tool in Neural Networks for great variety of tasks: predication, classification, function approximation, etc. The program was written in Matlab.
Gas price is one of the most important topics that Americans and currently most of Europe and Asia, are concerned with in the recent years. Each time driving by the gas station I keep wandering, if the prices will finally stop raising and there will be some day of low and nice prices of under $1/per galon. Let us see what neural networks will predict what gas price we should expect in near future and in several years. Note that the prediction is made in April, 2008 when gas price was still $3.40, and that predication for the day you are reading this report may differ from the actual gas price.
The data for this problem is obtained from Energy Information Administration www.eia.doe.gov governmental source. Data presents gas price in cents for a gallon (ranging from 130 to 340!). For time period 1/14/2002 - 4/14/2008, the prices are shown the week starting from 1/14/2002.
Gallon price per cent for 6 years (April 2002 - April 2008)
The data in our case is not cyclic (as in Sine wave case in previous example) and neural net has to take the challenge of its approximation.
Neural Network parameters and training
Gas value is provided weekly, so we have only 326 week for time range 1/14/2002 - 4/14/2008. For smoother graph we introduce additional 2 points per week (simply by averaging the endpoints) which results data set of 976 ≈ 1000.
For training the neural network we chose to have 2 layers - hidden and output. We chose randomly weigh matrixes of the hidden and output layers, and 8 hidden units in hidden layer, and use bipolar activation function.
Below is presented the Standard Squared Error (SSE) graph, which shows that of 100 cycles of iteration the error is minimized and converges to 0. This shows that the prediction is precise, and that the prediction error is minimal.
SSE = 0.03 for N = 8, cycle number = 100
For the presentation of actual values, each time before plotting we multiply the data with the scale factor and map. Next we present the prediction mapped vs. original data which shows the degree of level of correctness of prediction. Prediction is started from 3/6/2006, and mapped for 3 after 4/14/2008.
Actual values (red) vs. prediction (green)
Next a few interesting figures are presented. Starting prediction today, prediction is made to see what will happen in 3 weeks. Using the same network configuration we see that prediction is different from the above case when we started from prior date. The prior argued that price would drop to $2.60, but below we see that it would be around $3.30.
Prediction of gas prices for next 3 months
The reason such difference exists is that before 3/6/2006 was smoother then what we have today. The figure below presents the prediction of network for next 6 years.
Prediction of gas prices for next 6 years
(April 2008 - April 2014)
To me this does not look too bad, though on average price will certainly rise with $0.6. This prediction can be verified by putting other tests on same data, and using different algorithm, but the most valid way of course is to remember about this in a while and compare predicted value with actual, as we saw recently the market can be very unstable.
However, at the end of May 2008, gas price is somewhat near predicted for 2014 ($4.10 in Dearborn, MI), although neural networks failed to learn this tendency, the actual price of $3.8 in the mid 2011 is very close to the prediction. We will observe the validity of the final prediction in years to come.