8000 DOC Clarify what the decision function in SVM calculates (#12708) · amueller/scikit-learn@fdfba9d · GitHub
[go: up one dir, main page]

Skip to content

Commit fdfba9d

Browse files
JanSellneramueller
authored andcommitted
DOC Clarify what the decision function in SVM calculates (scikit-learn#12708)
1 parent 9d9d798 commit fdfba9d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

sklearn/svm/base.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ def _compute_kernel(self, X):
384384
return X
385385

386386
def _decision_function(self, X):
387-
"""Distance of the samples X to the separating hyperplane.
387+
"""Evaluates the decision function for the samples in X.
388388
389389
Parameters
390390
----------
@@ -529,7 +529,7 @@ def _validate_targets(self, y):
529529
return np.asarray(y, dtype=np.float64, order='C')
530530

531531
def decision_function(self, X):
532-
"""Distance of the samples X to the separating hyperplane.
532+
"""Evaluates the decision function for the samples in X.
533533
534534
Parameters
535535
----------
@@ -541,7 +541,16 @@ def decision_function(self, X):
541541
Returns the decision function of the sample for each class
542542
in the model.
543543
If decision_function_shape='ovr', the shape is (n_samples,
544-
n_classes)
544+
n_classes).
545+
546+
Notes
547+
------
548+
If decision_function_shape='ovo', the function values are proportional
549+
to the distance of the samples X to the separating hyperplane. If the
550+
exact distances are required, divide the function values by the norm of
551+
the weight vector (``coef_``). See also `this question
552+
<https://stats.stackexchange.com/questions/14876/
553+
interpreting-distance-from-hyperplane-in-svm>`_ for further details.
545554
"""
546555
dec = self._decision_function(X)
547556
if self.decision_function_shape == 'ovr' and len(self.classes_) > 2:

0 commit comments

Comments
 (0)
0