BayesianOptimization
BayesianOptimization copied to clipboard
Error when running maximize() on custom objective function
When running maximize() I run into this error:
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-173-36ce80c380cc> in <module>()
36 #bo_strat.explore( strat_params_explore )
37
---> 38 bo_strat.maximize(init_points=3, n_iter=15, kappa=2)
~/python/anaconda3510/anaconda3/envs/quant_py364/lib/python3.6/site-packages/bayes_opt/bayesian_optimization.py in maximize(self, init_points, n_iter, acq, kappa, xi, **gp_params)
257 bounds=self.space.bounds,
258 random_state=self.random_state,
--> 259 **self._acqkw)
260
261 # Print new header
~/python/anaconda3510/anaconda3/envs/quant_py364/lib/python3.6/site-packages/bayes_opt/helpers.py in acq_max(ac, gp, y_max, bounds, random_state, n_warmup, n_iter)
61
62 # Store it if better than previous minimum(maximum).
---> 63 if max_acq is None or -res.fun[0] >= max_acq:
64 x_max = res.x
65 max_acq = -res.fun[0]
IndexError: too many indices for array
I should note that the 3 init_points objective function evaluations do in fact work and the results are printed to the screen prior to the above error message
Closing. i figured it out. Not all of my variables' range tuples were of the form (min, max) Some were (max, min). Once I made them all (min, max) it now works.