Exemple #1
0
# coding: utf-8
"""Classification Kriging."""
import numpy as np
from pykrige.compat import Krige, validate_sklearn, check_sklearn_model

validate_sklearn()

from sklearn.metrics import accuracy_score
from sklearn.svm import SVC
from sklearn.preprocessing import OneHotEncoder
from scipy.linalg import helmert


class ClassificationKriging:
    """
    An implementation of Simplicial Indicator Kriging applied to classification ilr transformed residuals.

    Parameters
    ----------
    classification_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
Exemple #2
0
# coding: utf-8
from pykrige.compat import validate_sklearn
validate_sklearn()
from pykrige.ok import OrdinaryKriging
from pykrige.uk import UniversalKriging
from pykrige.ok3d import OrdinaryKriging3D
from pykrige.uk3d import UniversalKriging3D
from sklearn.base import RegressorMixin, BaseEstimator
from sklearn.svm import SVR
from sklearn.metrics import r2_score

krige_methods = {'ordinary': OrdinaryKriging,
                 'universal': UniversalKriging,
                 'ordinary3d': OrdinaryKriging3D,
                 'universal3d': UniversalKriging3D
                 }

threed_krige = ('ordinary3d', 'universal3d')


def validate_method(method):
    if method not in krige_methods.keys():
        raise ValueError('Kriging method must be '
                         'one of {}'.format(krige_methods.keys()))


class Krige(RegressorMixin, BaseEstimator):
    """
    A scikit-learn wrapper class for Ordinary and Universal Kriging.
    This works with both Grid/RandomSearchCv for finding the best
    Krige parameters combination for a problem.