1. Jure Žbontar
  2. ml

Commits

Jure Žbontar  committed 6ca7d96

Added fit_predict tests.

  • Participants
  • Parent commits 5d94c93
  • Branches default

Comments (0)

Files changed (1)

File ml_test.py

View file
  • Ignore whitespace
         self.model.fit(X, self.y)
         self.assertTrue(np.allclose(self.model.theta, self.theta))
 
+    def test_fit_predict(self):
+        actual = np.array([
+            83.07772773,  162.266873  ,  -93.8332665 ,   61.37261269,
+             6.9702318 ,  -97.32416141,   70.19070473,   44.9641682 ,
+             0.9506707 , -144.63621431])
+
+        predicted = self.model.fit_predict(self.X[10:], self.y[10:], self.X[:10])
+        self.assertTrue(np.allclose(actual, predicted))
+
 
 class TestLogisticRegression(unittest.TestCase):
     def setUp(self):
         self.model.fit(X, self.y)
         self.assertTrue(np.allclose(self.model.theta, self.theta))
 
+    def test_fit_predict(self):
+        actual = np.array([  
+             1.17498491e-04,   9.95826405e-01,   9.98773808e-01,
+             6.62140434e-04,   9.96420564e-01,   2.83732713e-05,
+             9.75252059e-01,   9.99222492e-01,   5.11384091e-01,
+             9.61580190e-02])
+
+        predicted = self.model.fit_predict(self.X[10:], self.y[10:], self.X[:10])
+        self.assertTrue(np.allclose(actual, predicted))
+
 
 class TestMLPClassifier(unittest.TestCase):
     def setUp(self):
         np.random.seed(42)
         self.model.fit(X, self.y)
         self.assertTrue(np.allclose(self.model.thetas, self.thetas))
+
+    def test_fit_predict(self):
+        actual = np.array([
+            [ 0.043719  ,  0.88365249,  0.01329955],
+            [ 0.88940686,  0.03208544,  0.09662599],
+            [ 0.05811965,  0.0844626 ,  0.89265948],
+            [ 0.02997956,  0.08853402,  0.92361998],
+            [ 0.34476473,  0.65574006,  0.00557211],
+            [ 0.88525077,  0.04970321,  0.05099792],
+            [ 0.25361902,  0.83153131,  0.00262188],
+            [ 0.04156667,  0.01631816,  0.88398498],
+            [ 0.83824806,  0.09197702,  0.0310241 ],
+            [ 0.96001685,  0.04271211,  0.02323116]])
+
+        predicted = self.model.fit_predict(self.X[10:], self.y[10:], self.X[:10])
+        self.assertTrue(np.allclose(actual, predicted))