.TH v.class.mlpy 1 "" "GRASS 7.8.6" "GRASS GIS User's Manual"
.SH NAME
\fI\fBv.class.mlpy.py\fR\fR  \- Vector supervised classification tool which uses attributes as classification parametres (order of columns matters, names not), cat column identifies feature, class_column is excluded from classification parametres.
.SH KEYWORDS
vector, classification, supervised, machine learning
.SH SYNOPSIS
\fBv.class.mlpy.py\fR
.br
\fBv.class.mlpy.py \-\-help\fR
.br
\fBv.class.mlpy.py\fR \fBinput\fR=\fIname\fR \fBtraining\fR=\fIname\fR  [\fBclass_column\fR=\fIstring\fR]   [\fBcolumns\fR=\fIstring\fR[,\fIstring\fR,...]]   [\-\-\fBhelp\fR]  [\-\-\fBverbose\fR]  [\-\-\fBquiet\fR]  [\-\-\fBui\fR]
.SS Flags:
.IP "\fB\-\-help\fR" 4m
.br
Print usage summary
.IP "\fB\-\-verbose\fR" 4m
.br
Verbose module output
.IP "\fB\-\-quiet\fR" 4m
.br
Quiet module output
.IP "\fB\-\-ui\fR" 4m
.br
Force launching GUI dialog
.SS Parameters:
.IP "\fBinput\fR=\fIname\fR \fB[required]\fR" 4m
.br
Name of vector map
.br
Input vector map (attribut table required)
.IP "\fBtraining\fR=\fIname\fR \fB[required]\fR" 4m
.br
Name of vector map
.br
Training vector map (attribut table required)
.IP "\fBclass_column\fR=\fIstring\fR" 4m
.br
Name of column containing class
.br
Used for both input/output and training dataset. If column does not exists in input map attribute table, it will be created.
.br
Default: \fIclass\fR
.IP "\fBcolumns\fR=\fIstring[,\fIstring\fR,...]\fR" 4m
.br
Columns to be used in classification
.br
Columns to be used in classification. If left empty, all columns will be used for classification except for class_column and cat column.
.SH DESCRIPTION
.PP
The \fIv.class.mlpy\fR module is a tool for supervised vector classification.
It is built on top of the Python \fImlpy\fR library [Albanese2012].
The classification is based on attribute values. The geometry is not taken into
account, so the module does not depend on the feature types used in the map.
The classification is supervised, so the training dataset is always required.
.PP
The attribute table of training map (dataset) has to contain a column with
the class. Required type of class column is integer. Expected type of other
columns is double or integer.
.SH NOTES
.PP
This module requires the user to have \fImlpy\fR library installed.
However, this is not an issue because \fImlpy\fR library is
free and open source and can be quickly downloaded and installed.
Furthermore, library is available for all major platforms supported by
GRASS GIS. You find \fImlpy\fR download and installation
instructions at the official \fImlpy\fR website
(http://mlpy.sourceforge.net/).
.SH EXAMPLE
.PP
This is an example in a North Carolina sample dataset. It uses several
raster maps and generates (spatially) random vector data for classification
from raster maps. The random data used as input to
the classification and represent training dataset and dataset to be classified
in the real use case.
.PP
Two sets of random points are generated containing 100 and 1000 points.
Then, an attribute table is created for both maps and attributes are derived
from digital values of raster maps (Landsat images) at points locations.
These attribute table columns are input to the classification.
The smaller dataset is used as training dataset. Classes are taken from
the raster map which is a part of the sample dataset as an example result
of some former classification. The number of classes in training dataset is 6.
.br
.nf
\fC
# the example code uses unix\-like syntax for continuation lines, for\-loops,
# variables and assigning command outputs to variables
# generate random points to be used as an input
v.random output=points_unknown n=1000
v.db.addtable map=points_unknown
# generate random points to be used as a training dataset
v.random output=points_known n=100
v.db.addtable map=points_known
# fill attribute tables
MAPS=$(g.list type=rast pattern=\(dqlsat*\(dq exclude=\(dq*87*\(dq mapset=PERMANENT sep=\(dq \(dq)
let NUM=0
for MAP in $MAPS
do
let NUM++
    v.db.addcolumn map=points_unknown layer=1 columns=\(dqmap_$NUM integer\(dq
    v.db.addcolumn map=points_known layer=1 columns=\(dqmap_$NUM integer\(dq
    v.what.rast map=points_unknown layer=1 raster=$MAP column=map_$NUM
    v.what.rast map=points_known layer=1 raster=$MAP column=map_$NUM
done
# fill the class (category) column with correct values for training dataset
v.db.addcolumn map=points_known layer=1 columns=\(dqlandclass integer\(dq
v.what.rast map=points_known layer=1 raster=landclass96 column=landclass
# TODO: syntax in the setting of color tables is strange, fix example
# set color table
r.colors.out map=landclass96 rules=tmp_color_rules_file \(rs
| v.colors map=points_known column=landclass layer=1 rules=tmp_color_rules_file
rm tmp_color_rules_file
# do the classification
v.class.mlpy input=points_unknown training=points_known class_column=landclass
# set color table
r.colors.out map=landclass96 rules=tmp_color_rules_file \(rs
| v.colors map=points_unknown column=landclass layer=1 rules=tmp_color_rules_file
rm tmp_color_rules_file
\fR
.fi
.SH SEE ALSO
\fIv.class\fR for unsupervised attributes
classification,
\fIv.to.db\fR for populating attribute values
from vector features,
\fIv.what.rast\fR for uploading raster
values to attribute columns,
\fIv.rast.stats\fR for uploading raster
statistics to attribute columns,
\fIv.class.ml\fR for a more powerful vector
classification module which uses \fIscikit\-learn\fR
.SH REFERENCES
D. Albanese, R. Visintainer, S. Merler, S. Riccadonna, G. Jurman, C. Furlanello.
\fImlpy: Machine Learning Python\fR, 2012.
arXiv:1202.6548
.SH AUTHOR
Vaclav Petras,
Czech Technical University in Prague, Czech Republic
.SH SOURCE CODE
.PP
Available at: v.class.mlpy source code (history)
.PP
Main index |
Vector index |
Topics index |
Keywords index |
Graphical index |
Full index
.PP
© 2003\-2021
GRASS Development Team,
GRASS GIS 7.8.6 Reference Manual
