"""Example 2 of orangeSNNS

Creates and trains a neural network:
 - With two hidden layers, the first with 2 neurons, and the second with 3
 - The training process will have 500 cycles on the training set.
 - If MSE=0 is achieved training stops.
 - The learning algorithm will be standard back propagation.
 - The learning parameter is 0.2

The network is then used to classify the training set showing the predicted
class for each example.

"""

import orange, orangeSNNS

# We set the path where SNNS binaries can be found, this
# is not necessary if they are in system path.
orangeSNNS.pathSNNS = "~/SNNSv4.2/tools/bin/i686-pc-linux-gnu/"

data = orange.ExampleTable("bupa.tab")

learner = orangeSNNS.SNNSLearner(name = 'SNNS neural network',
                                 hiddenLayers = [2,3],
                                 MSE = 0,
                                 cycles = 500,
                                 algorithm = "Std_Backpropagation",
                                 learningParams = ["0.2"])

classifier = learner(data)

for example in data:
   print example,
   print "->", classifier(example)
