Checks the known class labels for each classifier. Args: *args: Classifier objects to check the known class labels. Returns: True, if class labels match for all classifiers, False otherwise.
(*args: BaseEstimator)
| 6 | |
| 7 | |
| 8 | def check_class_labels(*args: BaseEstimator) -> bool: |
| 9 | """ |
| 10 | Checks the known class labels for each classifier. |
| 11 | |
| 12 | Args: |
| 13 | *args: Classifier objects to check the known class labels. |
| 14 | |
| 15 | Returns: |
| 16 | True, if class labels match for all classifiers, False otherwise. |
| 17 | """ |
| 18 | try: |
| 19 | classes_ = [estimator.classes_ for estimator in args] |
| 20 | except AttributeError: |
| 21 | raise NotFittedError('Not all estimators are fitted. Fit all estimators before using this method.') |
| 22 | |
| 23 | for classifier_idx in range(len(args) - 1): |
| 24 | if not np.array_equal(classes_[classifier_idx], classes_[classifier_idx+1]): |
| 25 | return False |
| 26 | |
| 27 | return True |
| 28 | |
| 29 | |
| 30 | def check_class_proba(proba: np.ndarray, known_labels: Sequence, all_labels: Sequence) -> np.ndarray: |
no outgoing calls
no test coverage detected
searching dependent graphs…