josejimenezluna / pyGPGO

Bayesian optimization for Python
http://pygpgo.readthedocs.io
MIT License
241 stars 61 forks source link

Parameters specified as "int" are returned as floats #10

Closed richardknudsen closed 5 years ago

richardknudsen commented 6 years ago

Hi,

first - thanks for the nice library!

When I specify a parameter to be an integer, gpgo.run will pass the exploration values as floats which causes problems with some library (e.g. lightgbm). Interestingly, only does so in the exploration but not in the initial phase. Is there some nice way around this?

version: 0.4.0.dev1 system: ubuntu python: anaconda 3.6

example: from pyGPGO.covfunc import squaredExponential from pyGPGO.acquisition import Acquisition from pyGPGO.surrogates.GaussianProcess import GaussianProcess from pyGPGO.GPGO import GPGO import multiprocessing

def func(**params): for k, v in params.items(): print(" ", k, v) return 0.

param_sets = { "learning_rate": ("cont", [0.01, 2]), "num_leaves": ("int", [2, 100]) }

max_iter = 2; init_evals = 2 sexp = squaredExponential() gp = GaussianProcess(sexp) acq = Acquisition("UCB") gpgo = GPGO(gp, acq, func, param_sets, n_jobs=multiprocessing.cpu_count())

gpgo.run(max_iter, init_evals)

output: Evaluation Proposed point Current eval. Best eval. learning_rate 1.5251204907602136 num_leaves 64 learning_rate 0.21636593353219993 num_leaves 30 init [ 1.52512 64. ]. 0.0 0.0 init [ 0.21637 30. ]. 0.0 0.0 learning_rate 0.22181394115246836 num_leaves 7.0 1 [0.22181 7. ]. 0.0 0.0
learning_rate 1.8110339488370346 num_leaves 36.0 2 [ 1.81103 36. ]. 0.0 0.0

josejimenezluna commented 6 years ago

@richardknudsen thanks for noticing this. In the next few days I will make sure these are passed as ints as well.

richardknudsen commented 6 years ago

Nice, thx a lot!

richardknudsen commented 5 years ago

@hawk31 any progress on this?

jamesdj commented 5 years ago

@hawk31 also wondering about this.

dwkwvss commented 5 years ago

Is this repo not maintained anymore? This still seems to be an issue

josejimenezluna commented 5 years ago

Hello @jamesdj @dwkwvss @richardknudsen

Sorry for the delay. Bayesian optimization happens in real space, and at the moment the only alternative I can provide is to make sure they are provided the correct type when returning here:

https://github.com/hawk31/pyGPGO/blob/master/pyGPGO/GPGO.py#L170

fonnesbeck commented 4 years ago

So, there probably isn't any point in having cont and int variables in the parameter dictionary if they are always treated as continuous. Might be simpler to just remove it. Happy do a PR if so.