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

Function entropy_sampling

modAL/uncertainty.py:186–211  ·  view source on GitHub ↗

Entropy sampling query strategy. Selects the instances where the class probabilities have the largest entropy. Args: classifier: The classifier for which the labels are to be queried. X: The pool of samples to query from. n_instances: Number of samples to be que

(classifier: BaseEstimator, X: modALinput,
                     n_instances: int = 1, random_tie_break: bool = False,
                     **uncertainty_measure_kwargs)

Source from the content-addressed store, hash-verified

184
185
186def entropy_sampling(classifier: BaseEstimator, X: modALinput,
187 n_instances: int = 1, random_tie_break: bool = False,
188 **uncertainty_measure_kwargs) -> np.ndarray:
189 """
190 Entropy sampling query strategy. Selects the instances where the class probabilities
191 have the largest entropy.
192
193 Args:
194 classifier: The classifier for which the labels are to be queried.
195 X: The pool of samples to query from.
196 n_instances: Number of samples to be queried.
197 random_tie_break: If True, shuffles utility scores to randomize the order. This
198 can be used to break the tie when the highest utility score is not unique.
199 **uncertainty_measure_kwargs: Keyword arguments to be passed for the uncertainty
200 measure function.
201
202 Returns:
203 The indices of the instances from X chosen to be labelled.
204 The entropy metric of the chosen instances.
205 """
206 entropy = classifier_entropy(classifier, X, **uncertainty_measure_kwargs)
207
208 if not random_tie_break:
209 return multi_argmax(entropy, n_instances=n_instances)
210
211 return shuffled_argmax(entropy, n_instances=n_instances)

Callers

nothing calls this directly

Calls 3

multi_argmaxFunction · 0.90
shuffled_argmaxFunction · 0.90
classifier_entropyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…