def test_performance_with_tolerance(length):
    concept_class = MonotoneConjunction(length)

    performance = PerformanceOracle(concept_class, 100)
    performance_with_tolerance = PerformanceOracleWithTolerance(concept_class, 0)

    random_func = tuple([choice([0, 1]) for _ in xrange(length)])
    print performance.get_estimated_performance(random_func)
    print performance_with_tolerance.get_estimated_performance(random_func)
    print
Esempio n. 2
0
def test_performance_with_tolerance(length):
    concept_class = MonotoneConjunction(length)

    performance = PerformanceOracle(concept_class, 100)
    performance_with_tolerance = PerformanceOracleWithTolerance(
        concept_class, 0)

    random_func = tuple([choice([0, 1]) for _ in xrange(length)])
    print performance.get_estimated_performance(random_func)
    print performance_with_tolerance.get_estimated_performance(random_func)
    print
def check_high_perf():
    length = 40
    concept_class = MonotoneConjunction(length)
    perf = PerformanceOracleWithTolerance(concept_class, 0)

    highest_perf_except_for_1 = 0
    for i in xrange(10000000):
        rep = tuple([choice([0, 1]) for _ in xrange(length)])

        current_perf = perf.get_estimated_performance(rep)

        if current_perf != 1:
            highest_perf_except_for_1 = max(highest_perf_except_for_1, current_perf)

    print highest_perf_except_for_1
def check_high_perf():
    length = 40
    concept_class = MonotoneConjunction(length)
    perf = PerformanceOracleWithTolerance(concept_class, 0)

    highest_perf_except_for_1 = 0
    for i in xrange(10000000):
        rep = tuple([choice([0, 1]) for _ in xrange(length)])

        current_perf = perf.get_estimated_performance(rep)

        if current_perf != 1:
            highest_perf_except_for_1 = max(highest_perf_except_for_1, current_perf)

    print highest_perf_except_for_1
class TestPerformanceOracleWithTolerance(unittest.TestCase):
    def setUp(self):
        self.tolerance_param = 0.00001
        self.concept_class = Mock()
        self.perf = PerformanceOracleWithTolerance(self.concept_class, self.tolerance_param)

    def test_one_perf_example(self):

        self.concept_class.ideal_function = (0, 1, 0, 0, 1)

        self.assertAlmostEqual(0.125 * 6, self.perf.get_estimated_performance((0, 0, 1, 0, 1)),
                               delta=self.tolerance_param)
class TestPerformanceOracleWithTolerance(unittest.TestCase):
    def setUp(self):
        self.tolerance_param = 0.00001
        self.concept_class = Mock()
        self.perf = PerformanceOracleWithTolerance(self.concept_class,
                                                   self.tolerance_param)

    def test_one_perf_example(self):

        self.concept_class.ideal_function = (0, 1, 0, 0, 1)

        self.assertAlmostEqual(0.125 * 6,
                               self.perf.get_estimated_performance(
                                   (0, 0, 1, 0, 1)),
                               delta=self.tolerance_param)
 def setUp(self):
     self.tolerance_param = 0.00001
     self.concept_class = Mock()
     self.perf = PerformanceOracleWithTolerance(self.concept_class, self.tolerance_param)
 def setUp(self):
     self.tolerance_param = 0.00001
     self.concept_class = Mock()
     self.perf = PerformanceOracleWithTolerance(self.concept_class,
                                                self.tolerance_param)
 def get_perf_without_precomp(self, concept_class):
     return PerformanceOracleWithTolerance(concept_class, self.tau)