<p dir="ltr"></p>
<p dir="ltr">On 11 Nov 2016 11:08 am, "Moritz Lennert" <<a href="mailto:mlennert@club.worldonline.be">mlennert@club.worldonline.be</a>> wrote:<br>
><br>
> On 11/11/16 11:36, James Duffy wrote:<br>
>><br>
>><br>
>><br>
>> On 11 November 2016 at 10:07, Moritz Lennert<br>
>> <<a href="mailto:mlennert@club.worldonline.be">mlennert@club.worldonline.be</a> <mailto:<a href="mailto:mlennert@club.worldonline.be">mlennert@club.worldonline.be</a>>> wrote:<br>
>><br>
>><br>
>><br>
>>     Le 11 novembre 2016 10:21:11 GMT+01:00, James Duffy<br>
>>     <<a href="mailto:james.philip.duffy@gmail.com">james.philip.duffy@gmail.com</a> <mailto:<a href="mailto:james.philip.duffy@gmail.com">james.philip.duffy@gmail.com</a>>><br>
>><br>
>>     a écrit :<br>
>>     >On 10 November 2016 at 19:37, Moritz Lennert<br>
>>     ><<a href="mailto:mlennert@club.worldonline.be">mlennert@club.worldonline.be</a> <mailto:<a href="mailto:mlennert@club.worldonline.be">mlennert@club.worldonline.be</a>>><br>
>><br>
>>     >wrote:<br>
>>     ><br>
>>     >><br>
>>     >><br>
>>     >> Le 10 novembre 2016 15:45:59 GMT+01:00, James Duffy <<br>
>>     >> <a href="mailto:james.philip.duffy@gmail.com">james.philip.duffy@gmail.com</a><br>
>>     <mailto:<a href="mailto:james.philip.duffy@gmail.com">james.philip.duffy@gmail.com</a>>> a écrit :<br>
>><br>
>>     >> >Hello,<br>
>>     >> ><br>
>>     >> >I'm trying to run v.class.mlR on a vector map, with a separate<br>
>>     >vector<br>
>>     >> >map<br>
>>     >> >containing my training data. Currently I have two classes '1' and<br>
>>     >'2'<br>
>>     >> >stored in the column 'class'. My region is set to that of the<br>
>>     >segments<br>
>>     >> >to<br>
>>     >> >be classified. I run the following command:<br>
>>     >> ><br>
>>     >> >v.class.mlR segments_map=gp_seg_stats_vec@gp1 \<br>
>>     >> >training_map=gp_seg_sed_grass@gp1 train_class_column=class \<br>
>>     >> >output_class_column=vote output_prob_column=prob folds=5 \<br>
>>     >> >partitions=10 tunelength=10 weighting_metric=accuracy<br>
>>     >> ><br>
>>     >> >And get the following output:<br>
>>     >> ><br>
>>     >> >Running R now. Following output is R output.<br>
>>     >> >Loading required package: caret<br>
>>     >> >Loading required package: lattice<br>
>>     >> >Loading required package: ggplot2<br>
>>     >> >Loading required package: kernlab<br>
>>     >> ><br>
>>     >> >Attaching package: ‘kernlab’<br>
>>     >> ><br>
>>     >> >The following object is masked from ‘package:ggplot2’:<br>
>>     >> ><br>
>>     >> >    alpha<br>
>>     >> ><br>
>>     >> >Loading required package: randomForest<br>
>>     >> >randomForest 4.6-12<br>
>>     >> >Type rfNews() to see new features/changes/bug fixes.<br>
>>     >> ><br>
>>     >> >Attaching package: ‘randomForest’<br>
>>     >> ><br>
>>     >> >The following object is masked from ‘package:ggplot2’:<br>
>>     >> ><br>
>>     >> >    margin<br>
>>     >> ><br>
>>     >> >Loading required package: rpart<br>
>>     >> >Error in eval(expr, envir, enclos) : object 'cat_' not found<br>
>>     >> >Calls: data.frame ... predict.train -> model.frame -><br>
>>     >> >model.frame.default<br>
>>     >> >-> eval -> eval<br>
>>     >> >Execution halted<br>
>>     >> >ERROR: There was an error in the execution of the R script.<br>
>>     >> >       Please check the R output.<br>
>>     >> ><br>
>>     >> ><br>
>>     >> >I'm not entirely sure where it's looking for anything called 'cat_'.<br>
>>     >> ><br>
>>     >> >Any help much appreciated please.<br>
>>     >><br>
>>     >><br>
>>     >> Could you send us the output of <a href="http://v.info">v.info</a> <<a href="http://v.info">http://v.info</a>> -c for<br>
>><br>
>>     both of the input maps<br>
>>     >?<br>
>>     >><br>
>>     ><br>
>>     ><a href="http://v.info">v.info</a> <<a href="http://v.info">http://v.info</a>> -c --verbose map=gp_seg_stats_vec@gp1<br>
>><br>
>>     ><br>
>>     >INTEGER|cat<br>
>>     >DOUBLE PRECISION|area<br>
>>     >DOUBLE PRECISION|perimeter<br>
>>     >DOUBLE PRECISION|fd<br>
>>     >DOUBLE PRECISION|gpo1min<br>
>>     >DOUBLE PRECISION|com_circ<br>
>>     >DOUBLE PRECISION|gpo1max<br>
>>     >DOUBLE PRECISION|gpo1range<br>
>>     >DOUBLE PRECISION|gpo1mean<br>
>>     >DOUBLE PRECISION|gpo1stdev<br>
>>     >DOUBLE PRECISION|gpo1var<br>
>>     >DOUBLE PRECISION|gpo1sum<br>
>>     >DOUBLE PRECISION|gpo2min<br>
>>     >DOUBLE PRECISION|gpo2max<br>
>>     >DOUBLE PRECISION|gpo2range<br>
>>     >DOUBLE PRECISION|gpo2mean<br>
>>     >DOUBLE PRECISION|gpo2stdev<br>
>>     >DOUBLE PRECISION|gpo2var<br>
>>     >DOUBLE PRECISION|gpo3min<br>
>>     >DOUBLE PRECISION|gpo3max<br>
>>     >DOUBLE PRECISION|gpo3range<br>
>>     >DOUBLE PRECISION|gpo3mean<br>
>>     >DOUBLE PRECISION|gpo3stdev<br>
>>     >DOUBLE PRECISION|gpo3var<br>
>>     >DOUBLE PRECISION|gpo3sum<br>
>>     >DOUBLE PRECISION|gpo4min<br>
>>     >DOUBLE PRECISION|gpo4max<br>
>>     >DOUBLE PRECISION|gpo4range<br>
>>     >DOUBLE PRECISION|gpo4mean<br>
>>     >DOUBLE PRECISION|gpo4stdev<br>
>>     >DOUBLE PRECISION|gpo4var<br>
>>     >DOUBLE PRECISION|gpo4sum<br>
>>     >Displaying column types/names for database connection of layer <1>:<br>
>>     >(Fri Nov 11 09:17:34 2016) Command finished (0 sec)<br>
>>     ><br>
>>     ><a href="http://v.info">v.info</a> <<a href="http://v.info">http://v.info</a>> -c --verbose map=gp_seg_sed_grass@gp1<br>
>><br>
>>     ><br>
>>     >INTEGER|cat<br>
>>     >INTEGER|cat_<br>
>><br>
>>     This is the problem. cat_ using the training data, but not in the<br>
>>     segments file. Erasing this column from the training data should be<br>
>>     enough to solve the problem.<br>
>><br>
>><br>
>> Ok, i'm pretty sure that the script made that as the shapefile i've read<br>
>> into GRASS didn't have 'cat_' has a column in the attribute table.<br>
>><br>
>> I have deleted it, and now get the following when trying to run the<br>
>> v.class.mlR code I posted above:<br>
>><br>
>> Loading required package: rpart<br>
>> Error in model.frame.default(Terms, newdata, na.action = na.action, xlev<br>
>> = object$xlevels) :<br>
>>   invalid type (closure) for variable 'type'<br>
>> Calls: data.frame ... predict.train -> model.frame -> model.frame.default<br>
>> Execution halted<br>
>> ERROR: There was an error in the execution of the R script.<br>
>>        Please check the R output.<br>
>><br>
>><br>
>> 'type' is a character column which just has one word descriptions of my<br>
>> cover types in it. Does the code not deal well with non-numeric attributes?<br>
><br>
><br>
><br>
> Probably not. I'll have to check into this, but the main issue actually is that the module currently assumes that all columns other than cat and class are used as independent variables for the model. IIUC, your 'type' variable is just a label for your class, or ? Then this should not be part of your training data either.<br>
><br>
> As a todo for the module would be to add a parameter that allows to list the columns to use for modeling, but currently it just uses all columns in the file.<br>
></p>
<p dir="ltr">Thanks for the suggestion. Removing that column worked. Could I suggest adding in a check either pre reading into R or pre-analysis in R to drop any character columns from the modelling but keep them in the attribute table?</p>
<p dir="ltr">James<br>
> Moritz<br></p>