[GRASS-user] v.class.mlR error

,

Hello,

When trying to run the following:

v.class.mlR --verbose segments_map=seg_stats_vec@MAP1 training_map=seg_stats_train_val@MAP1 raster_segments_map=seg_optimum_clump@MAP1 classified_map=out train_class_column=class output_class_column=vote output_prob_column=prob folds=5 partitions=10 tunelength=10 weighting_metric=accuracy processes=6

I get the following error:

Running R now. Following output is R output.
During startup - Warning messages:
1: Setting LC_CTYPE=en_GB.cp1252 failed
2: Setting LC_COLLATE=en_GB.cp1252 failed
3: Setting LC_TIME=en_GB.cp1252 failed
4: Setting LC_MONETARY=en_GB.cp1252 failed
Loading required package: caret
Loading required package: lattice
Loading required package: ggplot2
Error: ‘\S’ is an unrecognized escape in character string starting "“C:\S”
Execution halted
ERROR: There was an error in the execution of the R script.
Please check the R output.
(Wed May 24 11:05:30 2017) Command finished (17 sec)

My GRASS mapset is located in - C:\Sandbox\RGRASS\TEST\MAP1

Given that R takes paths with / rather than ****, I think the issue lies at the start of the R part of the script which reads:

require(caret)
features ← read.csv(“C:\Sandbox\RGRASS\TEST\MAP1.tmp/unknown\5636.0”, sep=“|”, header=TRUE, row.names=1)
training ← read.csv(“C:\Sandbox\RGRASS\TEST\MAP1.tmp/unknown\5636.1”, sep=“|”, header=TRUE, row.names=1)

I have run v.class.mlR on an osgeolive build before, but not on Windows. Is this a Windows specific issue that needs addressing?

I’m using GRASS 7.3.svn (2017).

Kind regards

James

On Wed, May 24, 2017 at 12:14 PM, James Duffy
<james.philip.duffy@gmail.com> wrote:
...

v.class.mlR --verbose segments_map=seg_stats_vec@MAP1

...

My GRASS mapset is located in - C:\Sandbox\RGRASS\TEST\MAP1

Given that R takes paths with / rather than \, I think the issue lies at the
start of the R part of the script which reads:

require(caret)
features <- read.csv("C:\Sandbox\RGRASS\TEST\MAP1\.tmp/unknown\5636.0",
sep="|", header=TRUE, row.names=1)
training <- read.csv("C:\Sandbox\RGRASS\TEST\MAP1\.tmp/unknown\5636.1",
sep="|", header=TRUE, row.names=1)

I have run v.class.mlR on an osgeolive build before, but not on Windows. Is
this a Windows specific issue that needs addressing?

In the script I see things like
                reclass_files[classifier] = tmpfilename.replace("\\", "/")

which is probably unhelpful on Windows. Not sure how to make that
portable, though.

Markus

Le Thu, 25 May 2017 00:25:57 +0200,
Markus Neteler <neteler@osgeo.org> a écrit :

On Wed, May 24, 2017 at 12:14 PM, James Duffy
<james.philip.duffy@gmail.com> wrote:
...
> v.class.mlR --verbose segments_map=seg_stats_vec@MAP1
...
> My GRASS mapset is located in - C:\Sandbox\RGRASS\TEST\MAP1
>
> Given that R takes paths with / rather than \, I think the issue
> lies at the start of the R part of the script which reads:
>
> require(caret)
> features <-
> read.csv("C:\Sandbox\RGRASS\TEST\MAP1\.tmp/unknown\5636.0",
> sep="|", header=TRUE, row.names=1) training <-
> read.csv("C:\Sandbox\RGRASS\TEST\MAP1\.tmp/unknown\5636.1",
> sep="|", header=TRUE, row.names=1)
>
> I have run v.class.mlR on an osgeolive build before, but not on
> Windows. Is this a Windows specific issue that needs addressing?

In the script I see things like
                reclass_files[classifier] = tmpfilename.replace("\\",
"/")

which is probably unhelpful on Windows. Not sure how to make that
portable, though.

I had forgotten that I had already done this elsewhere in the
module... :wink:

It is actually there exactly for Windows: tempfile() creates a path
with \, but in R these have to either be escaped, or modified into / as
R (and I think Windows in general) can handle paths with forward
slashes.

I had answered James, but I now notice that it was from a wrong
address, so the mail didn't get through to the list.

I've now just comitted a fix using the same technique.

James, can you just reinstall v.class.mlR and try again ?

Moritz

Hi Moritz,

Your suggested edits to v.class.mlR.py worked (except you had one too many brackets on the end of each line, so I removed those). Once I updated and saved that script file, the error disappeared.

