You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 28, 2024. It is now read-only.
from skopt import gp_minimize
from sklearn.gaussian_process import GaussianProcessRegressor
from sklearn.gaussian_process.kernels import ConstantKernel, RBF
# Define your observed data (replace with your own data)
observed_X = np.array([0.5, 1.5, 2.0])
observed_y = np.array([2.0, 1.0, 0.5])
# Reshape the observed_X to have shape (n_samples, n_features)
observed_X = observed_X.reshape(-1, 1)
# Define the surrogate model
kernel = ConstantKernel(1.0, constant_value_bounds="fixed") * RBF(length_scale=1.0, length_scale_bounds="fixed")
surrogate_model = GaussianProcessRegressor(kernel=kernel)
# Define the optimization function using the surrogate model's prediction
def optimization_function(x):
return surrogate_model.predict(np.array([[x]]))
# Perform Bayesian optimization using Gaussian Process with observed data
result = gp_minimize(optimization_function,
dimensions=[(0., 5.0)],
n_calls=20,
n_random_starts=5,
x0=observed_X,
y0=observed_y)
but when I run it I get the error:
RuntimeError: Optimization space (Space([Real(low=0.0, high=5.0, prior='uniform', transform='normalize')])) and initial points in x0 use inconsistent dimensions.
I am using the following versions in a conda enviroment:
I have a simple example of using skopt:
but when I run it I get the error:
RuntimeError: Optimization space (Space([Real(low=0.0, high=5.0, prior='uniform', transform='normalize')])) and initial points in x0 use inconsistent dimensions.
I am using the following versions in a conda enviroment:
scikit-learn 1.0.2
scikit-optimize 0.9.0
scipy 1.8.1
The text was updated successfully, but these errors were encountered: