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

Function consensus_entropy

modAL/disagreement.py:48–69  ·  view source on GitHub ↗

Calculates the consensus entropy for the Committee. First it computes the class probabilties of X for each learner in the Committee, then calculates the consensus probability distribution by averaging the individual class probabilities for each learner. The entropy of the consensus prob

(committee: BaseCommittee, X: modALinput, **predict_proba_kwargs)

Source from the content-addressed store, hash-verified

46
47
48def consensus_entropy(committee: BaseCommittee, X: modALinput, **predict_proba_kwargs) -> np.ndarray:
49 """
50 Calculates the consensus entropy for the Committee. First it computes the class probabilties of X for each learner
51 in the Committee, then calculates the consensus probability distribution by averaging the individual class
52 probabilities for each learner. The entropy of the consensus probability distribution is the vote entropy of the
53 Committee, which is returned.
54
55 Args:
56 committee: The :class:`modAL.models.BaseCommittee` instance for which the consensus entropy is to be calculated.
57 X: The data for which the consensus entropy is to be calculated.
58 **predict_proba_kwargs: Keyword arguments for the :meth:`predict_proba` of the Committee.
59
60 Returns:
61 Consensus entropy of the Committee for the samples in X.
62 """
63 try:
64 proba = committee.predict_proba(X, **predict_proba_kwargs)
65 except NotFittedError:
66 return np.zeros(shape=(X.shape[0],))
67
68 entr = np.transpose(entropy(np.transpose(proba)))
69 return entr
70
71
72def KL_max_disagreement(committee: BaseCommittee, X: modALinput, **predict_proba_kwargs) -> np.ndarray:

Callers 1

Calls 1

predict_probaMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…