**CHICKEN PRICES PREDICTION USING NEURAL NETWORKS**
**An example for time-series prediction**
by Dr. Valentin Steinhauer
**Short description**
Time
series prediction plays a big role in economics. The
prices courses, as well as the consumption for example of
chicken, can be predicted
to be able to make decisions. This tutorial shows one possible approach how neural networks can be used for this kind of prediction. It extends the Neuroph tutorial called
"Time Series Prediction", that gives a good theoretical base
for prediction. To show how it works, we trained the network
with the chicken prices data – for the two years (from 01.2008
to 10.2009) - to predict of increase or decrease of the chicken
price at 11.2009. As a strategy
we take the sequences from 4 months to predict each 5th month. In
the training set 5th month is the supervised value. The data can be downloaded from the following url (one of the possibilities):
http://www.imf.org/external/np/res/commod/externaldata.csv
US
cents per pound of chicken - 2008,2009:
double[] data = {77.77D, 76.85D, 77.25D,
79.15D, 81.23D, 82.04D, 83.46D, 85.71D, 88.25D, 88.42D, 88.40D,
87.54D, //2008
87.02D, 87.25D, 86.7D, 85.73D, 85.38D, 86.96D, 88.17D, 88.56D,
86.77D, 82.85D, 82.13D};//2009
As
next step is the
preparation
of the training data in area (0-1).
For this goal is needed to find of the max/min value of
prices: datamax, datamin.
These values will be multiplied with 1.2 and 0.8 accordently, to
avoid small (0.0...) and big values (0.99...).
Further the
topology of network is defined:
what type of network, how many layers and how many neurons per
layer are used. Actually, there is no rule for this, and usually it is determined experimentaly. However the common type of network used for prediction is
a multi layer perceptron. A recommendation is to have 2n+1 nodes
for hidden-layer, where n is the number of the input nodes. The
output layer has only one node in this case.
At this point,
we are ready to train and test the net. As a test it
is prepared data set in which the
price
data are given from the
07-08-09-10 months 2009
to predict the value at
11.2009.
Because the
start state of the network with random values of weights is generated,
the test results differ from a calculation to
calculation. After five
tests it came out with the following prediction - results for
11.2009:
83,91;
83.75;
83.98;
83,75;
84.12.
The value which was official announced on that day is
82.13.
The middle value the last 4 month is 86.59. You can be take your
decision, for example, that you can buy the chichen next month.
**Using Clojure**
Here is the demo implementation of Chicken sample using Neuroph in Clojure created by Bojan Jovicic
Basically the idea was to follow the original idea of the sample by Dr. V. Steinhauer as closelly as possible while leveraging some advantages of Clojure.
First point of interest is ease of getting maximum and minimum using Clojure:
(defn get-data-max [data] (* 1.2 (reduce max data)))
(defn get-data-min [data] (* 0.8 (reduce min data)))
Full implementation is available for download here
**DOWNLOADS**
**Note:** These download packages are for versions of Neuroph older than 2.6, however differencies are minor
1.
Neuroph
framework with easyNeurons application
2.
NetBeans project for Chicken Price Prediction example
3.
Clojure implementation of Chicken sample
**See also:**
Time Series Prediction Tutorial
Stock Market Prediction Tutorial
Multi Layer Perceptron Tutorial |