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

Method _set_classes

modAL/models/learners.py:489–508  ·  view source on GitHub ↗

Checks the known class labels by each learner, merges the labels and returns a mapping which maps the learner's classes to the complete label list.

(self)

Source from the content-addressed store, hash-verified

487 self._set_classes()
488
489 def _set_classes(self):
490 """
491 Checks the known class labels by each learner, merges the labels and returns a mapping which maps the learner's
492 classes to the complete label list.
493 """
494 # assemble the list of known classes from each learner
495 try:
496 # if estimators are fitted
497 known_classes = tuple(learner.estimator.classes_ for learner in self.learner_list)
498 except AttributeError:
499 # handle unfitted estimators
500 self.classes_ = None
501 self.n_classes_ = 0
502 return
503
504 self.classes_ = np.unique(
505 np.concatenate(known_classes, axis=0),
506 axis=0
507 )
508 self.n_classes_ = len(self.classes_)
509
510 def _add_training_data(self, X: modALinput, y: modALinput):
511 super()._add_training_data(X, y)

Callers 3

__init__Method · 0.95
fitMethod · 0.95
teachMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected