[MRG] #9494 FIX Fail to train SVM ... #14282
Closed
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.
Fixes #9494. See also PR #9674.
Issue #9494 surfaced when training svm.SVC classifier with negative sample weights. There is a PR that attempted to fix this issue - PR #9674.
SVC algorithms is part of 5 svm algorithms that are implemented in svm.cpp: SVC, NuSVC, SVR, NuSVR and OneClassSVM. Function PREFIX(train) in svm.cpp implements all 5 algorithms. The way this function handles samples with negative/zero weights is by removing the corresponding samples from the training set.
This behavior can result in an invalid model after fit() for SVC, SVR, NuSVR and OneClassSVM if too many samples are removed, NuSVC is the only class that currently detects this and fails fit() with an exception.
This PR resolves this problem by detecting this situation in all classes and behaving like NuSVC- throwing an Exception during fit()
Please see a more detailed analysis at the bottom of issue #9494