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

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Apr 21 20:20:38 PDT 2017


Author: spawley
Date: 2017-04-21 20:20:36 -0700 (Fri, 21 Apr 2017)
New Revision: 70909

Modified:
   grass-addons/grass7/raster/r.learn.ml/r.learn.ml.py
   grass-addons/grass7/raster/r.learn.ml/raster_learning.py
Log:
r.learn.ml minor additions of descriptions and labels

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-21 12:18:04 UTC (rev 70908)
+++ grass-addons/grass7/raster/r.learn.ml/r.learn.ml.py	2017-04-22 03:20:36 UTC (rev 70909)
@@ -1,4 +1,6 @@
 #!/usr/bin/env python
+# -- coding: utf-8 --
+
 ############################################################################
 # MODULE:        r.learn.ml
 # AUTHOR:        Steven Pawley
@@ -409,6 +411,7 @@
     n_partitions = int(options['n_partitions'])
     modelonly = flags['m']
     probability = flags['p']
+    prob_only = flags['z']
     tuneonly = flags['t']
     rowincr = int(options['lines'])
     random_state = int(options['random_state'])
@@ -428,7 +431,6 @@
     n_jobs = int(options['n_jobs'])
     lowmem = flags['l']
     impute = flags['i']
-    prob_only = flags['z']
     errors_file = options['errors_file']
     fimp_file = options['fimp_file']
     param_file = options['param_file']
@@ -439,8 +441,19 @@
     if ',' in categorymaps:
         categorymaps = [int(i) for i in categorymaps.split(',')]
     else: categorymaps = None
+    
+    # error checking
+    # feature importances selected by no cross-validation scheme used
     if importances is True and cv == 1:
         grass.fatal('Feature importances require cross-validation cv > 1')
+    
+    # output map has not been entered and modelonly is not set to True
+    if output == '' and modelonly is True:
+        grass.fatal('No output map specified')
+    
+    # perform prediction only for class probabilities but probability flag is not set to True
+    if prob_only is True:
+        probability = True
 
     # make dicts for hyperparameters, datatypes and parameters for tuning
     hyperparams = {'C': options['c'],

Modified: grass-addons/grass7/raster/r.learn.ml/raster_learning.py
===================================================================
--- grass-addons/grass7/raster/r.learn.ml/raster_learning.py	2017-04-21 12:18:04 UTC (rev 70908)
+++ grass-addons/grass7/raster/r.learn.ml/raster_learning.py	2017-04-22 03:20:36 UTC (rev 70909)
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+
 import os
 import numpy as np
 from numpy.random import RandomState
@@ -161,9 +163,9 @@
                        'neg_mean_squared_error': metrics.mean_squared_error}
 
     byclass_methods = {'f1': metrics.f1_score,
-                      'fbeta': metrics.fbeta_score,
-                      'precision': metrics.precision_score,
-                      'recall': metrics.recall_score}
+                       'fbeta': metrics.fbeta_score,
+                       'precision': metrics.precision_score,
+                       'recall': metrics.recall_score}
 
     # create diction to store byclass metrics results
     n_classes = len(np.unique(y))



More information about the grass-commit mailing list