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

Function avg_score

modAL/multilabel.py:235–264  ·  view source on GitHub ↗

AvgScore query strategy for multilabel classification. For more details on this query strategy, see Esuli and Sebastiani., Active Learning Strategies for Multi-Label Text Classification (http://dx.doi.org/10.1007/978-3-642-00958-7_12) Args: classifier: The multilabel c

(classifier: OneVsRestClassifier, X_pool: modALinput,
              n_instances: int = 1, random_tie_break: bool = False)

Source from the content-addressed store, hash-verified

233
234
235def avg_score(classifier: OneVsRestClassifier, X_pool: modALinput,
236 n_instances: int = 1, random_tie_break: bool = False) -> np.ndarray:
237 """
238 AvgScore query strategy for multilabel classification.
239
240 For more details on this query strategy, see
241 Esuli and Sebastiani., Active Learning Strategies for Multi-Label Text Classification
242 (http://dx.doi.org/10.1007/978-3-642-00958-7_12)
243
244 Args:
245 classifier: The multilabel classifier for which the labels are to be queried.
246 X_pool: The pool of samples to query from.
247 random_tie_break: If True, shuffles utility scores to randomize the order. This
248 can be used to break the tie when the highest utility score is not unique.
249
250 Returns:
251 The index of the instance from X_pool chosen to be labelled.
252 The classwise mean metric of the chosen instances.
253
254 """
255
256 classwise_confidence = classifier.predict_proba(X_pool)
257 classwise_predictions = classifier.predict(X_pool)
258 classwise_scores = classwise_confidence*(classwise_predictions-1/2)
259 classwise_mean = np.mean(classwise_scores, axis=1)
260
261 if not random_tie_break:
262 return multi_argmax(classwise_mean, n_instances)
263
264 return shuffled_argmax(classwise_mean, n_instances)

Callers

nothing calls this directly

Calls 4

multi_argmaxFunction · 0.90
shuffled_argmaxFunction · 0.90
predict_probaMethod · 0.45
predictMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…