Skip to content

Commit

Permalink
Use new interval() of categorical
Browse files Browse the repository at this point in the history
Why:

Categorical used to return the categories even when there was a one-hot
encoding of it. Since PR Epistimio/orion#447,
the one-hot transformer now returns the proper interval in (0, 1) in
vector of the size equal to number of dimensions.
  • Loading branch information
bouthilx committed Dec 4, 2020
1 parent 8806ec3 commit 2647410
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/orion/algo/skopt/bayes.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,17 @@ def orion_space_to_skopt_space(orion_space):
"""Convert Oríon's definition of problem's domain to a skopt compatible."""
dimensions = []
for key, dimension in orion_space.items():
# low = dimension._args[0]
# high = low + dimension._args[1]
low, high = dimension.interval()
# NOTE: A hack, because orion priors have non-inclusive higher bound
# while scikit-optimizer have inclusive ones.
# pylint: disable = assignment-from-no-return
high = numpy.nextafter(high, high - 1)
shape = dimension.shape
assert not shape or len(shape) == 1
if not shape:
shape = (1,)
low = (low,)
high = (high,)
# Unpack dimension
for i in range(shape[0]):
dimensions.append(
Real(name=key + "_" + str(i), prior="uniform", low=low, high=high)
Real(name=key + "_" + str(i), prior="uniform", low=low[i], high=high[i])
)

return Space(dimensions)
Expand Down

0 comments on commit 2647410

Please sign in to comment.