Skip to content

Commit 0ad578f

Browse files
committed
Bug fix for containers and fidelity space
1 parent fd25d57 commit 0ad578f

File tree

14 files changed

+44
-82
lines changed

14 files changed

+44
-82
lines changed

hpobench/benchmarks/ml/__init__.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
1-
from hpobench.benchmarks.ml.histgb_benchmark import HistGBBenchmark, HistGBBenchmarkBB, HistGBBenchmarkMF
21
from hpobench.benchmarks.ml.lr_benchmark import LRBenchmark, LRBenchmarkBB, LRBenchmarkMF
32
from hpobench.benchmarks.ml.nn_benchmark import NNBenchmark, NNBenchmarkBB, NNBenchmarkMF
43
from hpobench.benchmarks.ml.rf_benchmark import RandomForestBenchmark, RandomForestBenchmarkBB, \
54
RandomForestBenchmarkMF
65
from hpobench.benchmarks.ml.svm_benchmark import SVMBenchmark, SVMBenchmarkBB, SVMBenchmarkMF
76
from hpobench.benchmarks.ml.tabular_benchmark import TabularBenchmark
87

8+
99
try:
10+
# `xgboost` is from https://xgboost.readthedocs.io/en/latest/install.html#conda
11+
# and not part of the scikit-learn bundle and not a strict requirement for running HPOBench
12+
# for other spaces and also for tabular benchmarks
1013
from hpobench.benchmarks.ml.xgboost_benchmark import XGBoostBenchmark, XGBoostBenchmarkBB, XGBoostBenchmarkMF
11-
except ImportError:
12-
pass
13-
14-
15-
__all__ = ['HistGBBenchmark', 'HistGBBenchmarkBB', 'HistGBBenchmarkMF',
16-
'LRBenchmark', 'LRBenchmarkBB', 'LRBenchmarkMF',
17-
'NNBenchmark', 'NNBenchmarkBB', 'NNBenchmarkMF',
18-
'RandomForestBenchmark', 'RandomForestBenchmarkBB', 'RandomForestBenchmarkMF',
19-
'SVMBenchmark', 'SVMBenchmarkBB', 'SVMBenchmarkMF',
20-
'TabularBenchmark',
21-
'XGBoostBenchmark', 'XGBoostBenchmarkBB', 'XGBoostBenchmarkMF',
22-
]
14+
__all__ = [
15+
'LRBenchmark', 'LRBenchmarkBB', 'LRBenchmarkMF',
16+
'NNBenchmark', 'NNBenchmarkBB', 'NNBenchmarkMF',
17+
'RandomForestBenchmark', 'RandomForestBenchmarkBB', 'RandomForestBenchmarkMF',
18+
'SVMBenchmark', 'SVMBenchmarkBB', 'SVMBenchmarkMF',
19+
'XGBoostBenchmark', 'XGBoostBenchmarkBB', 'XGBoostBenchmarkMF',
20+
'TabularBenchmark',
21+
]
22+
except (ImportError, AttributeError) as e:
23+
__all__ = [
24+
'LRBenchmark', 'LRBenchmarkBB', 'LRBenchmarkMF',
25+
'NNBenchmark', 'NNBenchmarkBB', 'NNBenchmarkMF',
26+
'RandomForestBenchmark', 'RandomForestBenchmarkBB', 'RandomForestBenchmarkMF',
27+
'SVMBenchmark', 'SVMBenchmarkBB', 'SVMBenchmarkMF',
28+
'TabularBenchmark',
29+
]

hpobench/benchmarks/ml/lr_benchmark.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def get_configuration_space(seed: Union[int, None] = None) -> CS.ConfigurationSp
5353
return cs
5454

