Return the mean accuracy on the given test data and labels. Parameters ---------- X : array-like of shape (n_samples, n_features) Test samples. y : array-like of shape (n_samples, n_outputs) True values for X. Returns -------
(self, X, y)
| 584 | return results |
| 585 | |
| 586 | def score(self, X, y): |
| 587 | """Return the mean accuracy on the given test data and labels. |
| 588 | |
| 589 | Parameters |
| 590 | ---------- |
| 591 | X : array-like of shape (n_samples, n_features) |
| 592 | Test samples. |
| 593 | |
| 594 | y : array-like of shape (n_samples, n_outputs) |
| 595 | True values for X. |
| 596 | |
| 597 | Returns |
| 598 | ------- |
| 599 | scores : float |
| 600 | Mean accuracy of predicted target versus true target. |
| 601 | """ |
| 602 | check_is_fitted(self) |
| 603 | n_outputs_ = len(self.estimators_) |
| 604 | if y.ndim == 1: |
| 605 | raise ValueError( |
| 606 | "y must have at least two dimensions for " |
| 607 | "multi target classification but has only one" |
| 608 | ) |
| 609 | if y.shape[1] != n_outputs_: |
| 610 | raise ValueError( |
| 611 | "The number of outputs of Y for fit {0} and" |
| 612 | " score {1} should be same".format(n_outputs_, y.shape[1]) |
| 613 | ) |
| 614 | y_pred = self.predict(X) |
| 615 | return np.mean(np.all(y == y_pred, axis=1)) |
| 616 | |
| 617 | def __sklearn_tags__(self): |
| 618 | tags = super().__sklearn_tags__() |