(self)
| 327 | ) |
| 328 | |
| 329 | def test_optimizer_UCB(self): |
| 330 | for n_samples in range(1, 100): |
| 331 | mean = np.random.rand(n_samples, ) |
| 332 | std = np.random.rand(n_samples, ) |
| 333 | beta = np.random.rand() |
| 334 | |
| 335 | # 1. fitted estimator |
| 336 | mock_estimator = mock.MockEstimator( |
| 337 | predict_return=(mean, std) |
| 338 | ) |
| 339 | optimizer = modAL.models.learners.BayesianOptimizer( |
| 340 | estimator=mock_estimator) |
| 341 | true_UCB = mean + beta*std |
| 342 | |
| 343 | np.testing.assert_almost_equal( |
| 344 | true_UCB, |
| 345 | modAL.acquisition.optimizer_UCB( |
| 346 | optimizer, np.random.rand(n_samples, 2), beta) |
| 347 | ) |
| 348 | |
| 349 | # 2. unfitted estimator |
| 350 | mock_estimator = mock.MockEstimator(fitted=False) |
| 351 | optimizer = modAL.models.learners.BayesianOptimizer( |
| 352 | estimator=mock_estimator) |
| 353 | true_UCB = np.zeros(shape=(len(mean), 1)) + \ |
| 354 | beta * np.ones(shape=(len(mean), 1)) |
| 355 | |
| 356 | np.testing.assert_almost_equal( |
| 357 | true_UCB, |
| 358 | modAL.acquisition.optimizer_UCB( |
| 359 | optimizer, np.random.rand(n_samples, 2), beta) |
| 360 | ) |
| 361 | |
| 362 | def test_selection(self): |
| 363 | for n_samples in range(1, 100): |
nothing calls this directly
no outgoing calls
no test coverage detected