I would like to use scikit-optimize.gp_minimize to optimize a function whose input is a combination of scalars and an Numpy array of shape N. How do I set the dimensions parameter for scalars and a 1d ndarray?
Example
import numpy as np
from skopt import gp_minimize
from skopt.space.space import Integer
# Create inputs
X_array = np.random.rand(12)
x_int = 10
# Define the function to be minimized
def objective(X_array, x_int):
return x_int + np.sum(X_array)
# Use gp_minimize to find the minimum of the objective function
res = gp_minimize(objective, dimensions=[???, Integer(0, 20)])
# Print the best set of parameters
print(f"Best set of parameters: {res.x}")
I had several discussions with a variety of chatbots and they suggested using a search space (skopt.space.space.Space). None of their code worked.
As a workaround, I could treat each element of the array as a separate parameter. This is a little messy.