コード例 #1
0
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))
コード例 #2
0
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))
コード例 #3
0
ファイル: main.py プロジェクト: SaintDevilS/LearningModels
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)
コード例 #4
0
 def setUp(self):
     self.conjunction = Conjunction(6)
コード例 #5
0
 def setUp(self):
     self.conjunction = Conjunction(6)