On 31/05/18 14:25, Helmut Kudrnovsky wrote:
Helmut Kudrnovsky wrote
Yes, obviously. Sorry for that.
no problem.
patch applied:
-------------
v.class.mlR --verbose segments_map=lsat7_segs_stats training_map=training
train_class_colum=class processes=3
Running R now. Following output is R output.
Loading required package: caret
Loading required package: lattice
Loading required package: ggplot2
Loading required package: foreach
Loading required package: iterators
Loading required package: parallel
Warning message:
In nominalTrainWorkflow(x = x, y = y, wts = weights, info = trainInfo, :
There were missing values in resampled performance measures.
Error: '\g' is an unrecognized escape in character string starting "'D:\g"
------------
Error: '\g' is an unrecognized escape in character string starting "'D:\g"
there seems to be a path issue with shlashes
added a g.message about the temporary file:
v.class.mlR --verbose segments_map=lsat7_segs_stats training_map=training
train_class_colum=class processes=3
temporary file: D:\grassdata\nc_spm_08_grass7\user1\.tmp/unknown\10300.3.csv
AFAIR R in windows needs slashes, e.g.
getwd()
[1] "C:/Users/myuser/Documents"
Right.
Would replacing tempfile() with tempfile().replace('\\', '/') in line
486 help ?
ISTR that there was a function for this somewhere, but can't find it in
a quick search.
Attached the again entire patch, but with the above change.
Moritz
Index: v.class.mlR.py
===================================================================
--- v.class.mlR.py (révision 72333)
+++ v.class.mlR.py (copie de travail)
@@ -233,8 +233,8 @@
gscript.try_remove(feature_vars)
if trainmap:
gscript.try_remove(training_vars)
- gscript.try_remove(model_output)
- gscript.try_remove(model_output_desc)
+ gscript.try_remove(model_output_csv)
+ gscript.try_remove(model_output_csvt)
gscript.try_remove(r_commands)
if reclass_files:
for reclass_file in reclass_files.itervalues():
@@ -251,8 +251,8 @@
global trainmap
global feature_vars
global training_vars
- global model_output
- global model_output_desc
+ global model_output_csv
+ global model_output_csvt
global temptable
global r_commands
global reclass_files
@@ -483,8 +483,9 @@
r_file.write("\n")
if allmap and not flags['f']:
- model_output = '.gscript_tmp_model_output_%d.csv' % os.getpid()
- write_string = "write.csv(resultsdf, '%s'," % model_output
+ model_output = gscript.tempfile().replace('\\', '/')
+ model_output_csv = model_output + '.csv'
+ write_string = "write.csv(resultsdf, '%s'," % model_output_csv
write_string += " row.names=FALSE, quote=FALSE)"
r_file.write(write_string)
r_file.write("\n")
@@ -575,10 +576,10 @@
if allmap and not flags['f']:
- model_output_desc = model_output + 't'
+ model_output_csvt = model_output + '.csvt'
temptable = 'classif_tmp_table_%d' % os.getpid()
- f = open(model_output_desc, 'w')
+ f = open(model_output_csvt, 'w')
header_string = '"Integer"'
if flags['i']:
for classifier in classifiers:
@@ -595,7 +596,7 @@
gscript.message("Loading results into attribute table")
gscript.run_command('db.in.ogr',
- input_=model_output,
+ input_=model_output_csv,
output=temptable,
overwrite=True,
quiet=True)
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user