From 653cb680d6cedf247f38ebb743b9fae92c5dccd3 Mon Sep 17 00:00:00 2001
From: Brandon Rodriguez <brodriguez8774@gmail.com>
Date: Mon, 21 May 2018 12:19:06 -0400
Subject: [PATCH] Set up base class structure

---
 main.py              | 28 +++++++++++++++++
 neural_net.py        | 71 ++++++++++++++++++++++++++++++++++++++++++++
 resources/logging.py |  2 +-
 3 files changed, 100 insertions(+), 1 deletion(-)
 create mode 100644 neural_net.py

diff --git a/main.py b/main.py
index e69de29..927ef8a 100644
--- a/main.py
+++ b/main.py
@@ -0,0 +1,28 @@
+"""
+Back-propagation Neural Net.
+"""
+
+# System Imports.
+import numpy, pandas
+
+# User Class Imports.
+from resources import logging
+import neural_net
+
+
+# Initialize logging.
+logger = logging.get_logger(__name__)
+
+
+# Load in CSV.
+housing_data = pandas.read_csv('./Documents/other_housing.csv')
+
+# Initially only work with first 10, for testing purposes.
+housing_data = housing_data[0:10]
+
+# Normalize data.
+normalizer = neural_net.Normalizer()
+normalized_data = normalizer.normalize_data(housing_data)
+
+# Start neural net.
+backprop = neural_net.BackPropNet(normalized_data)
diff --git a/neural_net.py b/neural_net.py
new file mode 100644
index 0000000..3ad7ce1
--- /dev/null
+++ b/neural_net.py
@@ -0,0 +1,71 @@
+"""
+Neural Net logic.
+"""
+
+# System Imports.
+import numpy, pandas
+
+# User Class Imports.
+from resources import logging
+
+
+# Initialize logging.
+logger = logging.get_logger(__name__)
+
+
+class Normalizer():
+    """
+    Handles data normalization.
+    """
+    def normalize_data(self, data):
+        """
+        Normalizes and returns provided dataset.
+        :param data: A pandas array of housing data to normalize.
+        :return: The normalized array of housing data.
+        """
+        # Print out data.
+        # logger.info(data)
+        # logger.info(data.columns.values)
+
+        # Address individual columns.
+
+        return data
+
+class BackPropNet():
+    """
+    Neural Net implementing back propagation.
+    """
+    def __init__(self, data):
+        self.weights = self._initialize_weights(data)
+
+    def _initialize_weights(self, data):
+        """
+        Initialize weights based of number of passed columns in data.
+        Values are initialized to random decimals near 0, using a normal distribution.
+        :param data: Data to create weights for.
+        :return: Vector of column weights.
+        """
+        weights = []
+        for column in data.columns:
+            weights.append(numpy.random.randn() * 0.001)
+
+        # logger.info(weights)
+        return weights
+
+    def predict(self):
+        pass
+
+    def train(self):
+        pass
+
+    def _train_step(self):
+        pass
+
+    def _calculate_error(self):
+        pass
+
+
+class ResultTracker():
+    """
+    Tracks statistics and progress of main Neural Net class.
+    """
diff --git a/resources/logging.py b/resources/logging.py
index c247173..f4cf655 100644
--- a/resources/logging.py
+++ b/resources/logging.py
@@ -22,7 +22,7 @@ def get_logger(caller):
 project_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
 log_dir = os.path.join(project_dir, 'resources/logs')
 if not os.path.exists(log_dir):
-    print('Error initializing logging.')
+    os.makedirs(log_dir)
 
 
 # Dictionary style logging options.
-- 
GitLab