Created
May 3, 2017 05:40
-
-
Save MechCoder/70a80a933c495d5fcaa06360587b323c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from hpolib.benchmarks.ml import svm_benchmark | |
from ConfigSpace.hyperparameters import FloatHyperparameter, IntegerHyperparameter | |
from skopt import gp_minimize | |
svm_bench = svm_benchmark.SvmOnMnist() | |
bounds = svm_bench.get_meta_information()["bounds"] | |
hyperparams = svm_bench.configuration_space.get_hyperparameters() | |
new_bounds = [] | |
for i, (l_b, u_b) in enumerate(bounds): | |
if isinstance(hyperparams[i], FloatHyperparameter): | |
new_bounds.append([float(l_b), float(u_b)]) | |
elif isinstance(hyperparams[i], IntegerHyperparameter): | |
new_bounds.append([int(l_b), int(u_b)]) | |
def svm_obj(x): | |
res = svm_bench.objective_function(configuration=x) | |
return res["function_value"] | |
res = gp_minimize(svm_obj, new_bounds, verbose=1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment