automl / ConfigSpace

Domain specific language for configuration spaces in Python. Useful for hyperparameter optimization and algorithm configuration.
https://automl.github.io/ConfigSpace/
Other
202 stars 93 forks source link

[Bug] Documentation is confusing #327

Closed Alken0 closed 2 months ago

Alken0 commented 1 year ago

Version: 0.7.2 https://automl.github.io/ConfigSpace/main/guide.html

this is stated on the website:

conf = cs.sample_configuration() conf['max_iter'] = 42 print(conf['max_iter']) 42

but it returns an error - I would have expected it to be possible, to just add a configuration to the config-space but it's only possible for already sampled configurations. This should be clearer written out and not just given indirectly through the code-example before.

eddiebergman commented 2 months ago

Sorry, I'm not sure how that was before but it works as of 1.0.0

import ConfigSpace as CS

cs = CS.ConfigurationSpace(
    {
        "max_iter": (0, 10),
        "upper_bound": (0, 10),
    },
)
conf = cs.sample_configuration()
print(conf)
conf["max_iter"] = 6
print(conf["max_iter"])

# Configuration(values={                                                                                                                                                                          
#   'max_iter': 8,                                                                                                                                                                                
#   'upper_bound': 9,                                                                                                                                                                             
# })                                                                                                                                                                                              
# 6