---
name: i.svm.predict
description: "Predict with a SVM Predict with a Support Vector Machine"
keywords: [ imagery, svm, classification, prediction, regression ]
---

# i.svm.predict

Predict with a SVM

Predict with a Support Vector Machine

=== "Command line"

    **i.svm.predict**
    **group**=*name*
    [**subgroup**=*name*]
    **signaturefile**=*name*
    **output**=*name*
    [**cache**=*cache size*]
    [**--overwrite**]
    [**--verbose**]
    [**--quiet**]
    [**--qq**]
    [**--ui**]

    Example:

    ```sh
    i.svm.predict group=name signaturefile=name output=name
    ```

=== "Python (grass.tools)"

    *grass.tools.Tools.i_svm_predict*(**group**,
        **subgroup**=*None*,
        **signaturefile**,
        **output**,
        **cache**=*512*,
        **overwrite**=*None*,
        **verbose**=*None*,
        **quiet**=*None*,
        **superquiet**=*None*)

    Example:

    ```python
    tools = Tools()
    tools.i_svm_predict(group="name", signaturefile="name", output="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.predict***",
        **group**,
        **subgroup**=*None*,
        **signaturefile**,
        **output**,
        **cache**=*512*,
        **overwrite**=*None*,
        **verbose**=*None*,
        **quiet**=*None*,
        **superquiet**=*None*)

    Example:

    ```python
    gs.run_command("i.svm.predict", group="name", signaturefile="name", output="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  
    **signaturefile**=*name* **[required]**  
    &nbsp;&nbsp;&nbsp;&nbsp;Name of input file containing signatures  
    **output**=*name* **[required]**  
    &nbsp;&nbsp;&nbsp;&nbsp;Output map with predicted class or calculated value  
    **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*  
    **--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*  
    **signaturefile** : str, *required*  
    &nbsp;&nbsp;&nbsp;&nbsp;Name of input file containing signatures  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: input, sigfile, *name*  
    **output** : str | type(np.ndarray) | type(np.array) | type(gs.array.array), *required*  
    &nbsp;&nbsp;&nbsp;&nbsp;Output map with predicted class or calculated value  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: output, raster, *name*  
    **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*  
    **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 | np.ndarray | tuple[np.ndarray] | None  
    If the tool produces text as standard output, a *ToolResult* object will be returned. Otherwise, `None` will be returned. If an array type (e.g., *np.ndarray*) is used for one of the raster outputs, the result will be an array and will have the shape corresponding to the computational region. If an array type is used for more than one raster output, the result will be a tuple of arrays.

    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*  
    **signaturefile** : str, *required*  
    &nbsp;&nbsp;&nbsp;&nbsp;Name of input file containing signatures  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: input, sigfile, *name*  
    **output** : str, *required*  
    &nbsp;&nbsp;&nbsp;&nbsp;Output map with predicted class or calculated value  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: output, raster, *name*  
    **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*  
    **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.predict* predicts values with a Support Vector Machine (SVM) and
stores them in a raster file. Predictions are based on a signature file
generated with [i.svm.train](i.svm.train.md).

Internally the module performs input value rescaling of each of imagery
group rasters by minimum and maximum range determined during training.

## 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) and in value prediction imagery
groups. Use [r.support](r.support.md) to set semantic labels.

## PERFORMANCE

Value prediction is done cell by cell and thus memory consumption should
be constant.

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 second part of classification process. See
[i.svm.train](i.svm.train.md) for the first part.

Predict land use classes form a LANDSAT scene from October of 2002 with
a SVM trained on a 1996 land use map *landuse96_28m*.

```sh
i.svm.predict group=lsat7_2002 subgroup=res_30m \
    signaturefile=landuse96_rnd_points output=pred_landuse_2002
```

## SEE ALSO

*Train SVM: [i.svm.train](i.svm.train.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.predict source code](https://github.com/OSGeo/grass/tree/main/imagery/i.svm.predict)
([history](https://github.com/OSGeo/grass/commits/main/imagery/i.svm.predict))  
Latest change: Thursday May 14 12:46:40 2026 in commit [3301c12](https://github.com/OSGeo/grass/commit/3301c12033b1d3a68d956322dddeaf5e4493978d)
