bayesian-optimization / BayesianOptimization

A Python implementation of global optimization with gaussian processes.
https://bayesian-optimization.github.io/BayesianOptimization/index.html
MIT License
7.81k stars 1.53k forks source link

new failure in regular test #306

Closed microprediction closed 2 years ago

microprediction commented 2 years ago

Hello, I just noticed some new failures in tests I run. Perhaps this trace is useful. For me things are working on 3.7 tests but not 3.8. Peter

    # Warm up with random points
    x_tries = random_state.uniform(bounds[:, 0], bounds[:, 1],
                                   size=(n_warmup, bounds.shape[0]))
    ys = ac(x_tries, gp=gp, y_max=y_max)
    x_max = x_tries[ys.argmax()]
    max_acq = ys.max()

    # Explore the parameter space more throughly
    x_seeds = random_state.uniform(bounds[:, 0], bounds[:, 1],
                                   size=(n_iter, bounds.shape[0]))
    for x_try in x_seeds:
        # Find the minimum of minus the acquisition function
        res = minimize(lambda x: -ac(x.reshape(1, -1), gp=gp, y_max=y_max),
                       x_try.reshape(1, -1),
                       bounds=bounds,
                       method="L-BFGS-B")

        # See if success
        if not res.success:
            continue

        # Store it if better than previous minimum(maximum).
      if max_acq is None or -res.fun[0] >= max_acq:

E TypeError: 'float' object is not subscriptable

/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/bayes_opt/util.py:65: TypeError

During handling of the above exception, another exception occurred:

def test_portfolio():
    n_trials = 10
    for n_dim in [2,3]:
        for optimizer in OPTIMIZERS:
            objective = random.choice(PORTFOLIO_OBJECTIVES)
            try:
                optimizer(objective, n_trials=n_trials,n_dim=n_dim,with_count=True)
            except Exception as e:
                print(e)
              raise Exception(optimizer.__name__ + ' fails on ' + objective.__name__)

E Exception: bayesopt_ucb_cube fails on markowitz_analytic_on_cube

tests/test_portfolio.py:16: Exception ----------------------------- Captured stdout call ----------------------------- 'float' object is not subscriptable =============================== warnings summary =============================== ../../../../../opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/past/builtins/misc.py:45 /opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/past/builtins/misc.py:45: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses from imp import reload

tests/test_elo_optimizers.py: 2 warnings tests/test_optimizers.py: 7 warnings tests/test_portfolio.py: 7 warnings /opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/nevergrad/parametrization/_datalayers.py:107: NevergradRuntimeWarning: Bounds are 1.0 sigma away from each other at the closest, you should aim for at least 3 for better quality. warnings.warn(

tests/test_elo_optimizers.py::test_elo_optim tests/test_optimizers.py::test_compendium tests/test_portfolio.py::test_portfolio /opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/bayes_opt/target_space.py:49: DeprecationWarning: np.float is a deprecated alias for the builtin float. To silence this warning, use float by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use np.float64 here. Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations dtype=np.float

tests/test_elo_optimizers.py::test_elo_optim tests/test_optimizers.py::test_compendium tests/test_portfolio.py::test_portfolio /home/runner/work/humpday/humpday/humpday/optimizers/scipycube.py:29: OptimizeWarning: Unknown solver options: method, maxfev result = minimize(_objective, x0=[0]*n_dim, method=options['method'],bounds=bounds, options=options)

tests/test_optimizers.py::test_compendium tests/test_portfolio.py::test_portfolio /home/runner/work/humpday/humpday/humpday/optimizers/scipycube.py:29: OptimizeWarning: Unknown solver options: method result = minimize(_objective, x0=[0]*n_dim, method=options['method'],bounds=bounds, options=options)

microprediction commented 2 years ago

Ah never mind this is https://github.com/fmfn/BayesianOptimization/issues/300