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

Function classifier_entropy

modAL/uncertainty.py:113–130  ·  view source on GitHub ↗

Entropy of predictions of the for the provided samples. Args: classifier: The classifier for which the prediction entropy is to be measured. X: The samples for which the prediction entropy is to be measured. **predict_proba_kwargs: Keyword arguments to be passed for

(classifier: BaseEstimator, X: modALinput, **predict_proba_kwargs)

Source from the content-addressed store, hash-verified

111
112
113def classifier_entropy(classifier: BaseEstimator, X: modALinput, **predict_proba_kwargs) -> np.ndarray:
114 """
115 Entropy of predictions of the for the provided samples.
116
117 Args:
118 classifier: The classifier for which the prediction entropy is to be measured.
119 X: The samples for which the prediction entropy is to be measured.
120 **predict_proba_kwargs: Keyword arguments to be passed for the :meth:`predict_proba` of the classifier.
121
122 Returns:
123 Entropy of the class probabilities.
124 """
125 try:
126 classwise_uncertainty = classifier.predict_proba(X, **predict_proba_kwargs)
127 except NotFittedError:
128 return np.zeros(shape=(X.shape[0], ))
129
130 return np.transpose(entropy(np.transpose(classwise_uncertainty)))
131
132
133def uncertainty_sampling(classifier: BaseEstimator, X: modALinput,

Callers 1

entropy_samplingFunction · 0.85

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…