|
21 | 21 | from skmatter.utils import check_cl_fit
|
22 | 22 |
|
23 | 23 |
|
24 |
| -# No inheritance from MultiOutputMixin because decision_function would fail |
25 |
| -# test_check_estimator.py 'check_classifier_multioutput' (line 2479 of estimator_checks.py). |
26 |
| -# This is the only test for multioutput classifiers, so is it OK to exclude this tag? |
27 |
| - |
28 |
| -# did a search of all classifiers that inherit from MultiOutputMixin - none of them implement |
29 |
| -# decision function |
30 |
| - |
31 |
| - |
32 | 24 | class PCovC(LinearClassifierMixin, _BasePCov):
|
33 | 25 | r"""Principal Covariates Classification (PCovC).
|
34 | 26 |
|
@@ -133,7 +125,9 @@ class PCovC(LinearClassifierMixin, _BasePCov):
|
133 | 125 | In such cases, the classifier will be re-fitted on the same
|
134 | 126 | training data as the composite estimator.
|
135 | 127 | If None and ``n_outputs < 2``, ``sklearn.linear_model.LogisticRegression()`` is used.
|
136 |
| - If None and ``n_outputs == 2``, ``sklearn.multioutput.MultiOutputClassifier()`` is used. |
| 128 | + If None and ``n_outputs >= 2``, a ``sklearn.multioutput.MultiOutputClassifier()`` is |
| 129 | + constructed, with ``sklearn.linear_model.LogisticRegression()`` models used for each |
| 130 | + label. |
137 | 131 |
|
138 | 132 | iterated_power : int or 'auto', default='auto'
|
139 | 133 | Number of iterations for the power method computed by
|
@@ -453,12 +447,13 @@ def decision_function(self, X=None, T=None):
|
453 | 447 |
|
454 | 448 | Returns
|
455 | 449 | -------
|
456 |
| - Z : numpy.ndarray, shape (n_samples,) or (n_samples, n_classes), or a list of \ |
457 |
| - n_outputs such arrays if n_outputs > 1 |
458 |
| - Confidence scores. For binary classification, has shape `(n_samples,)`, |
459 |
| - for multiclass classification, has shape `(n_samples, n_classes)`. |
460 |
| - If n_outputs > 1, the list can contain arrays with differing shapes |
461 |
| - depending on the number of classes in each output of Y. |
| 450 | + Z : numpy.ndarray, shape (n_samples,) or (n_samples, n_classes), or |
| 451 | + a list of n_outputs such arrays if n_outputs > 1. |
| 452 | + Confidence scores. For binary classification, has shape |
| 453 | + `(n_samples,)`, for multiclass classification, has shape |
| 454 | + `(n_samples, n_classes)`. If n_outputs > 1, the list can |
| 455 | + contain arrays with differing shapes depending on the number |
| 456 | + of classes in each output of Y. |
462 | 457 | """
|
463 | 458 | check_is_fitted(self, attributes=["pxz_", "ptz_"])
|
464 | 459 |
|
@@ -514,15 +509,14 @@ def transform(self, X=None):
|
514 | 509 | """
|
515 | 510 | return super().transform(X)
|
516 | 511 |
|
517 |
| - def score(self, X, y): |
518 |
| - |
| 512 | + def score(self, X, y, sample_weight=None): |
519 | 513 | # accuracy_score will handle everything but multiclass-multilabel
|
520 | 514 | if self.n_outputs_ > 1 and len(self.classes_) > 2:
|
521 | 515 | y_pred = self.predict(X)
|
522 | 516 | return np.mean(np.all(y == y_pred, axis=1))
|
523 | 517 |
|
524 | 518 | else:
|
525 |
| - return super().score(X, y) |
| 519 | + return super().score(X, y, sample_weight) |
526 | 520 |
|
527 | 521 | # Inherit the docstring from scikit-learn
|
528 | 522 | score.__doc__ = LinearClassifierMixin.score.__doc__
|
0 commit comments