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

Method predict

sklearn/calibration.py:538–560  ·  view source on GitHub ↗

Predict the target of new samples. The predicted class is the class that has the highest probability, and can thus be different from the prediction of the uncalibrated classifier. Parameters ---------- X : array-like of shape (n_samples, n_features)

(self, X)

Source from the content-addressed store, hash-verified

536 return mean_proba
537
538 def predict(self, X):
539 """Predict the target of new samples.
540
541 The predicted class is the class that has the highest probability,
542 and can thus be different from the prediction of the uncalibrated classifier.
543
544 Parameters
545 ----------
546 X : array-like of shape (n_samples, n_features)
547 The samples, as accepted by `estimator.predict`.
548
549 Returns
550 -------
551 C : ndarray of shape (n_samples,)
552 The predicted class.
553 """
554 xp, _ = get_namespace(X)
555 check_is_fitted(self)
556 class_indices = xp.argmax(self.predict_proba(X), axis=1)
557 if isinstance(self.classes_[0], str):
558 class_indices = move_to(class_indices, xp=np, device="cpu")
559
560 return self.classes_[class_indices]
561
562 def get_metadata_routing(self):
563 """Get metadata routing of this object.

Callers 5

make_predictionFunction · 0.95
test_calibration_frozenFunction · 0.95

Calls 4

predict_probaMethod · 0.95
get_namespaceFunction · 0.90
check_is_fittedFunction · 0.90
move_toFunction · 0.90

Tested by 5

make_predictionFunction · 0.76
test_calibration_frozenFunction · 0.76