pykrige.rk.RegressionKriging

class pykrige.rk.RegressionKriging(regression_model=SVR(), method='ordinary', variogram_model='linear', n_closest_points=10, nlags=6, weight=False, verbose=False, exact_values=True, pseudo_inv=False, pseudo_inv_type='pinv', variogram_parameters=None, variogram_function=None, anisotropy_scaling=(1.0, 1.0), anisotropy_angle=(0.0, 0.0, 0.0), enable_statistics=False, coordinates_type='euclidean', drift_terms=None, point_drift=None, ext_drift_grid=(None, None, None), functional_drift=None)[source]

Bases: object

An implementation of Regression-Kriging.

As described here: https://en.wikipedia.org/wiki/Regression-Kriging

Parameters:
  • regression_model (machine learning model instance from sklearn)

  • method (str, optional) – type of kriging to be performed

  • variogram_model (str, optional) – variogram model to be used during Kriging

  • n_closest_points (int) – number of closest points to be used during Ordinary Kriging

  • nlags (int) – see OK/UK class description

  • weight (bool) – see OK/UK class description

  • verbose (bool) – see OK/UK class description

  • exact_values (bool) – see OK/UK class description

  • variogram_parameters (list or dict) – see OK/UK class description

  • variogram_function (callable) – see OK/UK class description

  • anisotropy_scaling (tuple) – single value for 2D (UK/OK) and two values in 3D (UK3D/OK3D)

  • anisotropy_angle (tuple) – single value for 2D (UK/OK) and three values in 3D (UK3D/OK3D)

  • enable_statistics (bool) – see OK class description

  • coordinates_type (str) – see OK/UK class description

  • drift_terms (list of strings) – see UK/UK3D class description

  • point_drift (array_like) – see UK class description

  • ext_drift_grid (tuple) – Holding the three values external_drift, external_drift_x and external_drift_z for the UK class

  • functional_drift (list of callable) – see UK/UK3D class description

Methods

fit(p, x, y)

Fit the regression method and also Krige the residual.

krige_residual(x, **kwargs)

Calculate the residuals.

predict(p, x, **kwargs)

Predict.

score(p, x, y[, sample_weight])

Overloading default regression score method.

fit(p, x, y)[source]

Fit the regression method and also Krige the residual.

Parameters:
  • p (ndarray) – (Ns, d) array of predictor variables (Ns samples, d dimensions) for regression

  • x (ndarray) – ndarray of (x, y) points. Needs to be a (Ns, 2) array corresponding to the lon/lat, for example 2d regression kriging. array of Points, (x, y, z) pairs of shape (N, 3) for 3d kriging

  • y (ndarray) – array of targets (Ns, )

krige_residual(x, **kwargs)[source]

Calculate the residuals.

Parameters:

x (ndarray) – ndarray of (x, y) points. Needs to be a (Ns, 2) array corresponding to the lon/lat, for example.

Returns:

residual – kriged residual values

Return type:

ndarray

predict(p, x, **kwargs)[source]

Predict.

Parameters:
  • p (ndarray) – (Ns, d) array of predictor variables (Ns samples, d dimensions) for regression

  • x (ndarray) – ndarray of (x, y) points. Needs to be a (Ns, 2) array corresponding to the lon/lat, for example. array of Points, (x, y, z) pairs of shape (N, 3) for 3d kriging

Returns:

pred – The expected value of ys for the query inputs, of shape (Ns,).

Return type:

ndarray

score(p, x, y, sample_weight=None, **kwargs)[source]

Overloading default regression score method.

Parameters:
  • p (ndarray) – (Ns, d) array of predictor variables (Ns samples, d dimensions) for regression

  • x (ndarray) – ndarray of (x, y) points. Needs to be a (Ns, 2) array corresponding to the lon/lat, for example. array of Points, (x, y, z) pairs of shape (N, 3) for 3d kriging

  • y (ndarray) – array of targets (Ns, )