1

I'm using scikit-optimize to do a BayesSearchCV within my RandomForestClassifier hyperparameter space. One hyperparameter is supposed to also be 0 (zero) while having a log-uniform distribution:

ccp_alpha = Real(min(ccp_alpha), max(ccp_alpha), prior='log-uniform')

Since log(0) is impossible to calculate, it is apparently impossible to have the parameter take the value 0 at some point.

Consequently, the following error is thrown:

ValueError: Not all points are within the bounds of the space.

Is there any way to work around this?

desertnaut
  • 57,590
  • 26
  • 140
  • 166
m3ph
  • 53
  • 6

1 Answers1

0

Note that getting a 0 from a log-uniform distribution is not well defined. How would you normalize this distribution, or in other words what would the odds be of drawing a 0?

The simplest approach would be to yield a list of values to try with the specified distribution. Since the values in this list will be sampled uniformly, you can use any distribution you like. For example with the list

reals = [0,0,0,0,x1,x2,x3,x4] 

wehere x1 to x4 are log-uniformly distributed will give you odds 4 / 8 of drawing a 0, and odds 4 / 8 of drawing a log-uniformly distributed value.

If you really wanted to, you could also implement a class called MyReal (probably subclassed from Real) that implements a rvs method that yields the distribution you want.

user787267
  • 2,550
  • 1
  • 23
  • 32