TrainVectorClassifier ignores completly two classes

For a class at the university I need to classify an image with OBIA. But I ran into the problem, that the TrainVectorClassifier ignores completly two of my training classes. I use the OTB v7.0.0 in Qgis.

I pasted the log file here
https://pastebin.com/yq4B3xWv

Maybe my vector data are somehow broken, I will upload them as well.
Can’t upload the file directly here but I have linked it (23mb, compressed shapefile):
http://s000.tinyupload.com/?file_id=19796148415105959998

Hopefully someone can help fix this problem.

Hello,

There are a lot of NULL values for the traintyp_d feature in your input vector. If I’m correct, they will be trated as 0 by the application. Is that what you want ?

Also, maybe the bayes classifer is not adapted to this problem ? I ran a few test with your data (I removed all features with NULL traintyp_d).

With bayes i got the following confusion matrix :

    [0] [1] [2] [3] [4] 
[0]  92   0   0   0   0 
[1]  11   0  36   0  24 
[2]   0   0 116   0   0 
[3]   0   0   0 153   0 
[4]   0   0   0  19 187 

With rf (random forest) :

    [0] [1] [2] [3] [4] 
[0]  92   0   0   0   0 
[1]   0  71   0   0   0 
[2]   0   0 116   0   0 
[3]   0   0   0 140  13 
[4]   0   0   0  11 195 

Cédric

Ok, this mean I have to remove all features, which are no trainingsdata from the file and use this for the TrainVectorClassifier and in the VectorClassifier I use the complete set?

Yes ! You can remove unwanted features using ogr2ogr (this is probably possible directly in QGIS too)

Hello !
@Cedric , could you please explain how to do it (ogr2ogr) ? I don’t understand how it works. I think I have the same problem as @nikiosna because when I use VectorClassifier, I have only one class in the classification instead of 2.

Thank you very much

Hello, to remove feature with null “id” field in a shapefile named input.shp containing a layer named “input”, you can write something like :

ogr2ogr  -sql "select * from input where id is not null" output.shp input.shp 

See https://gdal.org/programs/ogr2ogr.html

Cédric