예제 #1
0
 def test_enum_factorial(self):
     """Tests factorial instantiation through the Models enum."""
     exp = get_factorial_experiment()
     factorial = Models.FACTORIAL(exp.search_space)
     self.assertIsInstance(factorial, DiscreteModelBridge)
     factorial_run = factorial.gen(n=-1)
     self.assertEqual(len(factorial_run.arms), 24)
예제 #2
0
def get_factorial(search_space: SearchSpace) -> DiscreteModelBridge:
    """Instantiates a factorial generator."""
    logger.info(
        "Factory functions (like `get_factorial`) will soon be deprecated). Use "
        "the model registry instead (`Models.FACTORIAL(...)`).")
    return checked_cast(DiscreteModelBridge,
                        Models.FACTORIAL(search_space=search_space))
예제 #3
0
 def test_enum_thompson(self):
     """Tests TS instantiation through the Models enum."""
     exp = get_factorial_experiment()
     factorial = Models.FACTORIAL(exp.search_space)
     self.assertIsInstance(factorial, DiscreteModelBridge)
     factorial_run = factorial.gen(n=-1)
     exp.new_batch_trial().add_generator_run(factorial_run).run().mark_completed()
     data = exp.fetch_data()
     thompson = Models.THOMPSON(experiment=exp, data=data)
     self.assertIsInstance(thompson.model, ThompsonSampler)
예제 #4
0
 def test_enum_empirical_bayes_thompson(self):
     """Tests EB/TS instantiation through the Models enum."""
     exp = get_factorial_experiment()
     factorial = Models.FACTORIAL(exp.search_space)
     self.assertIsInstance(factorial, DiscreteModelBridge)
     factorial_run = factorial.gen(n=-1)
     exp.new_batch_trial().add_generator_run(factorial_run).run().mark_completed()
     data = exp.fetch_data()
     eb_thompson = Models.EMPIRICAL_BAYES_THOMPSON(
         experiment=exp, data=data, min_weight=0.0
     )
     self.assertIsInstance(eb_thompson, DiscreteModelBridge)
     self.assertIsInstance(eb_thompson.model, EmpiricalBayesThompsonSampler)
     thompson_run = eb_thompson.gen(n=5)
     self.assertEqual(len(thompson_run.arms), 5)
예제 #5
0
def get_factorial(search_space: SearchSpace) -> DiscreteModelBridge:
    """Instantiates a factorial generator."""
    return checked_cast(
        DiscreteModelBridge,
        Models.FACTORIAL(search_space=search_space, fit_out_of_design=True),
    )