[GRASS-SVN] r70893 - grass-addons/grass7/raster/r.learn.ml
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Apr 17 11:22:23 PDT 2017
Author: spawley
Date: 2017-04-17 11:22:23 -0700 (Mon, 17 Apr 2017)
New Revision: 70893
Modified:
grass-addons/grass7/raster/r.learn.ml/r.learn.ml.py
grass-addons/grass7/raster/r.learn.ml/raster_learning.py
Log:
fixed issue caused by grass integer nodata value in r.learn.ml with recent introduction of using vector points as training features
Modified: grass-addons/grass7/raster/r.learn.ml/r.learn.ml.py
===================================================================
--- grass-addons/grass7/raster/r.learn.ml/r.learn.ml.py 2017-04-17 18:12:01 UTC (rev 70892)
+++ grass-addons/grass7/raster/r.learn.ml/r.learn.ml.py 2017-04-17 18:22:23 UTC (rev 70893)
@@ -461,12 +461,15 @@
# clump the labelled pixel raster if labels represent polygons
# then set the group_raster to the clumped raster to extract the
# group_ids used in the GroupKFold cross-validation
- if cvtype == 'clumped' and group_raster == '':
+ if trainingmap != '' and cvtype == 'clumped' and group_raster == '':
clumped_trainingmap = 'tmp_clumped_trainingmap'
tmp_rast.append(clumped_trainingmap)
r.clump(input=trainingmap, output=clumped_trainingmap,
overwrite=True, quiet=True)
group_raster = clumped_trainingmap
+ elif trainingmap == '' and cvtype == 'clumped':
+ grass.fatal('Cross-validation using clumped training areas ',
+ 'requires raster-based training areas')
# extract training data from maplist and take group ids from
# group_raster. Shuffle=False so that group ids and labels align
@@ -524,7 +527,7 @@
if group_id is not None:
X, y, sample_coords, group_id = shuffle(
X, y, sample_coords, group_id, random_state=random_state)
-
+ print(X[:, 0].min())
# option to save extracted data to .csv file
if save_training != '':
save_training_data(X, y, group_id, save_training)
Modified: grass-addons/grass7/raster/r.learn.ml/raster_learning.py
===================================================================
--- grass-addons/grass7/raster/r.learn.ml/raster_learning.py 2017-04-17 18:12:01 UTC (rev 70892)
+++ grass-addons/grass7/raster/r.learn.ml/raster_learning.py 2017-04-17 18:22:23 UTC (rev 70893)
@@ -798,6 +798,9 @@
coordinates = values[:, 1:3]
X[:, i] = values[:, 3]
+ # set any grass integer nodata values to NaN
+ X[X == -2147483648] = np.nan
+
# remove missing response data
X = X[~np.isnan(y)]
coordinates = coordinates[~np.isnan(y)]
More information about the grass-commit
mailing list