Estimate the best class label for each sample in X. This is implemented as ``argmax(decision_function(X), axis=1)`` which will return the label of the class with most votes by estimators predicting the outcome of a decision for each possible class pair. Parameters
(self, X)
| 930 | return self |
| 931 | |
| 932 | def predict(self, X): |
| 933 | """Estimate the best class label for each sample in X. |
| 934 | |
| 935 | This is implemented as ``argmax(decision_function(X), axis=1)`` which |
| 936 | will return the label of the class with most votes by estimators |
| 937 | predicting the outcome of a decision for each possible class pair. |
| 938 | |
| 939 | Parameters |
| 940 | ---------- |
| 941 | X : {array-like, sparse matrix} of shape (n_samples, n_features) |
| 942 | Data. |
| 943 | |
| 944 | Returns |
| 945 | ------- |
| 946 | y : numpy array of shape [n_samples] |
| 947 | Predicted multi-class targets. |
| 948 | """ |
| 949 | Y = self.decision_function(X) |
| 950 | if self.n_classes_ == 2: |
| 951 | thresh = _threshold_for_binary_predict(self.estimators_[0]) |
| 952 | return self.classes_[(Y > thresh).astype(int)] |
| 953 | return self.classes_[Y.argmax(axis=1)] |
| 954 | |
| 955 | def decision_function(self, X): |
| 956 | """Decision function for the OneVsOneClassifier. |