Пример #1
0
class TestEI(unittest.TestCase):
    def setUp(self):
        self.X = np.random.rand(10, 2)
        self.y = np.sinc(self.X * 10 - 5).sum(axis=1)
        self.model = DemoModel()
        self.model.train(self.X, self.y)

    def test_compute(self):
        ei = EI(self.model)

        X_test = np.random.rand(5, 2)
        a = ei.compute(X_test, derivative=False)
        assert a.shape[0] == X_test.shape[0]
        assert len(a.shape) == 1
Пример #2
0
class TestEI(unittest.TestCase):

    def setUp(self):
        self.X = np.random.rand(10, 2)
        self.y = np.sinc(self.X * 10 - 5).sum(axis=1)
        self.model = DemoModel()
        self.model.train(self.X, self.y)

    def test_compute(self):
        ei = EI(self.model)

        X_test = np.random.rand(5, 2)
        a = ei.compute(X_test, derivative=False)
        assert a.shape[0] == X_test.shape[0]
        assert len(a.shape) == 1
Пример #3
0
class TestLCB(unittest.TestCase):

    def setUp(self):
        self.X = np.random.rand(10, 2)
        self.y = np.sinc(self.X * 10 - 5).sum(axis=1)
        self.model = DemoModel()
        self.model.train(self.X, self.y)

    def test_compute(self):
        lcb = LCB(self.model)

        X_test = np.random.rand(5, 2)
        a = lcb.compute(X_test, derivative=False)
        assert a.shape[0] == X_test.shape[0]
        assert len(a.shape) == 1

        np.testing.assert_almost_equal(a, np.ones(X_test.shape[0]) * (- np.mean(self.y) + np.std(self.y)), decimal=3)
Пример #4
0
class TestLCB(unittest.TestCase):
    def setUp(self):
        self.X = np.random.rand(10, 2)
        self.y = np.sinc(self.X * 10 - 5).sum(axis=1)
        self.model = DemoModel()
        self.model.train(self.X, self.y)

    def test_compute(self):
        lcb = LCB(self.model)

        X_test = np.random.rand(5, 2)
        a = lcb.compute(X_test, derivative=False)
        assert a.shape[0] == X_test.shape[0]
        assert len(a.shape) == 1

        np.testing.assert_almost_equal(a,
                                       np.ones(X_test.shape[0]) *
                                       (-np.mean(self.y) + np.std(self.y)),
                                       decimal=3)
Пример #5
0
 def setUp(self):
     self.X = np.random.rand(10, 2)
     self.y = np.sinc(self.X * 10 - 5).sum(axis=1)
     self.model = DemoModel()
     self.model.train(self.X, self.y)
Пример #6
0
 def setUp(self):
     self.X = np.random.rand(10, 2)
     self.y = np.sinc(self.X * 10 - 5).sum(axis=1)
     self.model = DemoModel()
     self.model.train(self.X, self.y)