class TestConjunction(unittest.TestCase): def setUp(self): self.conjunction = Conjunction(6) def test_is_function_answering_yes_on_sample__answer_no(self): function = [1, 1, -1, 0, -1, 0] x = [1, 1, 1, 1, -1, 1] self.assertEqual(False, self.conjunction.is_function_answering_yes_on_sample(x, function)) def test_is_function_answering_yes_on_sample__answer_yes(self): function = [1, 1, -1, 0, -1, 0] x = [1, 1, -1, 1, -1, 1] self.assertEqual(True, self.conjunction.is_function_answering_yes_on_sample(x, function)) def test_get_random_false_sample(self): for i in xrange(10000): function = [1, 1, -1, 0, -1, 0] self.conjunction.ideal_function = function sample = self.conjunction.get_random_false_sample() self.assertEqual(False, self.conjunction.is_function_answering_yes_on_sample(sample, function))
class TestConjunction(unittest.TestCase): def setUp(self): self.conjunction = Conjunction(6) def test_is_function_answering_yes_on_sample__answer_no(self): function = [1, 1, -1, 0, -1, 0] x = [1, 1, 1, 1, -1, 1] self.assertEqual( False, self.conjunction.is_function_answering_yes_on_sample(x, function)) def test_is_function_answering_yes_on_sample__answer_yes(self): function = [1, 1, -1, 0, -1, 0] x = [1, 1, -1, 1, -1, 1] self.assertEqual( True, self.conjunction.is_function_answering_yes_on_sample(x, function)) def test_get_random_false_sample(self): for i in xrange(10000): function = [1, 1, -1, 0, -1, 0] self.conjunction.ideal_function = function sample = self.conjunction.get_random_false_sample() self.assertEqual( False, self.conjunction.is_function_answering_yes_on_sample( sample, function))
def main(): length = 10 concept = Conjunction(length) function = concept.get_ideal_function() distribution = UniformDistribution(concept, length) pac_oracle = PAC_Oracle(concept, distribution) pac_alg = PAC_Algorithm(pac_oracle, length) hypo = pac_alg.learn_ideal_function(0.5, 0.1) print "FUNC IS: " + str(function) print "HYPO IS: " + str(hypo)
def rewrite(self): return Conjunction(lhs=Implication(lhs=self.lhs, rhs=self.rhs), rhs=Implication(lhs=self.rhs, rhs=self.lhs))
def setUp(self): self.conjunction = Conjunction(6)