Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I will wait until this is carefully reviewed before merging since it impacts the logic of all classifiers.
The main problem was in the
Dense_Feature_Set
that did not force the features to be sorted. This resulted in confusion about features while predicting. This was happening only when a classifier was returning false topredict_is_optimized
(the default). This was in particular the case ofStump
.I cleaned also some of the logic around optimization. It seems that the original intent was to have all optimize calls to work transparently even when a classifier did not support optimization. This condition was tracked in two ways, calling
predict_is_optimized()
and using theOptimization_Info::initialized
member. I kept only the former. It is therefore an error now to call an optimize predict with an uninitializedOptimization_Info
.I also removed the call
optimization_supported
. This call was not used except in the creation of theOptimization_Info
and since the optimized predict methods can be called in all cases, it was not necessary to keep it.Lastly, the
all_features()
method does not return all the features the classifier was trained on. An example is with aCommittee
ofStump
where only the features that were actually selected during the training will be persisted. This might not be an issue but thought it was at the beginning. For this reason, the optimized predict will useOptimize_Info::from_features
instead ofOptimize_Info::to_features
but this might not be required or even a good idea.