Python - Kriging (Gaussian Process) in scikit_learn

回眸只為那壹抹淺笑 提交于 2019-11-30 19:30:18

Yes, you can definitely do that in scikit_learn.

In fact, it is a basic feature of kriging/Gaussian process regression that you can use anisotropic covariance kernels.

As it is precised in the manual (cited below) ou can either set the parameters of the covariance yourself or estimate them. And you can choose either having all parameters equal or all different.

theta0 : double array_like, optional An array with shape (n_features, ) or (1, ). The parameters in the autocorrelation model. If thetaL and thetaU are also specified, theta0 is considered as the starting point for the maximum likelihood estimation of the best set of parameters. Default assumes isotropic autocorrelation model with theta0 = 1e-1.

In the 2d case, something like this should work:

import numpy as np
from sklearn.gaussian_process import GaussianProcess

x = np.arange(1,51)
y = np.arange(1,51)
X, Y = np.meshgrid(lons, lats)

points = zip(obs_x,  obs_y)
values = obs_data    # Replace with your observed data

gp = GaussianProcess(theta0=0.1, thetaL=.001, thetaU=1., nugget=0.001)
gp.fit(points, values)
XY_pairs = np.column_stack([X.flatten(), Y.flatten()])
predicted = gp.predict(XY_pairs).reshape(X.shape)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!