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

Method vote_proba

modAL/models/learners.py:598–629  ·  view source on GitHub ↗

Predicts the probabilities of the classes for each sample and each learner. Args: X: The samples for which class probabilities are to be calculated. **predict_proba_kwargs: Keyword arguments for the :meth:`predict_proba` of the learners. Returns:

(self, X: modALinput, **predict_proba_kwargs)

Source from the content-addressed store, hash-verified

596 return prediction
597
598 def vote_proba(self, X: modALinput, **predict_proba_kwargs) -> Any:
599 """
600 Predicts the probabilities of the classes for each sample and each learner.
601 Args:
602 X: The samples for which class probabilities are to be calculated.
603 **predict_proba_kwargs: Keyword arguments for the :meth:`predict_proba` of the learners.
604 Returns:
605 Probabilities of each class for each learner and each instance.
606 """
607
608 # get dimensions
609 n_samples = X.shape[0]
610 n_learners = len(self.learner_list)
611 proba = np.zeros(shape=(n_samples, n_learners, self.n_classes_))
612
613 # checking if the learners in the Committee know the same set of class labels
614 if check_class_labels(*[learner.estimator for learner in self.learner_list]):
615 # known class labels are the same for each learner
616 # probability prediction is straightforward
617
618 for learner_idx, learner in enumerate(self.learner_list):
619 proba[:, learner_idx, :] = learner.predict_proba(X, **predict_proba_kwargs)
620
621 else:
622 for learner_idx, learner in enumerate(self.learner_list):
623 proba[:, learner_idx, :] = check_class_proba(
624 proba=learner.predict_proba(X, **predict_proba_kwargs),
625 known_labels=learner.estimator.classes_,
626 all_labels=self.classes_
627 )
628
629 return proba
630
631
632class CommitteeRegressor(BaseCommittee):

Callers 3

test_vote_probaMethod · 0.95
predict_probaMethod · 0.95
KL_max_disagreementFunction · 0.45

Calls 3

check_class_labelsFunction · 0.90
check_class_probaFunction · 0.90
predict_probaMethod · 0.45

Tested by 1

test_vote_probaMethod · 0.76