Skip to content

Commit

Permalink
[krige] update kriging package, config
Browse files Browse the repository at this point in the history
  • Loading branch information
basaks committed Nov 7, 2023
1 parent 1d83772 commit 85efb68
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
29 changes: 15 additions & 14 deletions configs/kriging.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# basic kriging setup
features:
- name: my pickle files
type: pickle
files:
covariates: features.pk
targets: targets.pk
# - name: my pickle files
# type: pickle
# files:
# covariates: features.pk
# targets: targets.pk
- name: my features 1
type: ordinal
files:
- path: /path/to/GA_data/GA-cover2/LATITUDE_GRID1.tif
- path: /path/to/GA_data/GA-cover2/LONGITUDE_GRID1.tif
- path: configs/data/sirsam/LATITUDE_GRID1.tif
- path: configs/data/sirsam/LONGITUDE_GRID1.tif
# transforms are performed in order
transforms:
- centre
- standardise
# - centre
# - standardise
imputation: nn

# only used during prediction
mask:
file: /path/to/GA_data/mask/old_mask_test.tif
retain: 1
#mask:
# file: /path/to/GA_data/mask/old_mask_test.tif
# retain: 1


# resample: choice (value, spatial)
Expand All @@ -29,7 +29,7 @@ mask:
# rows and cols: for spatial resampling, sample from rows X cols tiles
# resampling is performed in sequence. The order of spatial/value is important.
targets:
file: /path/to/GA_data/GA-cover2/geochem_sites.shp
file: configs/data/sirsam/out_resampled/geochem_sites.shp
property: K_ppm_imp_
# resample:
# - spatial:
Expand All @@ -50,6 +50,7 @@ learning:
arguments:
method: ordinary # ordinary or universal
variogram_model: spherical # linear, power, gaussian, spherical, exponential
variogram_parameters: [0, 1, 0.1] # [sill, range, nugget] for gaussian, spherical, exponential
verbose: False


Expand All @@ -74,4 +75,4 @@ validation:
random_seed: 1

output:
directory: .
directory: krige
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def run(self):
'PyYAML >= 3.11',
'pandas >= 1.2.5',
'matplotlib >= 3.4.0',
'PyKrige==1.3.0',
'PyKrige==1.7.0',
'xgboost>=1.4.2',
'setuptools>=30.0.0',
'eli5>=0.8.2',
Expand Down
3 changes: 3 additions & 0 deletions uncoverml/krige.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class Krige(TagsMixin, RegressorMixin, BaseEstimator, KrigePredictDistMixin):
def __init__(self,
method='ordinary',
variogram_model='linear',
variogram_parameters=None,
nlags=6,
weight=False,
n_closest_points=10,
Expand All @@ -102,6 +103,7 @@ def __init__(self,
raise ConfigException('Kirging method must be '
'one of {}'.format(krige_methods.keys()))
self.variogram_model = variogram_model
self.variogram_parameters = variogram_parameters
self.verbose = verbose
self.nlags = nlags
self.weight = weight
Expand All @@ -126,6 +128,7 @@ def fit(self, x, y, *args, **kwargs):
y=x[:, 1],
z=y,
variogram_model=self.variogram_model,
variogram_parameters=self.variogram_parameters,
verbose=self.verbose,
nlags=self.nlags,
weight=self.weight,
Expand Down

0 comments on commit 85efb68

Please sign in to comment.