-
-
Notifications
You must be signed in to change notification settings - Fork 26k
DOC Clarify what the decision function in SVM calculates #12708
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
DOC Clarify what the decision function in SVM calculates #12708
Conversation
sklearn/svm/base.py
Outdated
|
||
Notes | ||
------ | ||
The function values are proportional to the distance of the samples X to the separating hyperplane. If the exact distances are required, divide the function values by the norm of the weight vector (``coef_``). See also `this question <https://stats.stackexchange.com/questions/14876/interpreting-distance-from-hyperplane-in-svm>`_ for further details. |
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.
take care pep8
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 for the note. Is fixed. This is a nice CI system you have here :-)
Great clarification |
sklearn/svm/base.py
Outdated
|
||
Notes | ||
------ | ||
The function values are proportional to the distance of the samples X |
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 is only relevant to decision_function_shape='ovo' isn't it? For ovr it does something more complicated
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.
Good point. As far as I understand the code, the decision values are somehow weighted up together and then scaled to a defined range. It does probably not make any sense to derive to the real distances based on the confidence values. So, yes, the note is only relevant to 'ovo' decision functions.
I would suggest changing the intro of the note to
If decision_function_shape=’ovo’, the function values are proportional
...
is that ok?
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.
Yes, just qualifying the statement like that s fine.
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.
Ok, done :-)
Thanks @Milania1 |
…kit-learn#12708)" This reverts commit 543d640.
…kit-learn#12708)" This reverts commit 543d640.
What does this implement/fix? Explain your changes.
Strictly speaking, the decision function of an SVM does not calculate the distance to the hyperplane. Instead the function value is only proportional to this distance. Since I stumbled over this, I made this small clarification and added a note for users who need the exact distance.
If this simplification was intentional, I would suggest to keep at least the note.