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)
| 46 | |
| 47 | |
| 48 | def 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 | |
| 72 | def KL_max_disagreement(committee: BaseCommittee, X: modALinput, **predict_proba_kwargs) -> np.ndarray: |
no test coverage detected
searching dependent graphs…