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

Method predict

sklearn/multiclass.py:932–953  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers 5

test_ovo_exceptionsFunction · 0.95
test_ovo_string_yFunction · 0.95

Calls 2

decision_functionMethod · 0.95

Tested by 5

test_ovo_exceptionsFunction · 0.76
test_ovo_string_yFunction · 0.76