---
name: i.svm.train
description: "Train a SVM Train a Support Vector Machine"
keywords: [ imagery, svm, classification, training ]
---

# i.svm.train

Train a SVM

Train a Support Vector Machine

=== "Command line"

    **i.svm.train**
    [**-sp**]
    **group**=*name*
    [**subgroup**=*name*]
    **trainingmap**=*name*
    **signaturefile**=*name*
    [**type**=*name*]
    [**kernel**=*name*]
    [**cache**=*cache size*]
    [**degree**=*value*]
    [**gamma**=*value*]
    [**coef0**=*value*]
    [**eps**=*value*]
    [**cost**=*value*]
    [**nu**=*value*]
    [**p**=*value*]
    [**--overwrite**]
    [**--verbose**]
    [**--quiet**]
    [**--qq**]
    [**--ui**]

    Example:

    ```sh
    i.svm.train group=name trainingmap=name signaturefile=name
    ```

=== "Python (grass.tools)"

    *grass.tools.Tools.i_svm_train*(**group**,
        **subgroup**=*None*,
        **trainingmap**,
        **signaturefile**,
        **type**=*"c_svc"*,
        **kernel**=*"rbf"*,
        **cache**=*512*,
        **degree**=*3*,
        **gamma**=*1*,
        **coef0**=*0*,
        **eps**=*None*,
        **cost**=*1*,
        **nu**=*0.5*,
        **p**=*0.1*,
        **flags**=*None*,
        **overwrite**=*None*,
        **verbose**=*None*,
        **quiet**=*None*,
        **superquiet**=*None*)

    Example:

    ```python
    tools = Tools()
    tools.i_svm_train(group="name", trainingmap="name", signaturefile="name")
    ```

    This grass.tools API is experimental in version 8.5 and expected to be stable in version 8.6.

=== "Python (grass.script)"

    *grass.script.run_command*("***i.svm.train***",
        **group**,
        **subgroup**=*None*,
        **trainingmap**,
        **signaturefile**,
        **type**=*"c_svc"*,
        **kernel**=*"rbf"*,
        **cache**=*512*,
        **degree**=*3*,
        **gamma**=*1*,
        **coef0**=*0*,
        **eps**=*None*,
        **cost**=*1*,
        **nu**=*0.5*,
        **p**=*0.1*,
        **flags**=*None*,
        **overwrite**=*None*,
        **verbose**=*None*,
        **quiet**=*None*,
        **superquiet**=*None*)

    Example:

    ```python
    gs.run_command("i.svm.train", group="name", trainingmap="name", signaturefile="name")
    ```

## Parameters

