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

gp_minimize: ranges can be a different datatype than initial guess #1143

Open
ChrisBNEU opened this issue Feb 5, 2023 · 0 comments
Open

Comments

@ChrisBNEU
Copy link

ChrisBNEU commented Feb 5, 2023

I am using skopt version 0.9.0 and numpy 1.23.5 (due to an error I got that is specified in #1138). I found, after downgrading numpy from 1.24.1, that I had made an error in specifying the ranges. They were ints instead of floats. however, my initial x-guess was a float. I made a minimal example below:

from skopt import gp_minimize
def find_sqrt(x):
    """find square root of value y given a guess x"""
    y = 12.5
    x = x[0]
    y_guess = x**2
    return abs(y_guess - y)

x0 = [1.0]
y0 = None
    
res1 = gp_minimize(
    find_sqrt,
    [
        (0.0, 12.0),
    ],
    n_calls=12,
    x0=x0,
    y0=y0,
)

print("guesses with proper float ranges: ", res1.x_iters)

res2 = gp_minimize(
    find_sqrt,
    [
        (0, 12),
    ],
    n_calls=12,
    x0=x0,
    y0=y0,
)

print("guesses with improper int ranges: ", res2.x_iters)

which outputs:

guesses with proper float ranges:  [[1.0], [8.114281197171252], [9.021416917982528], [4.955995220826303], [6.649848371121621], [11.582469882107137], [3.953831466277097], [2.1390536274803877], [2.6277353173592157], [5.884289789665528], [3.918451377145078], [3.5048487566802144]]
guesses with improper int ranges [[1.0], [6], [9], [5], [0], [11], [1], [1], [7], [3], [4], [4]]

If this is expected behavior and I missed something in the docs then I am fine with closing the issue, but I would think that there would be an error thrown if the first and second guesses are different datatypes for the same variable.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant