MCPcopy
hub / github.com/scikit-learn/scikit-learn / decision_function

Method decision_function

sklearn/multiclass.py:955–1001  ·  view source on GitHub ↗

Decision function for the OneVsOneClassifier. The decision values for the samples are computed by adding the normalized sum of pair-wise classification confidence levels to the votes in order to disambiguate between the decision values when the votes for all the clas

(self, X)

Source from the content-addressed store, hash-verified

953 return self.classes_[Y.argmax(axis=1)]
954
955 def decision_function(self, X):
956 """Decision function for the OneVsOneClassifier.
957
958 The decision values for the samples are computed by adding the
959 normalized sum of pair-wise classification confidence levels to the
960 votes in order to disambiguate between the decision values when the
961 votes for all the classes are equal leading to a tie.
962
963 Parameters
964 ----------
965 X : array-like of shape (n_samples, n_features)
966 Input data.
967
968 Returns
969 -------
970 Y : array-like of shape (n_samples, n_classes) or (n_samples,)
971 Result of calling `decision_function` on the final estimator.
972
973 .. versionchanged:: 0.19
974 output shape changed to ``(n_samples,)`` to conform to
975 scikit-learn conventions for binary classification.
976 """
977 check_is_fitted(self)
978 X = validate_data(
979 self,
980 X,
981 accept_sparse=True,
982 ensure_all_finite=False,
983 reset=False,
984 )
985
986 indices = self.pairwise_indices_
987 if indices is None:
988 Xs = [X] * len(self.estimators_)
989 else:
990 Xs = [X[:, idx] for idx in indices]
991
992 predictions = np.vstack(
993 [est.predict(Xi) for est, Xi in zip(self.estimators_, Xs)]
994 ).T
995 confidences = np.vstack(
996 [_predict_binary(est, Xi) for est, Xi in zip(self.estimators_, Xs)]
997 ).T
998 Y = _ovr_decision_function(predictions, confidences, len(self.classes_))
999 if self.n_classes_ == 2:
1000 return Y[:, 1]
1001 return Y
1002
1003 @property
1004 def n_classes_(self):

Callers 3

predictMethod · 0.95
test_ovo_tiesFunction · 0.95

Calls 5

check_is_fittedFunction · 0.90
validate_dataFunction · 0.90
_ovr_decision_functionFunction · 0.90
_predict_binaryFunction · 0.85
predictMethod · 0.45

Tested by 2

test_ovo_tiesFunction · 0.76