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

Function avg_confidence

modAL/multilabel.py:173–200  ·  view source on GitHub ↗

AvgConfidence 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 multila

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

Source from the content-addressed store, hash-verified

171
172
173def avg_confidence(classifier: OneVsRestClassifier, X_pool: modALinput,
174 n_instances: int = 1, random_tie_break: bool = False) -> np.ndarray:
175 """
176 AvgConfidence query strategy for multilabel classification.
177
178 For more details on this query strategy, see
179 Esuli and Sebastiani., Active Learning Strategies for Multi-Label Text Classification
180 (http://dx.doi.org/10.1007/978-3-642-00958-7_12)
181
182 Args:
183 classifier: The multilabel classifier for which the labels are to be queried.
184 X_pool: The pool of samples to query from.
185 random_tie_break: If True, shuffles utility scores to randomize the order. This
186 can be used to break the tie when the highest utility score is not unique.
187
188 Returns:
189 The index of the instance from X_pool chosen to be labelled.
190 The average confidence metric of the chosen instances.
191
192 """
193
194 classwise_confidence = classifier.predict_proba(X_pool)
195 classwise_mean = np.mean(classwise_confidence, axis=1)
196
197 if not random_tie_break:
198 return multi_argmax(classwise_mean, n_instances)
199
200 return shuffled_argmax(classwise_mean, n_instances)
201
202
203def max_score(classifier: OneVsRestClassifier, X_pool: modALinput,

Callers

nothing calls this directly

Calls 3

multi_argmaxFunction · 0.90
shuffled_argmaxFunction · 0.90
predict_probaMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…