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)
| 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. |