Pymc with external GP function

I’m trying to use pymc3 to find the parameter of a set of data modeled through a GP in skit-learn. I want pymc to take samples of the variable H, input this H into my GP to obtain an array, this array will be compared with a goal array called ‘P’.
The code is:
def GPR(H):
u_ = np.linspace(0, 10, 51)
H_ = np.tile(H, 51)
u_H = np.column_stack((u_, H_))
y_predUnL = gp.predict(u_H)
return y_predUnL

with pm.Model() as Infer:
beta = pm.Normal(‘beta’, mu=4, sigma=1, shape=1)
sigma = pm.HalfNormal(‘sigma’, sigma=0.05)
mu = GPR_UnLd(beta)
recruits = pm.Normal(‘P’, mu=mu, sigma=sigma, observed=P)

# Run sampling
trace = pm.sample(4000)

Analyze the results

pm.summary(trace)
pm.traceplot(trace)

I’m getting this error:

TypeError Traceback (most recent call last)
TypeError: float() argument must be a string or a real number, not ‘FreeRV’

The above exception was the direct cause of the following exception:

ValueError Traceback (most recent call last)
in <cell line: 8>()
9 beta = pm.Normal(‘beta’, mu=4, sigma=1, shape=1)
10 sigma = pm.HalfNormal(‘sigma’, sigma=0.05)
—> 11 mu = GPR_UnLd(beta)
12 recruits = pm.Normal(‘P’, mu=mu, sigma=sigma, observed=P)
13

4 frames
in GPR_UnLd(H)
2 u_ = np.linspace(0, 10, 51)
3 H_ = np.tile(H, 51)
----> 4 y_predUnL = gp.predict(np.column_stack((u_, H_)))
5 print(y_predUnL)
6 print(y_predUnL.shape)

/usr/local/lib/python3.10/dist-packages/sklearn/gaussian_process/_gpr.py in predict(self, X, return_std, return_cov)
383 dtype, ensure_2d = None, False
384
→ 385 X = self.validate_data(X, ensure_2d=ensure_2d, dtype=dtype, reset=False)
386
387 if not hasattr(self, "X_train
"): # Unfitted;predict based on GP prior

/usr/local/lib/python3.10/dist-packages/sklearn/base.py in _validate_data(self, X, y, reset, validate_separately, **check_params)
563 raise ValueError(“Validation should be done on X, y or both.”)
564 elif not no_val_X and no_val_y:
→ 565 X = check_array(X, input_name=“X”, **check_params)
566 out = X
567 elif no_val_X and not no_val_y:

/usr/local/lib/python3.10/dist-packages/sklearn/utils/validation.py in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, estimator, input_name)
877 array = xp.astype(array, dtype, copy=False)
878 else:
→ 879 array = _asarray_with_order(array, order=order, dtype=dtype, xp=xp)
880 except ComplexWarning as complex_warning:
881 raise ValueError(

/usr/local/lib/python3.10/dist-packages/sklearn/utils/_array_api.py in _asarray_with_order(array, dtype, order, copy, xp)
183 if xp.name in {“numpy”, “numpy.array_api”}:
184 # Use NumPy API to support order
→ 185 array = numpy.asarray(array, order=order, dtype=dtype)
186 return xp.asarray(array, copy=copy)
187 else:

ValueError: setting an array element with a sequence.

I think the main problem is that I need a float as input for my function, but the beta of pymc3 has a different type. How can I convert such a value to a float so it can work with my function or any other way to make it work? The gp.predict was done on skit-learn.