Skip to content

How to update/delete a Hyperparameter from ConfigSpace? #296

@Doglovesfish

Description

@Doglovesfish

1.I want to update a Hyperparameter from ConfigSpace. Is there any API to do update/delete a Hyperparameter from ConfigSpace?

2.I also found that add_hyperparameters can't override the existed Hyperparameter. If I want to change upper and lower, I have to do this like

    hp = cs.get_hyperparameter(hp_name)
    hp.lower = 180
    hp.upper = 181
    hp.default_value = 180

In this way, a bug might occur. The following code cannot be executed:

from ConfigSpace import ConfigurationSpace, ForbiddenEqualsClause
from ConfigSpace import UniformIntegerHyperparameter


def get_configspace():
    cs = ConfigurationSpace()
    hp_name = 'cpu_num'
    hp_a = UniformIntegerHyperparameter(hp_name, 1, 10, default_value=6)
    cs.add_hyperparameter(hp_a)

    # change cs
    hp = cs.get_hyperparameter(hp_name)
    hp.lower = 180
    hp.upper = 200
    hp.default_value = 190

    # check
    print(cs)
    print(cs["cpu_num"])

    config = cs.sample_configuration()
    print(config)

    forbidden_clause_a = ForbiddenEqualsClause(cs[hp_name], 181)
    cs.add_forbidden_clause(forbidden_clause_a)


if __name__ == '__main__':
    cs = get_configspace()

image

image

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions