Skip to content
This repository was archived by the owner on Feb 28, 2024. It is now read-only.
This repository was archived by the owner on Feb 28, 2024. It is now read-only.

Different results across platforms / python versions #916

Description

@TaigoFr

Bug

On running the example code for bayesian optimization with gp_minimize (https://scikit-optimize.github.io/stable/auto_examples/bayesian-optimization.html) I get inconsistent results with different (stable) python versions and in different machines. It's not machine precision errors, these are dramatic differences.
Correct Results: MacOs - all python versions seem to work; Ubuntu - tested python 2.7 (scikit-learn 0.20.4, scikit-optimize 0.7.4) and 3.6 (scikit-learn 0.20.2, scikit-optimize 0.7.4) and it works
Incorrect Results: Ubuntu - tested python 3.7.5 and 3.8.0 and 3.8.3 (all with scikit-learn 0.23.1, scikit-optimize 0.7.4) and they give wrong results (consistently different among them)

I'm assuming this might not be a generic problem in Ubuntu, but for me it is. My fear is if this is some problem deep down in BLAS/LAPACK algebra libraries with some ill-conditioning going on, but I'm hoping someone might have some idea of what is going on. Or maybe something simpler as the sklearn version.

Steps to Reproduce

  1. Download the example python source code from https://scikit-optimize.github.io/stable/auto_examples/bayesian-optimization.html
  2. run it with python 3.7 or 3.8 in a Ubuntu (again, I tested with 3.7.5, 3.8.0 and 3.8.3)

Platform:
Ubuntu 18.04.4 LTS 64-bit 16GB RAM

Expected Results

With python 3.6.9 (same result as in the example page)

fun: -1.0146594077693436
    func_vals: array([ 0.03716044,  0.00673852,  0.63515442, -0.16042062,  0.10695907,
       -0.23193728, -0.60259431, -0.04943778, -1.01465941, -0.98480886,
       -0.87449015,  0.18102445, -0.10782771,  0.01197229, -0.80618926])
       models: [GaussianProcessRegressor(alpha=1e-10, copy_X_train=True,
             kernel=1**2 * Matern(length_scale=1, nu=2.5) + WhiteKernel(noise_level=0.01),
             n_restarts_optimizer=2, noise=0.010000000000000002,
             normalize_y=True, optimizer='fmin_l_bfgs_b',
             random_state=822569775), GaussianProcessRegressor(alpha=1e-10, copy_X_train=True,
             kernel=1**2 * Matern(length_scale=1, nu=2.5) + WhiteKernel(noise_level=0.01),
             n_restarts_optimizer=2, noise=0.010000000000000002,
             normalize_y=True, optimizer='fmin_l_bfgs_b',
             random_state=822569775), GaussianProcessRegressor(alpha=1e-10, copy_X_train=True,
             kernel=1**2 * Matern(length_scale=1, nu=2.5) + WhiteKernel(noise_level=0.01),
             n_restarts_optimizer=2, noise=0.010000000000000002,
             normalize_y=True, optimizer='fmin_l_bfgs_b',
             random_state=822569775), GaussianProcessRegressor(alpha=1e-10, copy_X_train=True,
             kernel=1**2 * Matern(length_scale=1, nu=2.5) + WhiteKernel(noise_level=0.01),
             n_restarts_optimizer=2, noise=0.010000000000000002,
             normalize_y=True, optimizer='fmin_l_bfgs_b',
             random_state=822569775), GaussianProcessRegressor(alpha=1e-10, copy_X_train=True,
             kernel=1**2 * Matern(length_scale=1, nu=2.5) + WhiteKernel(noise_level=0.01),
             n_restarts_optimizer=2, noise=0.010000000000000002,
             normalize_y=True, optimizer='fmin_l_bfgs_b',
             random_state=822569775), GaussianProcessRegressor(alpha=1e-10, copy_X_train=True,
             kernel=1**2 * Matern(length_scale=1, nu=2.5) + WhiteKernel(noise_level=0.01),
             n_restarts_optimizer=2, noise=0.010000000000000002,
             normalize_y=True, optimizer='fmin_l_bfgs_b',
             random_state=822569775), GaussianProcessRegressor(alpha=1e-10, copy_X_train=True,
             kernel=1**2 * Matern(length_scale=1, nu=2.5) + WhiteKernel(noise_level=0.01),
             n_restarts_optimizer=2, noise=0.010000000000000002,
             normalize_y=True, optimizer='fmin_l_bfgs_b',
             random_state=822569775), GaussianProcessRegressor(alpha=1e-10, copy_X_train=True,
             kernel=1**2 * Matern(length_scale=1, nu=2.5) + WhiteKernel(noise_level=0.01),
             n_restarts_optimizer=2, noise=0.010000000000000002,
             normalize_y=True, optimizer='fmin_l_bfgs_b',
             random_state=822569775), GaussianProcessRegressor(alpha=1e-10, copy_X_train=True,
             kernel=1**2 * Matern(length_scale=1, nu=2.5) + WhiteKernel(noise_level=0.01),
             n_restarts_optimizer=2, noise=0.010000000000000002,
             normalize_y=True, optimizer='fmin_l_bfgs_b',
             random_state=822569775), GaussianProcessRegressor(alpha=1e-10, copy_X_train=True,
             kernel=1**2 * Matern(length_scale=1, nu=2.5) + WhiteKernel(noise_level=0.01),
             n_restarts_optimizer=2, noise=0.010000000000000002,
             normalize_y=True, optimizer='fmin_l_bfgs_b',
             random_state=822569775), GaussianProcessRegressor(alpha=1e-10, copy_X_train=True,
             kernel=1**2 * Matern(length_scale=1, nu=2.5) + WhiteKernel(noise_level=0.01),
             n_restarts_optimizer=2, noise=0.010000000000000002,
             normalize_y=True, optimizer='fmin_l_bfgs_b',
             random_state=822569775)]
 random_state: <mtrand.RandomState object at 0x7f35be6c6708>
        space: Space([Real(low=-2.0, high=2.0, prior='uniform', transform='normalize')])
        specs: {'args': {'model_queue_size': None, 'n_jobs': 1, 'kappa': 1.96, 'xi': 0.01, 'n_restarts_optimizer': 5, 'n_points': 10000, 'callback': None, 'verbose': False, 'random_state': <mtrand.RandomState object at 0x7f35be6c6708>, 'y0': None, 'x0': None, 'acq_optimizer': 'auto', 'acq_func': 'EI', 'n_random_starts': 5, 'n_calls': 15, 'base_estimator': GaussianProcessRegressor(alpha=1e-10, copy_X_train=True,
             kernel=1**2 * Matern(length_scale=1, nu=2.5),
             n_restarts_optimizer=2, noise=0.010000000000000002,
             normalize_y=True, optimizer='fmin_l_bfgs_b',
             random_state=822569775), 'dimensions': Space([Real(low=-2.0, high=2.0, prior='uniform', transform='normalize')]), 'func': <function f at 0x7f35d8dc3e18>}, 'function': 'base_minimize'}
            x: [-0.35076964213550554]
      x_iters: [[-0.009345334109402526], [1.2713537644662787], [0.4484475787090836], [1.0854396754496047], [1.4426790855107496], [0.9698921802985794], [-0.4464493263345515], [-0.6474638307563569], [-0.35076964213550554], [-0.28714768066245777], [-0.2968537677230516], [-2.0], [2.0], [-1.3149517829595054], [-0.3218160663811962]]

result3 6

Actual Results

With python 3.8.3

fun: -0.4294555822111941
    func_vals: array([ 0.03716044,  0.00673852,  0.63515442, -0.16042062,  0.10695907,
       -0.11519569, -0.07975108, -0.2971752 , -0.42763291, -0.37296444,
       -0.23640416, -0.10508651, -0.42945558, -0.28040902, -0.25062723])
       models: [GaussianProcessRegressor(kernel=1**2 * Matern(length_scale=1, nu=2.5) + WhiteKernel(noise_level=0.01),
                         n_restarts_optimizer=2, noise=0.010000000000000002,
                         normalize_y=True, random_state=822569775), GaussianProcessRegressor(kernel=1**2 * Matern(length_scale=1, nu=2.5) + WhiteKernel(noise_level=0.01),
                         n_restarts_optimizer=2, noise=0.010000000000000002,
                         normalize_y=True, random_state=822569775), GaussianProcessRegressor(kernel=1**2 * Matern(length_scale=1, nu=2.5) + WhiteKernel(noise_level=0.01),
                         n_restarts_optimizer=2, noise=0.010000000000000002,
                         normalize_y=True, random_state=822569775), GaussianProcessRegressor(kernel=1**2 * Matern(length_scale=1, nu=2.5) + WhiteKernel(noise_level=0.01),
                         n_restarts_optimizer=2, noise=0.010000000000000002,
                         normalize_y=True, random_state=822569775), GaussianProcessRegressor(kernel=1**2 * Matern(length_scale=1, nu=2.5) + WhiteKernel(noise_level=0.01),
                         n_restarts_optimizer=2, noise=0.010000000000000002,
                         normalize_y=True, random_state=822569775), GaussianProcessRegressor(kernel=1**2 * Matern(length_scale=1, nu=2.5) + WhiteKernel(noise_level=0.01),
                         n_restarts_optimizer=2, noise=0.010000000000000002,
                         normalize_y=True, random_state=822569775), GaussianProcessRegressor(kernel=1**2 * Matern(length_scale=1, nu=2.5) + WhiteKernel(noise_level=0.01),
                         n_restarts_optimizer=2, noise=0.010000000000000002,
                         normalize_y=True, random_state=822569775), GaussianProcessRegressor(kernel=1**2 * Matern(length_scale=1, nu=2.5) + WhiteKernel(noise_level=0.01),
                         n_restarts_optimizer=2, noise=0.010000000000000002,
                         normalize_y=True, random_state=822569775), GaussianProcessRegressor(kernel=1**2 * Matern(length_scale=1, nu=2.5) + WhiteKernel(noise_level=0.01),
                         n_restarts_optimizer=2, noise=0.010000000000000002,
                         normalize_y=True, random_state=822569775), GaussianProcessRegressor(kernel=1**2 * Matern(length_scale=1, nu=2.5) + WhiteKernel(noise_level=0.01),
                         n_restarts_optimizer=2, noise=0.010000000000000002,
                         normalize_y=True, random_state=822569775), GaussianProcessRegressor(kernel=1**2 * Matern(length_scale=1, nu=2.5) + WhiteKernel(noise_level=0.01),
                         n_restarts_optimizer=2, noise=0.010000000000000002,
                         normalize_y=True, random_state=822569775)]
 random_state: RandomState(MT19937) at 0x7F53B30AB340
        space: Space([Real(low=-2.0, high=2.0, prior='uniform', transform='normalize')])
        specs: {'args': {'func': <function f at 0x7f53d4635280>, 'dimensions': Space([Real(low=-2.0, high=2.0, prior='uniform', transform='normalize')]), 'base_estimator': GaussianProcessRegressor(kernel=1**2 * Matern(length_scale=1, nu=2.5),
                         n_restarts_optimizer=2, noise=0.010000000000000002,
                         normalize_y=True, random_state=822569775), 'n_calls': 15, 'n_random_starts': 5, 'acq_func': 'EI', 'acq_optimizer': 'auto', 'x0': None, 'y0': None, 'random_state': RandomState(MT19937) at 0x7F53B30AB340, 'verbose': False, 'callback': None, 'n_points': 10000, 'n_restarts_optimizer': 5, 'xi': 0.01, 'kappa': 1.96, 'n_jobs': 1, 'model_queue_size': None}, 'function': 'base_minimize'}
            x: [0.9015772522942358]
      x_iters: [[-0.009345334109402526], [1.2713537644662787], [0.4484475787090836], [1.0854396754496047], [1.4426790855107496], [1.0722894743393931], [1.104047772527582], [1.0332536162210535], [0.9564593955296274], [0.9335830910110636], [0.9616485023360357], [0.9464152096274643], [0.9015772522942358], [0.9186215206368642], [0.8568590965465104]]

result3 8

Versions

Result of import sklearn; sklearn.show_versions():

System:
    python: 3.8.3 (default, Jun 17 2020, 12:03:07)  [GCC 9.3.0]
executable: /usr/local/bin/python3.8
   machine: Linux-4.15.0-106-generic-x86_64-with-glibc2.27

Python dependencies:
          pip: 20.1.1
   setuptools: 47.3.1
      sklearn: 0.23.1
        numpy: 1.18.5
        scipy: 1.4.1
       Cython: None
       pandas: 1.0.4
   matplotlib: 3.2.1
       joblib: 0.15.1
threadpoolctl: 2.1.0

Built with OpenMP: True

Using: scikit-optimize 0.7.4

Thank you for your support! I'm very lost about what to do regarding this, as my team work requires a recent >3.6 python version and I get wrong results with those.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions