Conditions
ConfigSpace.conditions
#
AndConjunction
#
AndConjunction(*args: Condition | Conjunction)
Bases: Conjunction
The following example shows how two constraints with an AndConjunction can be combined.
from ConfigSpace import (
ConfigurationSpace,
LessThanCondition,
GreaterThanCondition,
AndConjunction
)
cs = ConfigurationSpace({ "a": (5, 15), "b": (0, 10), "c": (0.0, 1.0) })
less_cond = LessThanCondition(cs['c'], cs['a'], 10)
greater_cond = GreaterThanCondition(cs['c'], cs['b'], 5)
cs.add(AndConjunction(less_cond, greater_cond))
print(cs)
PARAMETER | DESCRIPTION |
---|---|
*args |
conditions, which will be combined with an AndConjunction
TYPE:
|
Source code in src/ConfigSpace/conditions.py
BinaryOpCondition
#
BinaryOpCondition(
child: Hyperparameter,
parent: Hyperparameter,
value: Any,
*,
check_condition_legality: bool = True
)
Bases: Condition
This is a base class for conditions that are based on a binary operations.
Source code in src/ConfigSpace/conditions.py
set_vector_idx
#
Sets the index of the hyperparameter for the vectorized form.
This is sort of a second-stage init that is called when a condition is added to the search space.
Source code in src/ConfigSpace/conditions.py
Condition
#
Condition(
child: Hyperparameter,
parent: Hyperparameter,
value: Any,
)
Bases: ABC
Source code in src/ConfigSpace/conditions.py
set_vector_idx
#
Sets the index of the hyperparameter for the vectorized form.
This is sort of a second-stage init that is called when a condition is added to the search space.
Source code in src/ConfigSpace/conditions.py
EqualsCondition
#
EqualsCondition(
child: Hyperparameter,
parent: Hyperparameter,
value: Any,
*,
check_condition_legality: bool = True
)
Bases: BinaryOpCondition
Hyperparameter child
is conditional on the parent
hyperparameter
being equal to value
.
Make b an active hyperparameter if a has the value 1
from ConfigSpace import ConfigurationSpace, EqualsCondition
cs = ConfigurationSpace({ "a": [1, 2, 3], "b": (1.0, 8.0)})
cond = EqualsCondition(cs['b'], cs['a'], 1)
cs.add(cond)
print(cs)
PARAMETER | DESCRIPTION |
---|---|
child |
This hyperparameter will be sampled in the configspace if the equal condition is satisfied
TYPE:
|
parent |
The hyperparameter, which has to satisfy the equal condition
TYPE:
|
value |
Value, which the parent is compared to
TYPE:
|
Source code in src/ConfigSpace/conditions.py
set_vector_idx
#
Sets the index of the hyperparameter for the vectorized form.
This is sort of a second-stage init that is called when a condition is added to the search space.
Source code in src/ConfigSpace/conditions.py
GreaterThanCondition
#
GreaterThanCondition(
child: Hyperparameter,
parent: Hyperparameter,
value: Any,
*,
check_condition_legality: bool = True
)
Bases: BinaryOpCondition
Hyperparameter child
is conditional on the parent
hyperparameter
being greater than value
.
Make b an active hyperparameter if a is greater than 5
from ConfigSpace import ConfigurationSpace, GreaterThanCondition
cs = ConfigurationSpace({ "a": (0, 10), "b": (1.0, 8.0) }) cond = GreaterThanCondition(cs['b'], cs['a'], 5) cs.add(cond) print(cs) ```
Args: child: This hyperparameter will be sampled in the configspace, if the GreaterThanCondition is satisfied parent: The hyperparameter, which has to satisfy the GreaterThanCondition value: Value, which the parent is compared to
Source code in src/ConfigSpace/conditions.py
set_vector_idx
#
Sets the index of the hyperparameter for the vectorized form.
This is sort of a second-stage init that is called when a condition is added to the search space.
Source code in src/ConfigSpace/conditions.py
InCondition
#
InCondition(
child: Hyperparameter,
parent: Hyperparameter,
values: list[Any],
)
Bases: Condition
Hyperparameter child
is conditional on the parent
hyperparameter
being in a set of values
.
make b an active hyperparameter if a is in the set [1, 2, 3, 4]
from ConfigSpace import ConfigurationSpace, InCondition
cs = ConfigurationSpace({ "a": (0, 10), "b": (1.0, 8.0) })
cond = InCondition(cs['b'], cs['a'], [1, 2, 3, 4])
cs.add(cond)
print(cs)
PARAMETER | DESCRIPTION |
---|---|
child |
This hyperparameter will be sampled in the configspace, if the InCondition is satisfied
TYPE:
|
parent |
The hyperparameter, which has to satisfy the InCondition
TYPE:
|
values |
Collection of values, which the parent is compared to |
Source code in src/ConfigSpace/conditions.py
set_vector_idx
#
Sets the index of the hyperparameter for the vectorized form.
This is sort of a second-stage init that is called when a condition is added to the search space.
Source code in src/ConfigSpace/conditions.py
LessThanCondition
#
LessThanCondition(
child: Hyperparameter,
parent: Hyperparameter,
value: Any,
*,
check_condition_legality: bool = True
)
Bases: BinaryOpCondition
Hyperparameter child
is conditional on the parent
hyperparameter
being less than value
.
Make b an active hyperparameter if a is less than 5
from ConfigSpace import ConfigurationSpace, LessThanCondition
cs = ConfigurationSpace({ "a": (0, 10), "b": (1.0, 8.0) })
cond = LessThanCondition(cs['b'], cs['a'], 5)
cs.add(cond)
print(cs)
PARAMETER | DESCRIPTION |
---|---|
child |
This hyperparameter will be sampled in the configspace, if the LessThanCondition is satisfied
TYPE:
|
parent |
The hyperparameter, which has to satisfy the LessThanCondition
TYPE:
|
value |
Value, which the parent is compared to
TYPE:
|
Source code in src/ConfigSpace/conditions.py
set_vector_idx
#
Sets the index of the hyperparameter for the vectorized form.
This is sort of a second-stage init that is called when a condition is added to the search space.
Source code in src/ConfigSpace/conditions.py
NotEqualsCondition
#
NotEqualsCondition(
child: Hyperparameter,
parent: Hyperparameter,
value: Any,
*,
check_condition_legality: bool = True
)
Bases: BinaryOpCondition
Hyperparameter child
is conditional on the parent
hyperparameter
being not equal to value
.
Make b an active hyperparameter if a has not the value 1
from ConfigSpace import ConfigurationSpace, NotEqualsCondition
cs = ConfigurationSpace({ "a": [1, 2, 3], "b": (1.0, 8.0) })
cond = NotEqualsCondition(cs['b'], cs['a'], 1)
cs.add(cond)
print(cs)
PARAMETER | DESCRIPTION |
---|---|
child |
This hyperparameter will be sampled in the configspace if the not-equals condition is satisfied
TYPE:
|
parent |
The hyperparameter, which has to satisfy the not equal condition
TYPE:
|
value |
Value, which the parent is compared to
TYPE:
|
Source code in src/ConfigSpace/conditions.py
set_vector_idx
#
Sets the index of the hyperparameter for the vectorized form.
This is sort of a second-stage init that is called when a condition is added to the search space.
Source code in src/ConfigSpace/conditions.py
OrConjunction
#
Bases: Conjunction
Similar to the AndConjunction, constraints can be combined by using the OrConjunction.
from ConfigSpace import (
ConfigurationSpace,
LessThanCondition,
GreaterThanCondition,
OrConjunction
)
cs = ConfigurationSpace({ "a": (5, 15), "b": (0, 10), "c": (0.0, 1.0) })
less_cond = LessThanCondition(cs['c'], cs['a'], 10)
greater_cond = GreaterThanCondition(cs['c'], cs['b'], 5)
cs.add(OrConjunction(less_cond, greater_cond))
print(cs)
PARAMETER | DESCRIPTION |
---|---|
*args |
conditions, which will be combined with an OrConjunction.
TYPE:
|