I have just reinstalled the module using g.extension and tried running v.class.mlR and I again have the original error regarding escaped slashes.

Kind regards

James

···

On 25 May 2017 at 09:15, Moritz Lennert <mlennert@club.worldonline.be> wrote:

Le Thu, 25 May 2017 00:25:57 +0200,
Markus Neteler <neteler@osgeo.org> a écrit :

On Wed, May 24, 2017 at 12:14 PM, James Duffy
<james.philip.duffy@gmail.com> wrote:

v.class.mlR --verbose segments_map=seg_stats_vec@MAP1

My GRASS mapset is located in - C:\Sandbox\RGRASS\TEST\MAP1

Given that R takes paths with / rather than , I think the issue
lies at the start of the R part of the script which reads:

require(caret)
features ←
read.csv(“C:\Sandbox\RGRASS\TEST\MAP1.tmp/unknown\5636.0”,
sep=“|”, header=TRUE, row.names=1) training ←
read.csv(“C:\Sandbox\RGRASS\TEST\MAP1.tmp/unknown\5636.1”,
sep=“|”, header=TRUE, row.names=1)

I have run v.class.mlR on an osgeolive build before, but not on
Windows. Is this a Windows specific issue that needs addressing?

In the script I see things like
reclass_files[classifier] = tmpfilename.replace(“\”,
“/”)

which is probably unhelpful on Windows. Not sure how to make that
portable, though.

I had forgotten that I had already done this elsewhere in the
module… :wink:

It is actually there exactly for Windows: tempfile() creates a path
with , but in R these have to either be escaped, or modified into / as
R (and I think Windows in general) can handle paths with forward
slashes.

I had answered James, but I now notice that it was from a wrong
address, so the mail didn’t get through to the list.

I’ve now just comitted a fix using the same technique.

James, can you just reinstall v.class.mlR and try again ?

Moritz

James Duffy
PhD Researcher
Environment and Sustainability Institute
Penryn Campus
University of Exeter
Penryn
Cornwall
TR10 9FE

Le Thu, 25 May 2017 10:54:18 +0100,
James Duffy <james.philip.duffy@gmail.com> a écrit :

Hi Moritz,

Your suggested edits to v.class.mlR.py worked (except you had one too
many brackets on the end of each line, so I removed those). Once I
updated and saved that script file, the error disappeared.

I have just reinstalled the module using g.extension and tried running
v.class.mlR and I again have the original error regarding escaped
slashes.

I had just copied and pasted from my message, so the problem you found
with one too many brackets was also in the file. I just fixed that.

Sorry, don't have the opportunity to test myself right now, so doing
this a bit blindly.

Moritz

I have just reinstalled the module using g.extension and tried running
v.class.mlR and I again have the original error regarding escaped >slashes.

grass addons for Windows platform are precompiled only once a day on the
server.

So try a little bit later, if the precompiled addon is updated.

HTH

-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/v-class-mlR-error-tp5321603p5321802.html
Sent from the Grass - Users mailing list archive at Nabble.com.

I’ve just tried using a csv as input instead of a vector file and I get the same error, now relating to the path of the csv. Could I suggest also putting in a check / replace line for csv paths if they are entered from a windows machine (especially using the GUI).

Thank you.

James

···

On 25 May 2017 at 11:43, Moritz Lennert <mlennert@club.worldonline.be> wrote:

Le Thu, 25 May 2017 10:54:18 +0100,
James Duffy <james.philip.duffy@gmail.com> a écrit :

Hi Moritz,

Your suggested edits to v.class.mlR.py worked (except you had one too
many brackets on the end of each line, so I removed those). Once I
updated and saved that script file, the error disappeared.

I have just reinstalled the module using g.extension and tried running
v.class.mlR and I again have the original error regarding escaped
slashes.

I had just copied and pasted from my message, so the problem you found
with one too many brackets was also in the file. I just fixed that.

Sorry, don’t have the opportunity to test myself right now, so doing
this a bit blindly.

Moritz

James Duffy
PhD Researcher
Environment and Sustainability Institute
Penryn Campus
University of Exeter
Penryn
Cornwall
TR10 9FE

Le Thu, 25 May 2017 12:18:52 +0100,
James Duffy <james.philip.duffy@gmail.com> a écrit :

I've just tried using a csv as input instead of a vector file and I
get the same error, now relating to the path of the csv. Could I
suggest also putting in a check / replace line for csv paths if they
are entered from a windows machine (especially using the GUI).

I really don't understand why this hasn't hit anyone before. Maybe its
because my MS Windows colleagues work in a Jupyter notebook environment
and things are different there.

I've just committed a fix that uses the same replace technique for the
csv file inputs.

I don't know if for Python addon modules you also have to wait 24 to
get access via g.extension...

Moritz