=== "Command line"

    **group**=*name* **[required]**  
    &nbsp;&nbsp;&nbsp;&nbsp;Maps with feature values (attributes)  
    **subgroup**=*name*  
    &nbsp;&nbsp;&nbsp;&nbsp;Name of input imagery subgroup  
    **trainingmap**=*name* **[required]**  
    &nbsp;&nbsp;&nbsp;&nbsp;Map with training labels or target values  
    **signaturefile**=*name* **[required]**  
    &nbsp;&nbsp;&nbsp;&nbsp;Name for output file containing result signatures  
    **type**=*name*  
    &nbsp;&nbsp;&nbsp;&nbsp;Type of SVM  
    &nbsp;&nbsp;&nbsp;&nbsp;Allowed values: *c_svc, nu_svc, one_class, epsilon_svr, nu_svr*  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *c_svc*  
    &nbsp;&nbsp;&nbsp;&nbsp;**c_svc**: C-SVM classification  
    &nbsp;&nbsp;&nbsp;&nbsp;**nu_svc**: nu-SVM classification  
    &nbsp;&nbsp;&nbsp;&nbsp;**one_class**: one-class SVM  
    &nbsp;&nbsp;&nbsp;&nbsp;**epsilon_svr**: epsilon-SVM regression  
    &nbsp;&nbsp;&nbsp;&nbsp;**nu_svr**: nu-SVM regression  
    **kernel**=*name*  
    &nbsp;&nbsp;&nbsp;&nbsp;SVM kernel type  
    &nbsp;&nbsp;&nbsp;&nbsp;Allowed values: *linear, poly, rbf, sigmoid*  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *rbf*  
    &nbsp;&nbsp;&nbsp;&nbsp;**linear**: u'\*v  
    &nbsp;&nbsp;&nbsp;&nbsp;**poly**: (gamma\*u'\*v + coef0)^degree  
    &nbsp;&nbsp;&nbsp;&nbsp;**rbf**: exp(-gamma\*|u-v|^2)  
    &nbsp;&nbsp;&nbsp;&nbsp;**sigmoid**: tanh(gamma\*u'\*v + coef0)  
    **cache**=*cache size*  
    &nbsp;&nbsp;&nbsp;&nbsp;LIBSVM kernel cache size in MB  
    &nbsp;&nbsp;&nbsp;&nbsp;Allowed values: *1-*  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *512*  
    **degree**=*value*  
    &nbsp;&nbsp;&nbsp;&nbsp;Degree in kernel function  
    &nbsp;&nbsp;&nbsp;&nbsp;Allowed values: *0-*  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *3*  
    **gamma**=*value*  
    &nbsp;&nbsp;&nbsp;&nbsp;Gamma in kernel function  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *1*  
    **coef0**=*value*  
    &nbsp;&nbsp;&nbsp;&nbsp;coef0 in kernel function  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *0*  
    **eps**=*value*  
    &nbsp;&nbsp;&nbsp;&nbsp;Tolerance of termination criterion  
    &nbsp;&nbsp;&nbsp;&nbsp;Defaults to 0.00001 for nu-SVC and 0.001 for others  
    **cost**=*value*  
    &nbsp;&nbsp;&nbsp;&nbsp;Cost of constraints violation  
    &nbsp;&nbsp;&nbsp;&nbsp;The parameter C of C-SVC, epsilon-SVR, and nu-SVR  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *1*  
    **nu**=*value*  
    &nbsp;&nbsp;&nbsp;&nbsp;The parameter nu of nu-SVC, one-class SVM, and nu-SVR  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *0.5*  
    **p**=*value*  
    &nbsp;&nbsp;&nbsp;&nbsp;The epsilon in epsilon-insensitive loss function of epsilon-SVM regression  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *0.1*  
    **-s**  
    &nbsp;&nbsp;&nbsp;&nbsp;Do not use the shrinking heuristics  
    &nbsp;&nbsp;&nbsp;&nbsp;Defaults to use the shrinking heuristics  
    **-p**  
    &nbsp;&nbsp;&nbsp;&nbsp;Train a SVC or SVR model for probability estimates  
    &nbsp;&nbsp;&nbsp;&nbsp;Defaults to no probabilities in model  
    **--overwrite**  
    &nbsp;&nbsp;&nbsp;&nbsp;Allow output files to overwrite existing files  
    **--help**  
    &nbsp;&nbsp;&nbsp;&nbsp;Print usage summary  
    **--verbose**  
    &nbsp;&nbsp;&nbsp;&nbsp;Verbose module output  
    **--quiet**  
    &nbsp;&nbsp;&nbsp;&nbsp;Quiet module output  
    **--qq**  
    &nbsp;&nbsp;&nbsp;&nbsp;Very quiet module output  
    **--ui**  
    &nbsp;&nbsp;&nbsp;&nbsp;Force launching GUI dialog

=== "Python (grass.tools)"

    **group** : str, *required*  
    &nbsp;&nbsp;&nbsp;&nbsp;Maps with feature values (attributes)  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: input, group, *name*  
    **subgroup** : str, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Name of input imagery subgroup  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: input, subgroup, *name*  
    **trainingmap** : str | np.ndarray, *required*  
    &nbsp;&nbsp;&nbsp;&nbsp;Map with training labels or target values  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: input, raster, *name*  
    **signaturefile** : str, *required*  
    &nbsp;&nbsp;&nbsp;&nbsp;Name for output file containing result signatures  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: output, sigfile, *name*  
    **type** : str, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Type of SVM  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: *name*  
    &nbsp;&nbsp;&nbsp;&nbsp;Allowed values: *c_svc, nu_svc, one_class, epsilon_svr, nu_svr*  
    &nbsp;&nbsp;&nbsp;&nbsp;**c_svc**: C-SVM classification  
    &nbsp;&nbsp;&nbsp;&nbsp;**nu_svc**: nu-SVM classification  
    &nbsp;&nbsp;&nbsp;&nbsp;**one_class**: one-class SVM  
    &nbsp;&nbsp;&nbsp;&nbsp;**epsilon_svr**: epsilon-SVM regression  
    &nbsp;&nbsp;&nbsp;&nbsp;**nu_svr**: nu-SVM regression  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *c_svc*  
    **kernel** : str, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;SVM kernel type  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: *name*  
    &nbsp;&nbsp;&nbsp;&nbsp;Allowed values: *linear, poly, rbf, sigmoid*  
    &nbsp;&nbsp;&nbsp;&nbsp;**linear**: u'\*v  
    &nbsp;&nbsp;&nbsp;&nbsp;**poly**: (gamma\*u'\*v + coef0)^degree  
    &nbsp;&nbsp;&nbsp;&nbsp;**rbf**: exp(-gamma\*|u-v|^2)  
    &nbsp;&nbsp;&nbsp;&nbsp;**sigmoid**: tanh(gamma\*u'\*v + coef0)  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *rbf*  
    **cache** : int, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;LIBSVM kernel cache size in MB  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: *cache size*  
    &nbsp;&nbsp;&nbsp;&nbsp;Allowed values: *1-*  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *512*  
    **degree** : int, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Degree in kernel function  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: *value*  
    &nbsp;&nbsp;&nbsp;&nbsp;Allowed values: *0-*  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *3*  
    **gamma** : float, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Gamma in kernel function  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: *value*  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *1*  
    **coef0** : float, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;coef0 in kernel function  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: *value*  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *0*  
    **eps** : float, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Tolerance of termination criterion  
    &nbsp;&nbsp;&nbsp;&nbsp;Defaults to 0.00001 for nu-SVC and 0.001 for others  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: *value*  
    **cost** : float, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Cost of constraints violation  
    &nbsp;&nbsp;&nbsp;&nbsp;The parameter C of C-SVC, epsilon-SVR, and nu-SVR  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: *value*  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *1*  
    **nu** : float, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;The parameter nu of nu-SVC, one-class SVM, and nu-SVR  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: *value*  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *0.5*  
    **p** : float, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;The epsilon in epsilon-insensitive loss function of epsilon-SVM regression  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: *value*  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *0.1*  
    **flags** : str, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Allowed values: *s*, *p*  
    &nbsp;&nbsp;&nbsp;&nbsp;**s**  
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Do not use the shrinking heuristics  
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Defaults to use the shrinking heuristics  
    &nbsp;&nbsp;&nbsp;&nbsp;**p**  
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Train a SVC or SVR model for probability estimates  
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Defaults to no probabilities in model  
    **overwrite** : bool, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Allow output files to overwrite existing files  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *None*  
    **verbose** : bool, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Verbose module output  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *None*  
    **quiet** : bool, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Quiet module output  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *None*  
    **superquiet** : bool, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Very quiet module output  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *None*  

    Returns:

    **result** : grass.tools.support.ToolResult | None  
    If the tool produces text as standard output, a *ToolResult* object will be returned. Otherwise, `None` will be returned.

    Raises:

    *grass.tools.ToolError*: When the tool ended with an error.

=== "Python (grass.script)"

    **group** : str, *required*  
    &nbsp;&nbsp;&nbsp;&nbsp;Maps with feature values (attributes)  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: input, group, *name*  
    **subgroup** : str, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Name of input imagery subgroup  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: input, subgroup, *name*  
    **trainingmap** : str, *required*  
    &nbsp;&nbsp;&nbsp;&nbsp;Map with training labels or target values  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: input, raster, *name*  
    **signaturefile** : str, *required*  
    &nbsp;&nbsp;&nbsp;&nbsp;Name for output file containing result signatures  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: output, sigfile, *name*  
    **type** : str, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Type of SVM  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: *name*  
    &nbsp;&nbsp;&nbsp;&nbsp;Allowed values: *c_svc, nu_svc, one_class, epsilon_svr, nu_svr*  
    &nbsp;&nbsp;&nbsp;&nbsp;**c_svc**: C-SVM classification  
    &nbsp;&nbsp;&nbsp;&nbsp;**nu_svc**: nu-SVM classification  
    &nbsp;&nbsp;&nbsp;&nbsp;**one_class**: one-class SVM  
    &nbsp;&nbsp;&nbsp;&nbsp;**epsilon_svr**: epsilon-SVM regression  
    &nbsp;&nbsp;&nbsp;&nbsp;**nu_svr**: nu-SVM regression  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *c_svc*  
    **kernel** : str, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;SVM kernel type  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: *name*  
    &nbsp;&nbsp;&nbsp;&nbsp;Allowed values: *linear, poly, rbf, sigmoid*  
    &nbsp;&nbsp;&nbsp;&nbsp;**linear**: u'\*v  
    &nbsp;&nbsp;&nbsp;&nbsp;**poly**: (gamma\*u'\*v + coef0)^degree  
    &nbsp;&nbsp;&nbsp;&nbsp;**rbf**: exp(-gamma\*|u-v|^2)  
    &nbsp;&nbsp;&nbsp;&nbsp;**sigmoid**: tanh(gamma\*u'\*v + coef0)  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *rbf*  
    **cache** : int, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;LIBSVM kernel cache size in MB  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: *cache size*  
    &nbsp;&nbsp;&nbsp;&nbsp;Allowed values: *1-*  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *512*  
    **degree** : int, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Degree in kernel function  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: *value*  
    &nbsp;&nbsp;&nbsp;&nbsp;Allowed values: *0-*  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *3*  
    **gamma** : float, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Gamma in kernel function  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: *value*  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *1*  
    **coef0** : float, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;coef0 in kernel function  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: *value*  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *0*  
    **eps** : float, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Tolerance of termination criterion  
    &nbsp;&nbsp;&nbsp;&nbsp;Defaults to 0.00001 for nu-SVC and 0.001 for others  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: *value*  
    **cost** : float, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Cost of constraints violation  
    &nbsp;&nbsp;&nbsp;&nbsp;The parameter C of C-SVC, epsilon-SVR, and nu-SVR  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: *value*  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *1*  
    **nu** : float, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;The parameter nu of nu-SVC, one-class SVM, and nu-SVR  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: *value*  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *0.5*  
    **p** : float, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;The epsilon in epsilon-insensitive loss function of epsilon-SVM regression  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: *value*  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *0.1*  
    **flags** : str, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Allowed values: *s*, *p*  
    &nbsp;&nbsp;&nbsp;&nbsp;**s**  
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Do not use the shrinking heuristics  
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Defaults to use the shrinking heuristics  
    &nbsp;&nbsp;&nbsp;&nbsp;**p**  
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Train a SVC or SVR model for probability estimates  
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Defaults to no probabilities in model  
    **overwrite** : bool, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Allow output files to overwrite existing files  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *None*  
    **verbose** : bool, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Verbose module output  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *None*  
    **quiet** : bool, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Quiet module output  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *None*  
    **superquiet** : bool, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Very quiet module output  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *None*

## DESCRIPTION

*i.svm.train* finds parameters for a Support Vector Machine and stores
them in a signature file for later usage by
[i.svm.predict](i.svm.predict.md).

Internally the module performs input value rescaling of each of imagery
group rasters by mean normalisation based on minimum and maximum value
present in the raster metadata. Rescaling parameters are written into
the signature file for use during prediction.

## NOTES

*i.svm.train* internally is using the LIBSVM. For introduction into
value prediction or estimation with LIBSVM, see [a Practical Guide to
Support Vector
Classification](https://www.csie.ntu.edu.tw/~cjlin/papers/guide/guide.pdf)
by Chih-Wei Hsu, Chih-Chung Chang, and Chih-Jen Lin.

It is strongly suggested to have semantic labels set for each raster map
in the training data (feature value) imagery group. Use
[r.support](r.support.md) to set semantic labels.

## PERFORMANCE

SVM training is done by loading all training data into memory. In a case
of large input raster files, use sparse label rasters (e.g. raster
points or small patches instead of uninterrupted cover).

During the training process there is no progress output printed.
Training with large number of data points can take significant time -
just be patient.

By default the shrinking heuristics option of LIBSVM is enabled. It
should not impact the outcome, just the training time. On some input
parameter and data combinations training with the shrinking heuristics
disabled might be faster.

The *cache* parameter determines the maximum memory allocated for kernel
caching to enhance computational speed. It's important to note that the
actual module's memory consumption may vary from this setting, as it
solely impacts LIBSVM's internal caching. The cache is utilized on an
as-needed basis, so it's unlikely to reach the specified value.

## EXAMPLE

This is the first part of classification process. See
[i.svm.predict](i.svm.predict.md) for the second part.

Train a SVM to identify land use classes according to the 1996 land use
map *landuse96_28m* and then classify a LANDSAT scene from October of
2002. Example requires the nc_spm_08 dataset.

```sh
# Align computation region to the scene
g.region raster=lsat7_2002_10 -p

# store VIZ, NIR, MIR into group/subgroup
i.group group=lsat7_2002 subgroup=res_30m \
    input=lsat7_2002_10,lsat7_2002_20,lsat7_2002_30,lsat7_2002_40,lsat7_2002_50,lsat7_2002_70

# Now digitize training areas "training" with the digitizer
# and convert to raster model with v.to.rast
v.to.rast input=training output=training use=cat label_column=label
# If you are just playing around and do not care about the accuracy of outcome,
# just use one of existing maps instead e.g.
# r.random input=landuse96_28m npoints=10000 raster=training -s

# Train the SVM
i.svm.train group=lsat7_2002 subgroup=res_30m \
    trainingmap=training signaturefile=landuse96_rnd_points

# Go to i.svm.predict for the next step.
```

## SEE ALSO

*Predict values: [i.svm.predict](i.svm.predict.md)  
Set semantic labels: [r.support](r.support.md)  
Other classification modules: [i.maxlik](i.maxlik.md),
[i.smap](i.smap.md)*  
LIBSVM home page: [LIBSVM - A Library for Support Vector
Machines](https://www.csie.ntu.edu.tw/~cjlin/libsvm/)

## REFERENCES

Please cite both - LIBSVM and i.svm.

- For i.svm.\* modules:  
  Nartiss, M., & Melniks, R. (2023). Improving pixel-­based
  classification of GRASS GIS with support vector machine. Transactions
  in GIS, 00, 1–16. <https://doi.org/10.1111/tgis.13102>
- For LIBSVM:  
  Chang, C.-C., & Lin, C.-J. (2011). LIBSVM : a library for support
  vector machines. ACM Transactions on Intelligent Systems and
  Technology, 2:27:1--27:27.

## AUTHOR

Maris Nartiss, University of Latvia.

## SOURCE CODE

Available at: [i.svm.train source code](https://github.com/OSGeo/grass/tree/main/imagery/i.svm.train)
([history](https://github.com/OSGeo/grass/commits/main/imagery/i.svm.train))  
Latest change: Thursday May 14 12:46:40 2026 in commit [3301c12](https://github.com/OSGeo/grass/commit/3301c12033b1d3a68d956322dddeaf5e4493978d)
