-
-
Notifications
You must be signed in to change notification settings - Fork 26.2k
Deprecate use of probability=True
in SVC and NuSVC
#32050
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @snath-xoc for the PR. Here is a pass of feedback. Once addressed, could you please try to fix any issue reported by the CI is green before pinging reviewers again?
Feel free to ask for help if there are particular CI failures you don't know how to address.
sklearn/svm/tests/test_svm.py
Outdated
# XXX: this test is thread-unsafe because it uses probability=True: | ||
# https://github.com/scikit-learn/scikit-learn/issues/31885 | ||
@pytest.mark.thread_unsafe | ||
@pytest.mark.filterwarnings("ignore::FutureWarning") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could change this test to remove probability=True
along with all the test function annotations: it seems that the convergence problem tested in this test is unrelated to the choice of probability=True
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, shall I do the same for other tests as well e.g., test_svc_clone_with_callable_kernel in L1061?
Never mind, it is using predict_proba.
sklearn/svm/_classes.py
Outdated
@@ -877,6 +882,16 @@ def __init__( | |||
break_ties=False, | |||
random_state=None, | |||
): | |||
if probability != "deprecated": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be moved to the fit
method. As per the scikit-learn estimator API, the constructor parameters should always be stored unchanged as attributes. Any validation logic should be deferred to the fit
method.
Co-authored-by: Olivier Grisel <[email protected]>
Reference Issues/PRs
Related to issue #31885
What does this implement/fix? Explain your changes.
this PR deprecates the use of probability=True in both SVC and NuSVC
Any other comments?
For now the default is set as
probability="deprecated"
and later on it is set toprobability=False
. This is as within the baselibsvm.fit
function pyx code, probability is required to be a boolean integer. Perhaps in future we hard-code this as always being 0 (i.e., False), as we should not useprobability=True
?FYI @ogrisel