Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Python中为内核创建各向异性指数和高斯相关函数?_Python_Scikit Learn_Gaussian_Kriging - Fatal编程技术网

如何在Python中为内核创建各向异性指数和高斯相关函数?

如何在Python中为内核创建各向异性指数和高斯相关函数?,python,scikit-learn,gaussian,kriging,Python,Scikit Learn,Gaussian,Kriging,我有一个1000个观察样本的数据集,其中6个特征构成X,一个目标变量构成Y 我正在使用克里格法或训练我的模型。我想使用各向异性高斯函数和各向异性指数相关函数作为核函数。请参考随附的方程式剪 如何在python中定义命名函数 Scikit learn提供各向异性高斯和指数内核。您所要做的就是将长度比例替换为长度等于特征数的数组。对于高斯核,其工作原理如下: from sklearn.datasets import load_iris from sklearn.gaussian_process im

我有一个1000个观察样本的数据集,其中6个特征构成X,一个目标变量构成Y

我正在使用克里格法或训练我的模型。我想使用各向异性高斯函数和各向异性指数相关函数作为核函数。请参考随附的方程式剪

如何在python中定义命名函数


Scikit learn提供各向异性高斯和指数内核。您所要做的就是将长度比例替换为长度等于特征数的数组。对于高斯核,其工作原理如下:

from sklearn.datasets import load_iris
from sklearn.gaussian_process import GaussianProcessClassifier
from sklearn.gaussian_process.kernels import RBF,Matern
X, y = load_iris(return_X_y=True)
kernel = 1.0 * RBF([1.0,1.5,0.5,1]) # just create anisotropic kernel here
#kernel = 1.0 * RBF([1]) # isotropic kernel
gpc = GaussianProcessClassifier(kernel=kernel,random_state=0).fit(X, y)
gpc.score(X, y)
gpc.predict_proba(X[:2,:])
可以将指数核作为matren核的特例来获得。我的数学有点生疏,但可以通过将nu参数设置为0.5来实现:

from sklearn.gaussian_process.kernels import Matern    
kernel = 1.0 * Matern(length_scale=[1.0,1.5,0.5,1], nu=0.5)

非常感谢你。非常感谢您抽出时间回答这个问题。数组中的值不是由高斯过程回归器优化的吗?我从阵列中的1开始。是的,默认情况下根据文档对它们进行了优化: