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)
| 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) |