Request for Changes-71: Enhance class field selection in training applications
- Author: Julien Michel
- Additional Contributors: Idea from Cédric Lardreux
- Submitted on 18.11.2016
- Proposed target release: 5.10 / 6.0
- Adopted (+3), merged
The purpose of this RFC is to enhance the user API of classification applications where a field name for class label must be selected from a vector file.
Currently, field name parameters to define class label in vector file in applications ComputeConfusionMatrix, TrainImagesClassifier, TrainVectorClassifier, SampleSelection, SampleExtraction and PolygonClassStatistics are of type string, with a default value (such as "Class"). This default value seldom corresponds to the actual field name to use, but if the user does not pay attention, she will be able to execute the application (and get a cryptic ITK exception about unknown field).
The idea of this RFC is to change this parameter from String to ListView, and to update the list view with eligible fields when the vector file has been set (this is already the case for other field parameters, such as the "-feat" parameter of the TrainVectorClassifier application. Fields will also be filtered to retain only compatible fields (integer values for class label, interger and floating point values for features).
This also requires to add a property to the ListView parameter, which only allows for multi-selection, so as to enable a single selection mode.
Classes and files
ListViewParameter class has been extended with a SingleSelection property. This property is used in SetSelectedItemsByNames() and SetSelectedItemsByKeys() to throw an exception if SingleSelection is ON and one tries to select more than 1 item.
Application class has been extended with a method to set the SingleSelection property of a ListView parameter
A bug has been fixed in GroupParameter class.
WrapperQtWidgetListViewParameter class has been improved to switch the QtWidget selection mode to QAbstractItemView::SingleSelection if SingleSelection flag is on.
WrapperCommandLineLaucher has been updated to display single selection ListView parameters as <string> instead of <string list>, and to check on errors if more than two values are provided in this case.
The new field filtering makes use of the OFTInteger64 that has been introduced in gdal >= 2.0. A new IsOFTInteger64 function has been added to OGRVersionProxy so has to hide the switch on version.
ComputeConfusionMatrix, TrainVectorClassifier, SampleSelection, SampleExtraction and PolygonClassStatistics applications have been updated with single selection ListView and parameter filtering.
TrainOGRLayerClassifier is deprecated so it has not been updated.
TrainImagesClassifier is currently being reworked as a composite app using TrainVectorClassifier, SampleSelection, SampleExtraction and PolygonClassStatistics, so it has not been changed.
No test change needed.
No documentation change needed.
The ListView QT widget is really poor : it can not be resized by user so if the list has hundreds of entries, the user has to use the small scroll-bar in order to try to reach the values she is interested in.