Ejemplo n.º 1
0
    def test_GPKG(self):
        """Tests GPKG instantiation."""
        exp = get_branin_experiment(with_batch=True)
        with self.assertRaises(ValueError):
            get_GPKG(experiment=exp, data=exp.fetch_data())
        exp.trials[0].run()
        gpkg = get_GPKG(experiment=exp, data=exp.fetch_data())
        self.assertIsInstance(gpkg, TorchModelBridge)

        # test transform_configs with winsorization
        configs = {
            "Winsorize": {
                "winsorization_lower": 0.1,
                "winsorization_upper": 0.1
            }
        }
        gpkg_win = get_GPKG(experiment=exp,
                            data=exp.fetch_data(),
                            transform_configs=configs)
        self.assertIsInstance(gpkg_win, TorchModelBridge)
        self.assertEqual(gpkg_win._transform_configs, configs)

        # test multi-fidelity optimization
        exp.parameters["x2"] = RangeParameter(
            name="x2",
            parameter_type=exp.parameters["x2"].parameter_type,
            lower=-5.0,
            upper=10.0,
            is_fidelity=True,
            target_value=10.0,
        )
        gpkg_mf = get_GPKG(experiment=exp, data=exp.fetch_data())
        self.assertIsInstance(gpkg_mf, TorchModelBridge)
Ejemplo n.º 2
0
 def test_GPKG(self):
     """Tests GPKG instantiation."""
     exp = get_branin_experiment(with_batch=True)
     with self.assertRaises(ValueError):
         get_GPKG(experiment=exp, data=exp.fetch_data())
     exp.trials[0].run()
     gpkg = get_GPKG(experiment=exp, data=exp.fetch_data())
     self.assertIsInstance(gpkg, TorchModelBridge)
     gpkg_win = get_GPKG(experiment=exp,
                         data=exp.fetch_data(),
                         winsorization_limits=[0.1, 0.1])
     self.assertIsInstance(gpkg_win, TorchModelBridge)
     configs_expected = {
         "Winsorize": {
             "winsorization_lower": 0.1,
             "winsorization_upper": 0.1
         }
     }
     self.assertEqual(gpkg_win._transform_configs, configs_expected)
Ejemplo n.º 3
0
    def test_GPKG(self):
        """Tests GPKG instantiation."""
        exp = get_branin_experiment(with_batch=True)
        with self.assertRaises(ValueError):
            get_GPKG(experiment=exp, data=exp.fetch_data())
        exp.trials[0].run().mark_completed()
        gpkg = get_GPKG(experiment=exp, data=exp.fetch_data())
        self.assertIsInstance(gpkg, TorchModelBridge)

        # Check that .gen returns without failure
        gr = gpkg.gen(n=1)
        self.assertEqual(len(gr.arms), 1)

        # test transform_configs with winsorization
        configs = {
            "Winsorize": {
                "winsorization_config": WinsorizationConfig(
                    lower_quantile_margin=0.1,
                    upper_quantile_margin=0.1,
                )
            }
        }
        gpkg_win = get_GPKG(
            experiment=exp, data=exp.fetch_data(), transform_configs=configs
        )
        self.assertIsInstance(gpkg_win, TorchModelBridge)
        self.assertEqual(gpkg_win._transform_configs, configs)

        # test multi-fidelity optimization
        exp.parameters["x2"] = RangeParameter(
            name="x2",
            parameter_type=exp.parameters["x2"].parameter_type,
            lower=-5.0,
            upper=10.0,
            is_fidelity=True,
            target_value=10.0,
        )
        gpkg_mf = get_GPKG(experiment=exp, data=exp.fetch_data())
        self.assertIsInstance(gpkg_mf, TorchModelBridge)