ConfigSpace icon indicating copy to clipboard operation
ConfigSpace copied to clipboard

Allow for hyperparameter sampling without an explicit random state required.

Open eddiebergman opened this issue 3 years ago • 2 comments

In theory, I don't see why this shouldn't be possible other than it adds an if check to the sample which may be a speed thing? In general, it would be also nice to have some documentation listed somewhere that motivates the decision for Cython as it makes it scary to change as I'm not sure where the bottleneck of things occur or how to benchmark it.

from ConfigSpace import UniformIntegerHyperparameter

u = UniformIntegerHyperparameter("u", 1, 10)
u.sample()  # TypeError sample() takes exactly one argument (0 given)
# hyperparameters.pyx

class HyperParameter:
    
    def sample(self, rs: RandomState):
        v = self._sample(rs)
        ...

class UniformIntegerHyperparameter:
    
    def _sample(self, rs: RandomState, size: int | None):
       ...  
      

eddiebergman avatar Jun 28 '22 10:06 eddiebergman

I usually use https://github.com/automl/ConfigSpace/blob/master/scripts/benchmark_sampling.py to benchmark changes. Probably we should improve that script and document how to use it.

mfeurer avatar Jun 30 '22 08:06 mfeurer

Now possible in #346

eddiebergman avatar Apr 16 '24 18:04 eddiebergman