Skip to content

Commit

Permalink
added support for NORMAL and LOG_NORMAL in hyperopt suggestion service
Browse files Browse the repository at this point in the history
Signed-off-by: Shashank Mittal <[email protected]>
  • Loading branch information
shashank-iitbhu committed Sep 10, 2024
1 parent 08b01ac commit 16dc030
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
34 changes: 30 additions & 4 deletions pkg/suggestion/v1beta1/hyperopt/base_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,36 @@ def create_hyperopt_domain(self):
hyperopt_search_space[param.name] = hyperopt.hp.loguniform(
param.name, float(param.min), float(param.max)
)
# else:
# hyperopt_search_space[param.name] = hyperopt.hp.uniform(
# param.name, float(param.min), float(param.max)
# )
elif param.distribution == api_pb2.NORMAL:
sigma = 1
if param.step:
hyperopt_search_space[param.name] = hyperopt.hp.qnormal(
param.name,
float((float(param.min) + float(param.max)) / 2),
float(sigma),
float(param.step),
)
else:
hyperopt_search_space[param.name] = hyperopt.hp.normal(
param.name,
float((float(param.min) + float(param.max)) / 2),
float(sigma),
)
elif param.distribution == api_pb2.LOG_NORMAL:
sigma = 1
if param.step:
hyperopt_search_space[param.name] = hyperopt.hp.qlognormal(
param.name,
float((float(param.min) + float(param.max)) / 2),
float(sigma),
float(param.step),
)
else:
hyperopt_search_space[param.name] = hyperopt.hp.lognormal(
param.name,
float((float(param.min) + float(param.max)) / 2),
float(sigma),
)
elif param.type == CATEGORICAL or param.type == DISCRETE:
hyperopt_search_space[param.name] = hyperopt.hp.choice(
param.name, param.list
Expand Down
1 change: 0 additions & 1 deletion pkg/suggestion/v1beta1/internal/search_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def convert(experiment):
search_space.goal = constant.MIN_GOAL
for p in experiment.spec.parameter_specs.parameters:
search_space.params.append(HyperParameterSearchSpace.convert_parameter(p))
print(search_space)
return search_space

@staticmethod
Expand Down
12 changes: 12 additions & 0 deletions test/unit/v1beta1/suggestion/test_hyperopt_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,18 @@ def test_get_suggestion(self):
parameter_type=api_pb2.DOUBLE,
feasible_space=api_pb2.FeasibleSpace(
max="10", min="5", list=[], distribution=api_pb2.UNIFORM)
),
api_pb2.ParameterSpec(
name="param-9",
parameter_type=api_pb2.DOUBLE,
feasible_space=api_pb2.FeasibleSpace(
max="10", min="5", list=[], step="0.8", distribution=api_pb2.NORMAL)
),
api_pb2.ParameterSpec(
name="param-10",
parameter_type=api_pb2.DOUBLE,
feasible_space=api_pb2.FeasibleSpace(
max="10", min="5", list=[], step="0.8", distribution=api_pb2.LOG_NORMAL)
)
]
)
Expand Down

0 comments on commit 16dc030

Please sign in to comment.