本文整理汇总了Python中ConfigSpace.ConfigurationSpace.check_configuration方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigurationSpace.check_configuration方法的具体用法?Python ConfigurationSpace.check_configuration怎么用?Python ConfigurationSpace.check_configuration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigSpace.ConfigurationSpace
的用法示例。
在下文中一共展示了ConfigurationSpace.check_configuration方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_check_configuration2
# 需要导入模块: from ConfigSpace import ConfigurationSpace [as 别名]
# 或者: from ConfigSpace.ConfigurationSpace import check_configuration [as 别名]
def test_check_configuration2(self):
# Test that hyperparameters which are not active must not be set and
# that evaluating forbidden clauses does not choke on missing
# hyperparameters
cs = ConfigurationSpace()
classifier = CategoricalHyperparameter("classifier",
["k_nearest_neighbors", "extra_trees"])
metric = CategoricalHyperparameter("metric", ["minkowski", "other"])
p = CategoricalHyperparameter("k_nearest_neighbors:p", [1, 2])
metric_depends_on_classifier = EqualsCondition(metric, classifier,
"k_nearest_neighbors")
p_depends_on_metric = EqualsCondition(p, metric, "minkowski")
cs.add_hyperparameter(metric)
cs.add_hyperparameter(p)
cs.add_hyperparameter(classifier)
cs.add_condition(metric_depends_on_classifier)
cs.add_condition(p_depends_on_metric)
forbidden = ForbiddenEqualsClause(metric, "other")
cs.add_forbidden_clause(forbidden)
configuration = Configuration(cs, dict(classifier="extra_trees"))
# check backward compatibility with checking configurations instead of vectors
cs.check_configuration(configuration)
示例2: test_deactivate_inactive_hyperparameters
# 需要导入模块: from ConfigSpace import ConfigurationSpace [as 别名]
# 或者: from ConfigSpace.ConfigurationSpace import check_configuration [as 别名]
def test_deactivate_inactive_hyperparameters(self):
diamond = ConfigurationSpace()
head = CategoricalHyperparameter('head', [0, 1])
left = CategoricalHyperparameter('left', [0, 1])
right = CategoricalHyperparameter('right', [0, 1])
bottom = CategoricalHyperparameter('bottom', [0, 1])
diamond.add_hyperparameters([head, left, right, bottom])
diamond.add_condition(EqualsCondition(left, head, 0))
diamond.add_condition(EqualsCondition(right, head, 0))
diamond.add_condition(AndConjunction(EqualsCondition(bottom, left, 0),
EqualsCondition(bottom, right, 0)))
c = deactivate_inactive_hyperparameters({'head': 0, 'left': 0,
'right': 0, 'bottom': 0},
diamond)
diamond._check_configuration_rigorous(c)
c = deactivate_inactive_hyperparameters({'head': 1, 'left': 0,
'right': 0, 'bottom': 0},
diamond)
diamond._check_configuration_rigorous(c)
c = deactivate_inactive_hyperparameters({'head': 0, 'left': 1,
'right': 0, 'bottom': 0},
diamond)
diamond._check_configuration_rigorous(c)
diamond = ConfigurationSpace()
head = CategoricalHyperparameter('head', [0, 1])
left = CategoricalHyperparameter('left', [0, 1])
right = CategoricalHyperparameter('right', [0, 1])
bottom = CategoricalHyperparameter('bottom', [0, 1])
diamond.add_hyperparameters([head, left, right, bottom])
diamond.add_condition(EqualsCondition(left, head, 0))
diamond.add_condition(EqualsCondition(right, head, 0))
diamond.add_condition(OrConjunction(EqualsCondition(bottom, left, 0),
EqualsCondition(bottom, right, 0)))
c = deactivate_inactive_hyperparameters({'head': 0, 'left': 0,
'right': 0, 'bottom': 0},
diamond)
diamond._check_configuration_rigorous(c)
c = deactivate_inactive_hyperparameters({'head': 1, 'left': 1,
'right': 0, 'bottom': 0},
diamond)
diamond._check_configuration_rigorous(c)
c = deactivate_inactive_hyperparameters({'head': 0, 'left': 1,
'right': 0, 'bottom': 0},
diamond)
diamond._check_configuration_rigorous(c)
plain = ConfigurationSpace()
a = UniformIntegerHyperparameter('a', 0, 10)
b = UniformIntegerHyperparameter('b', 0, 10)
plain.add_hyperparameters([a, b])
c = deactivate_inactive_hyperparameters({'a': 5, 'b': 6}, plain)
plain.check_configuration(c)