我需要使用 scikit-learn 库在 Python 中实现 GPR(高斯过程回归)。
我的输入 X 有两个功能。前任。X=[x1, x2]。并且输出是一维 y=[y1]
我想使用两个内核;RBF 和 Matern,这样 RBF 使用“x1”功能,而 Matern 使用“x2”功能。我尝试了以下方法:
import numpy as np
from sklearn.gaussian_process import GaussianProcessRegressor
from sklearn.gaussian_process.kernels import Matern as M, RBF as R
X = np.matrix([[1.,2], [3.,4], [5.,1], [6.,5],[4, 7.],[ 9,8.], [1.,2], [3.,4], [5.,1], [6.,5],[4, 7.],[ 9,8.],[1.,2], [3.,4], [5.,1], [6.,5],[4, 7.],[ 9,8.]]).T
y=[0.84147098, 0.42336002, -4.79462137, -1.67649299, 4.59890619, 7.91486597, 0.84147098, 0.42336002, -4.79462137, -1.67649299, 4.59890619, 7.91486597, 0.84147098, 0.42336002, -4.79462137, -1.67649299, 4.59890619, 7.91486597]
kernel = R(X[0]) * M(X[1])
gp = GaussianProcessRegressor(kernel=kernel) …Run Code Online (Sandbox Code Playgroud)