Mean Max Loss query strategy for SVM multilabel classification. For more details on this query strategy, see Li et al., Multilabel SVM active learning for image classification (http://dx.doi.org/10.1109/ICIP.2004.1421535) Args: classifier: The multilabel classifier for
(classifier: OneVsRestClassifier, X_pool: modALinput,
n_instances: int = 1, random_tie_break: bool = False)
| 109 | |
| 110 | |
| 111 | def mean_max_loss(classifier: OneVsRestClassifier, X_pool: modALinput, |
| 112 | n_instances: int = 1, random_tie_break: bool = False) -> np.ndarray: |
| 113 | """ |
| 114 | Mean Max Loss query strategy for SVM multilabel classification. |
| 115 | |
| 116 | For more details on this query strategy, see |
| 117 | Li et al., Multilabel SVM active learning for image classification |
| 118 | (http://dx.doi.org/10.1109/ICIP.2004.1421535) |
| 119 | |
| 120 | Args: |
| 121 | classifier: The multilabel classifier for which the labels are to be queried. Should be an SVM model |
| 122 | such as the ones from sklearn.svm. Although the function will execute for other models as well, |
| 123 | the mathematical calculations in Li et al. work only for SVM-s. |
| 124 | X_pool: The pool of samples to query from. |
| 125 | random_tie_break: If True, shuffles utility scores to randomize the order. This |
| 126 | can be used to break the tie when the highest utility score is not unique. |
| 127 | |
| 128 | Returns: |
| 129 | The index of the instance from X_pool chosen to be labelled. |
| 130 | The SVM-loss metric of the chosen instances. |
| 131 | |
| 132 | """ |
| 133 | |
| 134 | assert len(X_pool) >= n_instances, 'n_instances cannot be larger than len(X_pool)' |
| 135 | loss = _SVM_loss(classifier, X_pool) |
| 136 | |
| 137 | if not random_tie_break: |
| 138 | return multi_argmax(loss, n_instances) |
| 139 | |
| 140 | return shuffled_argmax(loss, n_instances) |
| 141 | |
| 142 | |
| 143 | def min_confidence(classifier: OneVsRestClassifier, X_pool: modALinput, |
nothing calls this directly
no test coverage detected
searching dependent graphs…