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 was archived by the owner on Feb 28, 2024. It is now read-only.
Calling multiple times .fit(X, y) whenever self.noise exists causes self.kernel to add new WhiteKernel noise.
Steps to reproduce
fromskopt.learning.gaussian_processimportgpr, kernels#gpr is the package with the bugimportnumpyasnpnp.random.seed(0) # for reproductiongp=gpr.GaussianProcessRegressor(kernel=kernels.RBF(), alpha=1e-7, noise=0.01)
train_inputs=np.array([0, 0.1, 0.2]).reshape(-1, 1)
train_targets=np.array([1, 1.5, 0.6])
foriinrange(10):
gp.fit(train_inputs, train_targets)
test_inputs=np.arange(0, 0.25, 0.05).reshape(-1, 1)
gp.predict(test_inputs)
print(str(gp.get_params()['kernel__k1']).count("WhiteKernel")) # number of WhiteKernels in self.kernel increases with each .fittrain_inputs=np.vstack([train_inputs, np.random.rand()])
train_targets=np.append(train_targets, np.random.rand())
Proposed solution
Lines 182-184, 189-194 from skopt.learning.gaussian_process.gpr should be on the init function, right after line 161
ifisinstance(self.noise, str) andself.noise!="gaussian":
raiseValueError("expected noise to be 'gaussian', got %s"%self.noise)
ifself.noise=="gaussian":
kernel=kernel+WhiteKernel()
elifself.noise:
kernel=kernel+WhiteKernel(
noise_level=self.noise, noise_level_bounds="fixed"
)