예제 #1
0
    def test__acquire_higher_mean_equal_std(self):
        # When the stds are equal but the mean s higher, it is selected

        # Set-up
        tuner = GPEi(tuple(), r_minimum=2)
        tuner.y = np.array([0.5, 0.6, 0.7])

        # Run
        predictions = np.array([[0.8, 1], [0.9, 1]])
        best = tuner._acquire(predictions)

        # assert
        assert best == 1
예제 #2
0
    def test__acquire_best_ei_neq_best_y(self):
        """Best Expected Improvement does NOT correspond to the best prediction."""

        # Set-up
        tuner = GPEi(tuple(), r_minimum=2)
        tuner.y = np.array([0.5, 0.6, 0.7])

        # Run
        predictions = np.array([[0.8, 2], [0.9, 1]])
        best = tuner._acquire(predictions)

        # assert
        assert best == 0
예제 #3
0
    def test__acquire_higher_mean_and_std(self):
        # When both the mean and std of one point is higher, it is selected

        # Set-up
        tuner = GPEi(tuple(), r_minimum=2)
        tuner.y = np.array([0.5, 0.6, 0.7])

        # Run
        predictions = np.array([[0.8, 1], [0.9, 2]])
        best = tuner._acquire(predictions)

        # assert
        assert best == 1
예제 #4
0
 def test_gpei(self):
     X = [{'a': 1.1, 'b': 0.01, 'c': 3.5}, {'a': 4, 'b': 0.001, 'c': 6.2}]
     y = [0.5, 0.6]
     c1 = HyperParameter(ParamTypes.INT, [1, 5])
     c2 = HyperParameter(ParamTypes.FLOAT_EXP, [0.0001, 0.1])
     c3 = HyperParameter(ParamTypes.FLOAT, [2, 8])
     tunables = [('a', c1), ('b', c2), ('c', c3)]
     u = GPEi(tunables)
     u.add(X, y)
     for i in range(100):
         proposed = u.propose()
         self.assertTrue(proposed['a'] >= 1 and proposed['a'] <= 5)
         self.assertTrue(proposed['b'] >= 0.0001 and proposed['b'] <= 0.1)
         self.assertTrue(proposed['c'] >= 2 and proposed['c'] <= 8)
예제 #5
0
파일: test_gp.py 프로젝트: wuqixiaobai/BTB
    def test__acquire_best_ei_neq_best_y(self):
        """Best Expected Improvement does NOT correspond to the best prediction."""

        # Set-up
        tuner = GPEi(tuple(), r_minimum=2)
        tuner.y = np.array([0.5, 0.6, 0.7])

        # Run
        predictions = np.array([
            [0.8, 2],
            [0.9, 1]
        ])
        best = tuner._acquire(predictions)

        # assert
        assert best == 0
예제 #6
0
    def test__acquire_possible_error(self):
        """Manually crafted case that seems to be an error in the formula:

        The second prediction has a higher score and both have the same stdev.
        However, the formula indicates that the first prediction is the best one.
        """

        # Set-up
        tuner = GPEi(tuple(), r_minimum=2)
        tuner.y = np.array([0.5, 0.6, 0.7])

        # Run
        predictions = np.array([[0.8, 1], [0.9, 1]])
        best = tuner._acquire(predictions)

        # assert
        assert best == 0
예제 #7
0
    def test__acquire_lower_mean_higher_std(self):
        # When the mean is higher but the std is lower, both outcomes are possible
        # Create a situation with a much larger std to demonstrate.

        # Set-up
        tuner = GPEi(tuple(), r_minimum=2)
        tuner.y = np.array([0.5, 0.6, 0.7])

        # Run
        predictions = np.array([
            [0.9, 1],
            [0.8, 100],
        ])
        best = tuner._acquire(predictions)

        # assert
        assert best == 1
예제 #8
0
파일: test_gp.py 프로젝트: wuqixiaobai/BTB
    def test__acquire_possible_error(self):
        """Manually crafted case that seems to be an error in the formula:

        The second prediction has a higher score and both have the same stdev.
        However, the formula indicates that the first prediction is the best one.
        """

        # Set-up
        tuner = GPEi(tuple(), r_minimum=2)
        tuner.y = np.array([0.5, 0.6, 0.7])

        # Run
        predictions = np.array([
            [0.8, 1],
            [0.9, 1]
        ])
        best = tuner._acquire(predictions)

        # assert
        assert best == 0