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

Method predict_proba

sklearn/calibration.py:509–536  ·  view source on GitHub ↗

Calibrated probabilities of classification. This function returns calibrated probabilities of classification according to each class on an array of test vectors X. Parameters ---------- X : array-like of shape (n_samples, n_features) The samples,

(self, X)

Source from the content-addressed store, hash-verified

507 return self
508
509 def predict_proba(self, X):
510 """Calibrated probabilities of classification.
511
512 This function returns calibrated probabilities of classification
513 according to each class on an array of test vectors X.
514
515 Parameters
516 ----------
517 X : array-like of shape (n_samples, n_features)
518 The samples, as accepted by `estimator.predict_proba`.
519
520 Returns
521 -------
522 C : ndarray of shape (n_samples, n_classes)
523 The predicted probas.
524 """
525 check_is_fitted(self)
526 # Compute the arithmetic mean of the predictions of the calibrated
527 # classifiers
528 xp, _, device_ = get_namespace_and_device(X)
529 mean_proba = xp.zeros((_num_samples(X), self.classes_.shape[0]), device=device_)
530 for calibrated_classifier in self.calibrated_classifiers_:
531 proba = calibrated_classifier.predict_proba(X)
532 mean_proba += proba
533
534 mean_proba /= len(self.calibrated_classifiers_)
535
536 return mean_proba
537
538 def predict(self, X):
539 """Predict the target of new samples.

Calls 4

check_is_fittedFunction · 0.90
get_namespace_and_deviceFunction · 0.90
_num_samplesFunction · 0.90
predict_probaMethod · 0.45