K parameter has no effect in KNN classifier
Bug reported by users on the forum
When using the KNN classifier, for example in TrainVectorClassifier
or TrainImageClassifier
, the input number of neighbor has no impact on the trained classifier.
Step to reproduce: (OTB 7.2.0)
otbcli_TrainVectorClassifier -io.vd trainExtract.shp -io.out knn.txt -cfield classlabel -feat value_0 value_1 -classifier knn -valid.vd validExtract.shp -classifier.knn.k 10
[...]
2021-04-16 11:43:46 (INFO) TrainVectorClassifier: Confusion matrix (rows = reference labels, columns = produced labels):
[0] [1] [2] [3]
[0] 25 0 1 0
[1] 0 296 0 0
[2] 9 0 76 7
[3] 0 21 0 593
[...]
otbcli_TrainVectorClassifier -io.vd trainExtract.shp -io.out knn.txt -cfield classlabel -feat value_0 value_1 -classifier knn -valid.vd validExtract.shp -classifier.knn.k 1
[...]
2021-04-16 11:43:46 (INFO) TrainVectorClassifier: Confusion matrix (rows = reference labels, columns = produced labels):
[0] [1] [2] [3]
[0] 25 0 1 0
[1] 0 296 0 0
[2] 9 0 76 7
[3] 0 21 0 593
[...]
Edited by Cédric Traizet