[GRASS-SVN] r70891 - grass-addons/grass7/raster/r.learn.ml

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Apr 17 11:04:49 PDT 2017


Author: spawley
Date: 2017-04-17 11:04:49 -0700 (Mon, 17 Apr 2017)
New Revision: 70891

Modified:
   grass-addons/grass7/raster/r.learn.ml/r.learn.ml.py
Log:
fixed bug with r.learn.ml for use of group raster

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 05:02:40 UTC (rev 70890)
+++ grass-addons/grass7/raster/r.learn.ml/r.learn.ml.py	2017-04-17 18:04:49 UTC (rev 70891)
@@ -382,8 +382,8 @@
     if ',' in indexes:
         indexes = [int(i) for i in indexes.split(',')]
     else:
-        indexes = int(indexes)
-    if indexes == -1:
+        indexes = [int(indexes)] # predict expects list
+    if indexes == [-1]:
         indexes = None
     n_permutations = int(options['n_permutations'])
     lowmem = flags['l']
@@ -476,10 +476,10 @@
                 maplist2.append(group_raster)
                 if trainingmap != '':
                     X, y, sample_coords = extract(
-                        response=trainingmap, predictors=maplist2, lowmem=False)
+                        response=trainingmap, predictors=maplist2, lowmem=lowmem)
                 elif trainingpoints != '':
                     X, y, sample_coords = extract_points(
-                        trainingpoints, maplist, field)
+                        trainingpoints, maplist2, field)
 
                 # take group id from last column and remove from predictors
                 group_id = X[:, -1]
@@ -502,7 +502,6 @@
 
                     clusters.fit(sample_coords)
                     group_id = clusters.labels_
-
             # check for labelled pixels and training data
             if y.shape[0] == 0 or X.shape[0] == 0:
                 grass.fatal('No training pixels or pixels in imagery group '



More information about the grass-commit mailing list