diff tests/test_logistic_regression.py @ 32:0f29b02f4806

[logistic regression] add model
author Jeff Hammel <k0scist@gmail.com>
date Mon, 04 Sep 2017 13:20:25 -0700
parents fa7a51df0d90
children
line wrap: on
line diff
--- a/tests/test_logistic_regression.py	Mon Sep 04 12:37:45 2017 -0700
+++ b/tests/test_logistic_regression.py	Mon Sep 04 13:20:25 2017 -0700
@@ -59,7 +59,7 @@
         """test gradient descent method"""
 
         # test examples
-        w, b, X, Y = np.array([[1],[2]]), 2, np.array([[1,2],[3,4]]), np.array([[1,0]])
+        w, b, X, Y = (np.array([[1],[2]]), 2, np.array([[1,2],[3,4]]), np.array([[1,0]]))
 
         params, grads, costs = logistic_regression.optimize(w, b, X, Y, num_iterations= 100, learning_rate = 0.009, print_cost = False)
 
@@ -77,6 +77,14 @@
         self.compare_arrays(w_expected, params['w'])
         self.compare_arrays(dw_expected, grads['dw'])
 
+    def test_predict(self):
+
+        w, b, X, Y = (np.array([[1],[2]]), 2, np.array([[1,2],[3,4]]), np.array([[1,0]]))
+
+        predictions = logistic_regression.predict(w, b, X)
+
+        assert predictions[0][0] == 1
+        assert predictions[0][1] == 1
 
 if __name__ == '__main__':
     unittest.main()