Hi, I’m using pymc3 to optimize two parameters in my GaussianProcessRegressor which is a scikit-learn object. And I tried many methods but it still can’t run. So I came here for some suggestion.

Below is my code:

X = data_1[‘param’] #which is 88×400

Cp_E = data_1[‘Cp_E’] #1×400

Y = data_1[‘Cp_M’] #88×400

gaussian=GaussianProcessRegressor()

fiting=gaussian.fit(X, Y)

def main(argv=None):

with pm.Model() as model_:

Cdt1 = pm.Normal(‘Cdt1’, mu = 20., sd = 10.)

CDESkeps = pm.Normal(‘CDESkeps’, mu = 0.6, sd = 3.)

epsilon = pm.Uniform(‘epsilon’, lower = 0, upper = 1)

Z = np.array([Cdt1, CDESkeps])

YX=gaussian.predict(Z.reshape(1, -1))

y_pred = pm.Normal(‘y_pred’, mu = YX, sd = epsilon, observed = Cp_E)

start = pm.find_MAP()

step = pm.NUTS(scaling = start)

trace_ = pm.sample(5000, step = step, start = start)

parameters = [‘Cdt1’, ‘CDESkeps’]

pm.traceplot(trace_, parameters)

if

name==‘main’:

sys.exit(main())

The error is setting an array element with a sequence. But I have confirmed that both the shape of YX and Cp_E are (1,400).

Hope someone can give me some suggestion, thanks in advance.