def test_write_q_float(self): expected = "Q16_float_a [16.0, 1024.0] [520.0]" cs = ConfigurationSpace() cs.add_hyperparameter( UniformFloatHyperparameter("float_a", 16, 1024, q=16)) value = pcs.write(cs) self.assertEqual(expected, value)
def test_write_log10(self): expected = "a [10.0, 1000.0] [100.0]l" cs = ConfigurationSpace() cs.add_hyperparameter( UniformFloatHyperparameter("a", 10, 1000, log=True)) value = pcs.write(cs) self.assertEqual(expected, value)
def test_write_log10(self): expected = "a [10.0, 1000.0] [100.0]l" cs = ConfigurationSpace() cs.add_hyperparameter( UniformFloatHyperparameter("a", 10, 1000, log=True)) value = pcs.write(cs) self.assertEqual(expected, value)
def test_write_q_int(self): expected = "Q16_int_a [16, 1024] [520]i" cs = ConfigurationSpace() cs.add_hyperparameter( UniformIntegerHyperparameter("int_a", 16, 1024, q=16)) value = pcs.write(cs) self.assertEqual(expected, value)
def _create_search_space(self, tmp_dir, backend, datamanager, include_estimators=None, exclude_estimators=None, include_preprocessors=None, exclude_preprocessors=None): task_name = 'CreateConfigSpace' self._stopwatch.start_task(task_name) configspace_path = os.path.join(tmp_dir, 'space.pcs') configuration_space = pipeline.get_configuration_space( datamanager.info, include_estimators=include_estimators, exclude_estimators=exclude_estimators, include_preprocessors=include_preprocessors, exclude_preprocessors=exclude_preprocessors) configuration_space = self.configuration_space_created_hook( datamanager, configuration_space) sp_string = pcs.write(configuration_space) backend.write_txt_file(configspace_path, sp_string, 'Configuration space') self._stopwatch.stop_task(task_name) return configuration_space, configspace_path
def test_write_q_float(self): expected = "Q16_float_a [16.0, 1024.0] [520.0]" cs = ConfigurationSpace() cs.add_hyperparameter( UniformFloatHyperparameter("float_a", 16, 1024, q=16)) value = pcs.write(cs) self.assertEqual(expected, value)
def test_write_q_int(self): expected = "Q16_int_a [16, 1024] [520]i" cs = ConfigurationSpace() cs.add_hyperparameter( UniformIntegerHyperparameter("int_a", 16, 1024, q=16)) value = pcs.write(cs) self.assertEqual(expected, value)
def test_build_forbidden(self): expected = "a {a, b, c} [a]\nb {a, b, c} [c]\n\n" \ "{a=a, b=a}\n{a=a, b=b}\n{a=b, b=a}\n{a=b, b=b}" cs = ConfigurationSpace() a = CategoricalHyperparameter("a", ["a", "b", "c"], "a") b = CategoricalHyperparameter("b", ["a", "b", "c"], "c") cs.add_hyperparameter(a) cs.add_hyperparameter(b) fb = ForbiddenAndConjunction(ForbiddenInClause(a, ["a", "b"]), ForbiddenInClause(b, ["a", "b"])) cs.add_forbidden_clause(fb) value = pcs.write(cs) self.assertIn(expected, value)
def test_build_forbidden(self): expected = "a {a, b, c} [a]\nb {a, b, c} [c]\n\n" \ "{a=a, b=a}\n{a=a, b=b}\n{a=b, b=a}\n{a=b, b=b}" cs = ConfigurationSpace() a = CategoricalHyperparameter("a", ["a", "b", "c"], "a") b = CategoricalHyperparameter("b", ["a", "b", "c"], "c") cs.add_hyperparameter(a) cs.add_hyperparameter(b) fb = ForbiddenAndConjunction(ForbiddenInClause(a, ["a", "b"]), ForbiddenInClause(b, ["a", "b"])) cs.add_forbidden_clause(fb) value = pcs.write(cs) self.assertIn(expected, value)
def _create_search_space(self, tmp_dir, backend, datamanager, include_estimators=None, include_preprocessors=None): task_name = 'CreateConfigSpace' self._stopwatch.start_task(task_name) configspace_path = os.path.join(tmp_dir, 'space.pcs') configuration_space = pipeline.get_configuration_space( datamanager.info, include_estimators=include_estimators, include_preprocessors=include_preprocessors) configuration_space = self.configuration_space_created_hook( datamanager, configuration_space) sp_string = pcs.write(configuration_space) backend.write_txt_file(configspace_path, sp_string, 'Configuration space') self._stopwatch.stop_task(task_name) return configuration_space, configspace_path
def test_read_write(self): # Some smoke tests whether reading, writing, reading alters makes the # configspace incomparable this_file = os.path.abspath(__file__) this_directory = os.path.dirname(this_file) configuration_space_path = os.path.join(this_directory, "..", "test_searchspaces") configuration_space_path = os.path.abspath(configuration_space_path) configuration_space_path = os.path.join(configuration_space_path, "spear-params-mixed.pcs") with open(configuration_space_path) as fh: cs = pcs.read(fh) tf = tempfile.NamedTemporaryFile() name = tf.name tf.close() with open(name, 'w') as fh: pcs_string = pcs.write(cs) fh.write(pcs_string) with open(name, 'r') as fh: pcs_new = pcs.read(fh) assert (pcs_new, cs)
def test_read_write(self): # Some smoke tests whether reading, writing, reading alters makes the # configspace incomparable this_file = os.path.abspath(__file__) this_directory = os.path.dirname(this_file) configuration_space_path = os.path.join(this_directory, "..", "test_searchspaces") configuration_space_path = os.path.abspath(configuration_space_path) configuration_space_path = os.path.join(configuration_space_path, "spear-params-mixed.pcs") with open(configuration_space_path) as fh: cs = pcs.read(fh) tf = tempfile.NamedTemporaryFile() name = tf.name tf.close() with open(name, 'w') as fh: pcs_string = pcs.write(cs) fh.write(pcs_string) with open(name, 'r') as fh: pcs_new = pcs.read(fh) assert (pcs_new, cs)
def test_write_log_int(self): expected = "int_log_a [1, 6] [2]il" cs = ConfigurationSpace() cs.add_hyperparameter(int_log_a) value = pcs.write(cs) self.assertEqual(expected, value)
def test_write_log_int(self): expected = "int_log_a [1, 6] [2]il" cs = ConfigurationSpace() cs.add_hyperparameter(int_log_a) value = pcs.write(cs) self.assertEqual(expected, value)