commit 9e7b5d4c67c718a39e1510cdce4f3d53244a83a6
Author: David Sorber <david.sorber@gmail.com>
Date:   Thu Dec 26 22:24:14 2013 -0500

    Adding work that I started on the PMML translator prototype.

diff --git a/software/PMML_translator/neural_network_model/neuron.py b/software/PMML_translator/neural_network_model/neuron.py
new file mode 100644
index 0000000..1ad1531
--- /dev/null
+++ b/software/PMML_translator/neural_network_model/neuron.py
@@ -0,0 +1,46 @@
+import math
+
+class Neuron(object):
+	
+	def __init__(self, layer, index, bias=0):
+		self.layer = layer
+		self.index = index
+		self.bias = bias
+		
+		# key: (from layer, from index)
+		# value: <weight>
+		self.edges = {}
+		
+		# Activation Function (logistic/sigmoid in this case)
+		# this should be passed as a parameter
+		self.act_func = lambda x: (1 / (1 + math.exp(-x)))
+		
+		self.value = 0
+		
+	def add_edge(self, key, weight):
+		""" Add new edge connection """
+		if key in self.edges:
+			raise Exception('edge already present')
+			
+		self.edges[key] = weight
+		
+	def calculate(self, inputs):
+		""" Calculate and return the neuron's output"""
+		# make sure number of inputs matches the number of edges/weights
+		if len(self.edges) != len(inputs):
+			msg = 'The number of inputs ({:d}) does not match the '\
+				  'number of expected edges ({:d})'\
+				  .format(len(self.edges), len(inputs))
+			raise Exception(msg)
+
+		# multiply each input by its weight and sum them all
+		for key, input_ in zip(sorted(self.edges), inputs):
+			weight = self.edges[key]
+			self.value += weight * input_
+		
+		# add in the bias
+		self.value += self.bias
+		
+		# ACTIVATE!
+		self.value = self.act_func(self.value)
+		return self.value
diff --git a/software/PMML_translator/neural_network_model/parser.py b/software/PMML_translator/neural_network_model/parser.py
new file mode 100644
index 0000000..1f97ddd
--- /dev/null
+++ b/software/PMML_translator/neural_network_model/parser.py
@@ -0,0 +1,26 @@
+import sys
+
+import lxml.etree as ET
+
+from neuron import Neuron
+
+pmml_ns = 'http://www.dmg.org/PMML-4_1'
+
+def _(string):
+	return '{{{:s}}}{:s}'.format(pmml_ns, string)
+
+def main():
+	if len(sys.argv) < 2:
+		print 'ERROR: not enough arguments specified'
+		return 1
+		
+	tree = ET.parse(sys.argv[1])
+	root = tree.getroot()
+	
+	network = root.findall(_('NeuralNetwork'))
+	
+	print network
+	print _('NeuralNetwork')
+	
+if __name__ == '__main__':
+	sys.exit(main())
