0

I'm having a problem with fitting Gaussian process regression model to my data. I don't know what comes after X, y =. I'm trying to follow the sklearn example.

My goal is to fit the model to these two objective functions:

def objectives (h,b,l,t):
    f1 = 1.10471*(h**2)*l + 0.04811*t*b*(14.0 + l)
    f2 = 2.1952 / (t**3)*b
    return f1,f2

X is a decision matrix I have generated with a sampling method:

sampler = qmc.LatinHypercube(d=4)
u_bounds = np.array([5.0, 5.0, 10.0, 10.0])
l_bounds = np.array([0.125, 0.125, 0.1, 0.1])
data = sampler.lhs_method(100)*(u_bounds-(l_bounds)) + (l_bounds)

yis:

y=np.zeros((100,2))   
for i in range(np.shape(data)[0]):
    y[i,0], y[i,1] = objectives(data[i,0], data[i,1], data[i,2], data[i,3])

Here comes the obstacle when I try to instantiate the Gaussian process model. What comes after X, y =?

X, y = ???(n_samples=500, noise=0, random_state=0)
kernel = DotProduct() + WhiteKernel()
gpr = GaussianProcessRegressor(kernel=kernel,
         random_state=0).fit(X, y)
gpr.score(X, y)
Gato
  • 389
  • 2
  • 12
  • 2
    You shouldn't need that line in your code if you already have data. The `X,y = make_friedman2(...)` is generating a semi-randomized regression dataset from [sklearn.datasets.make_friedman2](https://scikit-learn.org/stable/modules/generated/sklearn.datasets.make_friedman2.html) in order to have data to fit the model onto. In your case, you're just fitting on your own X and y, no? – G. Anderson Jun 01 '22 at 17:16
  • You might be right. At least it works, and gives a score ```0.00035767791141416705```. But I don't know what that score represents exactly. Do you know what is the next step, code-wise, towards fitting the model onto the objective functions? My intuitive ```gpr.fit(f1)```does not do the job. – Gato Jun 01 '22 at 17:38
  • Your question is a little ambiguous. The custom function(s) you included could be one of three things. Are you trying to use custom optimization functions (in the documentation for the GaussianProcessRegression that you posted under the section `optimizer: "fmin_l_bfgs_b" or callable` where your function would be the callable), [custom kernels](https://stackoverflow.com/questions/49188159/how-to-create-a-custom-kernel-for-a-gaussian-process-regressor-in-scikit-learn), or [custom loss/scoring](https://stackoverflow.com/questions/54267745/implementing-custom-loss-function-in-scikit-learn) ? – G. Anderson Jun 01 '22 at 20:45
  • Yes, a bit too ambiguous it is. No, I haven't tried to use these custom optimization functions – Gato Jun 02 '22 at 17:40

0 Answers0