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 Aug 26, 2020
1 parent 3176601 commit 7d84c69
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 @@ -26,22 +26,18 @@ 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))
low=low[i], high=high[i]))

return Space(dimensions)

Expand Down

0 comments on commit 7d84c69

Please sign in to comment.