Ejemplo n.º 1
0
 def test_hypothesis_adding(self):
     algebraic_h_1 = AlgebraicHypothesis.AlgebraicHypothesis()
     algebraic_h_1.add_symbol("WeakLearner_1", 0.12, DummyPredictor(100))
     algebraic_h_2 = AlgebraicHypothesis.AlgebraicHypothesis()
     algebraic_h_2.add_symbol("WeakLearner_2", 1, DummyPredictor(13))
     algebraic_h_3 = algebraic_h_1 + algebraic_h_2
     data_width = 100
     self.assertTrue(np.allclose(np.repeat(25, TEST_DATA_LEN),
                                 algebraic_h_3.evaluate(np.random.random((TEST_DATA_LEN, data_width)))))
Ejemplo n.º 2
0
 def test_hypothesis_multiplication(self):
     algebraic_h = AlgebraicHypothesis.AlgebraicHypothesis()
     algebraic_h.add_symbol("WeakLearner_1", 0.12, DummyPredictor(100))
     algebraic_h.add_symbol("WeakLearner_2", 1, DummyPredictor(13))
     algebraic_h *= 10
     data_width = 100
     self.assertTrue(np.allclose(np.repeat(250, TEST_DATA_LEN),
                                 algebraic_h.evaluate(np.random.random((TEST_DATA_LEN, data_width)))))
Ejemplo n.º 3
0
 def test_hypothesis_caching(self):
     data_width = 100
     algebraic_h = AlgebraicHypothesis.AlgebraicHypothesis()
     algebraic_h.add_symbol("WeakLearner_1", 0.12, DummyPredictor(100))
     algebraic_h.evaluate(np.random.random((TEST_DATA_LEN, data_width)), True)
     algebraic_h.add_symbol("WeakLearner_2", 1, DummyPredictor(13))
     self.assertTrue(np.allclose(np.repeat(25, TEST_DATA_LEN),
                                 algebraic_h.evaluate(np.random.random((TEST_DATA_LEN, data_width)))))
Ejemplo n.º 4
0
 def test_cache_clearing(self):
     data_width = 100
     algebraic_h = AlgebraicHypothesis.AlgebraicHypothesis()
     algebraic_h.add_symbol("WeakLearner_1", 0.12, DummyPredictor(100))
     algebraic_h.evaluate(np.random.random((TEST_DATA_LEN, data_width)), True)
     algebraic_h.add_symbol("WeakLearner_2", 1, DummyPredictor(13))
     algebraic_h.evaluate(np.random.random((TEST_DATA_LEN, data_width)))
     algebraic_h.clear_cache()
     self.assertEqual({}, algebraic_h.train_cache)
Ejemplo n.º 5
0
 def test_hypothesis_printing(self):
     algebraic_h = AlgebraicHypothesis.AlgebraicHypothesis()
     algebraic_h.add_symbol("WeakLearner_1", 0.12, None)
     self.assertEqual("Algebraic hypothesis:\nWeakLearner_1 * 0.12 | None", str(algebraic_h))
Ejemplo n.º 6
0
 def test_hypothesis_symbol_adding(self):
     algebraic_h = AlgebraicHypothesis.AlgebraicHypothesis()
     algebraic_h.add_symbol("WeakLearner_1", 0.12, None)
     self.assertEqual(0.12, algebraic_h.symbol_weights["WeakLearner_1"])
     self.assertEqual(None, algebraic_h.symbol_evaluation_scheme["WeakLearner_1"])
Ejemplo n.º 7
0
 def test_creation(self):
     algebraic_h = AlgebraicHypothesis.AlgebraicHypothesis()
     self.assertEqual({}, algebraic_h.symbol_weights)
     self.assertEqual({}, algebraic_h.symbol_evaluation_scheme)