5555
@staticmethod
56-
def get_fidelity_space(self, seed: Union[int, None] = None) -> CS.ConfigurationSpace:
56+
def get_fidelity_space(seed: Union[int, None] = None) -> CS.ConfigurationSpace:
5757
fidelity_space = CS.ConfigurationSpace(seed=seed)
5858
fidelity_space.add_hyperparameters(
5959
# gray-box setting (multi-multi-fidelity) - iterations + data subsample
@@ -285,7 +285,8 @@ def _train_objective(
285285
class LRBenchmarkBB(LRBenchmark):
286286
""" Black-box version of the LRBenchmark
287287
"""
288-
def get_fidelity_space(self, seed: Union[int, None] = None) -> CS.ConfigurationSpace:
288+
@staticmethod
289+
def get_fidelity_space(seed: Union[int, None] = None) -> CS.ConfigurationSpace:
289290
fidelity_space = CS.ConfigurationSpace(seed=seed)
290291
fidelity_space.add_hyperparameters(
291292
# black-box setting (full fidelity)
@@ -297,7 +298,8 @@ def get_fidelity_space(self, seed: Union[int, None] = None) -> CS.ConfigurationS
297298
class LRBenchmarkMF(LRBenchmark):
298299
""" Multi-fidelity version of the LRBenchmark
299300
"""
300-
def get_fidelity_space(self, seed: Union[int, None] = None) -> CS.ConfigurationSpace:
301+
@staticmethod
302+
def get_fidelity_space(seed: Union[int, None] = None) -> CS.ConfigurationSpace:
301303
fidelity_space = CS.ConfigurationSpace(seed=seed)
302304
fidelity_space.add_hyperparameters(
303305
# gray-box setting (multi-fidelity) - iterations

hpobench/benchmarks/ml/nn_benchmark.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ def _train_objective(
293293
class NNBenchmarkBB(NNBenchmark):
294294
""" Black-box version of the NNBenchmark
295295
"""
296-
def get_fidelity_space(self, seed: Union[int, None] = None) -> CS.ConfigurationSpace:
296+
@staticmethod
297+
def get_fidelity_space(seed: Union[int, None] = None) -> CS.ConfigurationSpace:
297298
fidelity_space = CS.ConfigurationSpace(seed=seed)
298299
fidelity_space.add_hyperparameters(
299300
# black-box setting (full fidelity)
@@ -305,7 +306,8 @@ def get_fidelity_space(self, seed: Union[int, None] = None) -> CS.ConfigurationS
305306
class NNBenchmarkMF(NNBenchmark):
306307
""" Multi-fidelity version of the NNBenchmark
307308
"""
308-
def get_fidelity_space(self, seed: Union[int, None] = None) -> CS.ConfigurationSpace:
309+
@staticmethod
310+
def get_fidelity_space(seed: Union[int, None] = None) -> CS.ConfigurationSpace:
309311
fidelity_space = CS.ConfigurationSpace(seed=seed)
310312
fidelity_space.add_hyperparameters(
311313
# gray-box setting (multi-fidelity) - iterations

hpobench/benchmarks/ml/rf_benchmark.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ def _train_objective(
284284
class RandomForestBenchmarkBB(RandomForestBenchmark):
285285
""" Black-box version of the RandomForestBenchmark
286286
"""
287-
def get_fidelity_space(self, seed: Union[int, None] = None) -> CS.ConfigurationSpace:
287+
@staticmethod
288+
def get_fidelity_space(seed: Union[int, None] = None) -> CS.ConfigurationSpace:
288289
fidelity_space = CS.ConfigurationSpace(seed=seed)
289290
fidelity_space.add_hyperparameters(
290291
# black-box setting (full fidelity)
@@ -298,7 +299,8 @@ def get_fidelity_space(self, seed: Union[int, None] = None) -> CS.ConfigurationS
298299
class RandomForestBenchmarkMF(RandomForestBenchmark):
299300
""" Multi-fidelity version of the RandomForestBenchmark
300301
"""
301-
def get_fidelity_space(self, seed: Union[int, None] = None) -> CS.ConfigurationSpace:
302+
@staticmethod
303+
def get_fidelity_space(seed: Union[int, None] = None) -> CS.ConfigurationSpace:
302304
fidelity_space = CS.ConfigurationSpace(seed=seed)
303305
fidelity_space.add_hyperparameters(
304306
# gray-box setting (multi-fidelity) - ntrees

hpobench/benchmarks/ml/svm_benchmark.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ def get_model_size(self, model: SVC) -> float:
110110
class SVMBenchmarkBB(SVMBenchmark):
111111
""" Black-box version of the SVMBenchmark
112112
"""
113-
def get_fidelity_space(self, seed: Union[int, None] = None) -> CS.ConfigurationSpace:
113+
@staticmethod
114+
def get_fidelity_space(seed: Union[int, None] = None) -> CS.ConfigurationSpace:
114115
fidelity_space = CS.ConfigurationSpace(seed=seed)
115116
fidelity_space.add_hyperparameter(
116117
# uses the entire data (subsample=1), reflecting the black-box setup

hpobench/benchmarks/ml/xgboost_benchmark.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ def get_model_size(self, model: xgb.XGBClassifier) -> float:
144144
class XGBoostBenchmarkBB(XGBoostBenchmark):
145145
""" Black-box version of the XGBoostBenchmark
146146
"""
147-
def get_fidelity_space(self, seed: Union[int, None] = None) -> CS.ConfigurationSpace:
147+
@staticmethod
148+
def get_fidelity_space(seed: Union[int, None] = None) -> CS.ConfigurationSpace:
148149
fidelity_space = CS.ConfigurationSpace(seed=seed)
149150
fidelity_space.add_hyperparameters(
150151
# black-box setting (full fidelity)
@@ -158,7 +159,8 @@ def get_fidelity_space(self, seed: Union[int, None] = None) -> CS.ConfigurationS
158159
class XGBoostBenchmarkMF(XGBoostBenchmark):
159160
""" Multi-fidelity version of the XGBoostBenchmark
160161
"""
161-
def get_fidelity_space(self, seed: Union[int, None] = None) -> CS.ConfigurationSpace:
162+
@staticmethod
163+
def get_fidelity_space(seed: Union[int, None] = None) -> CS.ConfigurationSpace:
162164
fidelity_space = CS.ConfigurationSpace(seed=seed)
163165
fidelity_space.add_hyperparameters(
164166
# gray-box setting (multi-fidelity) - ntrees

hpobench/container/benchmarks/ml/lr_benchmark.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from hpobench.container.client_abstract_benchmark import AbstractBenchmarkClient
77

88

9-
container_name = "ml_mfbb"
9+
container_name = "ml_mmfb"
1010
container_version = "0.0.3"
1111

1212

hpobench/container/benchmarks/ml/nn_benchmark.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from hpobench.container.client_abstract_benchmark import AbstractBenchmarkClient
77

88

9-
container_name = "ml_mfbb"
9+
container_name = "ml_mmfb"
1010
container_version = "0.0.3"
1111

1212

hpobench/container/benchmarks/ml/rf_benchmark.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from hpobench.container.client_abstract_benchmark import AbstractBenchmarkClient
77

88

9-
container_name = "ml_mfbb"
9+
container_name = "ml_mmfb"
1010
container_version = "0.0.3"
1111

1212

hpobench/container/benchmarks/ml/svm_benchmark.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from hpobench.container.client_abstract_benchmark import AbstractBenchmarkClient
77

88

9-
container_name = "ml_mfbb"
9+
container_name = "ml_mmfb"
1010
container_version = "0.0.3"
1111

1212

0 commit comments

Comments
 (0)