This repository has been archived by the owner on Feb 28, 2024. It is now read-only.
Replies: 1 comment
-
As per In your code, you are mixing two usages: Here is a script where import numpy as np
import skopt
np.random.seed(123)
dimensions = [
(-2.0, 2.0),
(-2, 2),
(0.0, 2.0),
]
def f(args):
x, y, z = args
return (
np.sin(5 * x) * (1 - np.tanh(x ** 2)) * np.random.randn() * 0.1
- y ** 2
+ z ** 2
)
result = skopt.gp_minimize(f, dimensions, n_calls=20)
print(f"Lowest value is {result.fun=}, at {result.x=}") If you want to use a standard function, you can use the import numpy as np
import skopt
from skopt import space, utils
np.random.seed(123)
dimensions = [
space.Real(-2.0, 2.0, name="x"),
space.Integer(-2, 2, name="y"),
space.Real(0.0, 2.0, name="z"),
]
@utils.use_named_args(dimensions)
def f(x, y, z):
return (
np.sin(5 * x) * (1 - np.tanh(x ** 2)) * np.random.randn() * 0.1
- y ** 2
+ z ** 2
)
result = skopt.gp_minimize(f, dimensions, n_calls=20)
print(f"Lowest value is {result.fun=}, at {result.x=}") |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have to optimize a black-box problem that depends on external software (no function definition neither derivatives) that is quite expensive to evaluate. It depends on several variables, some of them are real and some other are integers.
I think Scikit Optimize may be a good choice. I am newbie with Scikit Optimize.
I was wondering if the following example (from the Scikit Optimize documentation) may be adapted to my actual problem. Being "f" an external function that provides the cost of a given set of parameters. Here it is a dummy function just to be reproducible. But, instead of depending just on "x", make it dependable on "y" and "z" being one of them restricted to integer values.
I have seen some other examples of Scikit Optimize oriented to hyperparameter optimization (based on Scikit Learn), but they seem less clear for me.
Here is the minimum reproducible example (that crash):
Best regards and thank you
Beta Was this translation helpful? Give feedback.
All reactions