[GRASS-SVN] r70266 - grass-addons/grass7/raster/r.learn.ml
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Jan 5 10:11:51 PST 2017
Author: spawley
Date: 2017-01-05 10:11:51 -0800 (Thu, 05 Jan 2017)
New Revision: 70266
Modified:
grass-addons/grass7/raster/r.learn.ml/r.learn.ml.py
Log:
'fixed loading of previously saved training data'
Modified: grass-addons/grass7/raster/r.learn.ml/r.learn.ml.py
===================================================================
--- grass-addons/grass7/raster/r.learn.ml/r.learn.ml.py 2017-01-05 17:16:20 UTC (rev 70265)
+++ grass-addons/grass7/raster/r.learn.ml/r.learn.ml.py 2017-01-05 18:11:51 UTC (rev 70266)
@@ -1008,19 +1008,19 @@
"""
training_data = np.loadtxt(file, delimiter=',')
- n_features = training_data.shape[1]-1
+ n_cols = training_data.shape[1]
+ last_Xcol = n_cols-2
# check to see if last column contains group labels or nans
groups = training_data[:, -1]
- training_data = training_data[:, 0:n_features]
- if np.isnan(groups).all() is True:
- # if all nans then ignore last column
+ # if all nans then set groups to None
+ if np.isnan(groups).all() == True:
groups = None
# fetch X and y
- X = training_data[:, 0:n_features-1]
- y = training_data[:, -1]
+ X = training_data[:, 0:last_Xcol]
+ y = training_data[:, -2]
return(X, y, groups)
More information about the grass-commit
mailing list