MCPcopy Create free account
hub / github.com/modAL-python/modAL / check_class_labels

Function check_class_labels

modAL/utils/validation.py:8–27  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

6
7
8def 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
30def check_class_proba(proba: np.ndarray, known_labels: Sequence, all_labels: Sequence) -> np.ndarray:

Callers 1

vote_probaMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…