From 5a10a36ae2a3903c3f09d4f0f1289e487fe4fbf3 Mon Sep 17 00:00:00 2001
From: Guillaume Pasero <guillaume.pasero@c-s.fr>
Date: Wed, 27 Sep 2017 17:01:37 +0200
Subject: [PATCH] DOC: CookBook improvements on unsupervised classification

---
 .../Cookbook/rst/recipes/pbclassif.rst        | 38 ++++++++++++++++---
 1 file changed, 32 insertions(+), 6 deletions(-)

diff --git a/Documentation/Cookbook/rst/recipes/pbclassif.rst b/Documentation/Cookbook/rst/recipes/pbclassif.rst
index 5807440bfb..73ab8409d7 100644
--- a/Documentation/Cookbook/rst/recipes/pbclassif.rst
+++ b/Documentation/Cookbook/rst/recipes/pbclassif.rst
@@ -553,16 +553,42 @@ provide a vector data file with a label field. This vector file will be
 used to extract samples for the training. Each label value is can be considered
 as a source area for samples, the same logic as in supervised learning is
 applied for the computation of extracted samples per area. Hence, for
-unsupervised classification :
+unsupervised classification, the samples are selected based on classes that are
+not actually used during the training. For the moment, only the KMeans
+algorithm is proposed in this framework.
 
-- if there is a unique label in the vector data, samples will be selected as if
-they come from a single class or set
+::
+
+    otbcli_TrainImageClassifier
+      -io.il                image.tif
+      -io.vd                training_areas.shp
+      -io.out               model.txt
+      -sample.vfn           Class
+      -classifier           sharkkm
+      -classifier.sharkkm.k 4
 
-- if multiple labels are present, samples will be selected so that every
-samples in the smallest class are selected, and the same number of sample from
-each class
+If your training samples are in a vector data file, you can use the application
+*TrainVectorClassifier*. In this case, you don't need a fake label field. You
+just need to specify which fields shall be used to do the training.
+
+::
 
+    otbcli_TrainVectorClassifier
+      -io.vd                training_samples.shp
+      -io.out               model.txt
+      -feat                 perimeter area width red nir
+      -classifier           sharkkm
+      -classifier.sharkkm.k 4
+
+Once you have the model file, the actual classification step is the same as
+the supervised case. The model will predict labels on your input data.
+
+::
 
+    otbcli_ImageClassifier
+      -in input_image.tif
+      -model model.txt
+      -out kmeans_labels.tif
 
 Fusion of classification maps
 -----------------------------
-- 
GitLab