MaxScore 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 = 1)
| 201 | |
| 202 | |
| 203 | def max_score(classifier: OneVsRestClassifier, X_pool: modALinput, |
| 204 | n_instances: int = 1, random_tie_break: bool = 1) -> np.ndarray: |
| 205 | """ |
| 206 | MaxScore query strategy for multilabel classification. |
| 207 | |
| 208 | For more details on this query strategy, see |
| 209 | Esuli and Sebastiani., Active Learning Strategies for Multi-Label Text Classification |
| 210 | (http://dx.doi.org/10.1007/978-3-642-00958-7_12) |
| 211 | |
| 212 | Args: |
| 213 | classifier: The multilabel classifier for which the labels are to be queried. |
| 214 | X_pool: The pool of samples to query from. |
| 215 | random_tie_break: If True, shuffles utility scores to randomize the order. This |
| 216 | can be used to break the tie when the highest utility score is not unique. |
| 217 | |
| 218 | Returns: |
| 219 | The index of the instance from X_pool chosen to be labelled. |
| 220 | The classwise maximum metric of the chosen instances. |
| 221 | |
| 222 | """ |
| 223 | |
| 224 | classwise_confidence = classifier.predict_proba(X_pool) |
| 225 | classwise_predictions = classifier.predict(X_pool) |
| 226 | classwise_scores = classwise_confidence*(classwise_predictions - 1/2) |
| 227 | classwise_max = np.max(classwise_scores, axis=1) |
| 228 | |
| 229 | if not random_tie_break: |
| 230 | return multi_argmax(classwise_max, n_instances) |
| 231 | |
| 232 | return shuffled_argmax(classwise_max, n_instances) |
| 233 | |
| 234 | |
| 235 | def avg_score(classifier: OneVsRestClassifier, X_pool: modALinput, |
nothing calls this directly
no test coverage detected
searching dependent graphs…