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

Function mean_max_loss

modAL/multilabel.py:111–140  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

109
110
111def 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
143def min_confidence(classifier: OneVsRestClassifier, X_pool: modALinput,

Callers

nothing calls this directly

Calls 3

multi_argmaxFunction · 0.90
shuffled_argmaxFunction · 0.90
_SVM_lossFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…