Margin sampling query strategy. Selects the instances where the difference between the first most likely and second most likely classes are the smallest. Args: classifier: The classifier for which the labels are to be queried. X: The pool of samples to query from.
(classifier: BaseEstimator, X: modALinput,
n_instances: int = 1, random_tie_break: bool = False,
**uncertainty_measure_kwargs)
| 158 | |
| 159 | |
| 160 | def margin_sampling(classifier: BaseEstimator, X: modALinput, |
| 161 | n_instances: int = 1, random_tie_break: bool = False, |
| 162 | **uncertainty_measure_kwargs) -> np.ndarray: |
| 163 | """ |
| 164 | Margin sampling query strategy. Selects the instances where the difference between |
| 165 | the first most likely and second most likely classes are the smallest. |
| 166 | Args: |
| 167 | classifier: The classifier for which the labels are to be queried. |
| 168 | X: The pool of samples to query from. |
| 169 | n_instances: Number of samples to be queried. |
| 170 | random_tie_break: If True, shuffles utility scores to randomize the order. This |
| 171 | can be used to break the tie when the highest utility score is not unique. |
| 172 | **uncertainty_measure_kwargs: Keyword arguments to be passed for the uncertainty |
| 173 | measure function. |
| 174 | Returns: |
| 175 | The indices of the instances from X chosen to be labelled. |
| 176 | The margin metric of the chosen instances. |
| 177 | """ |
| 178 | margin = classifier_margin(classifier, X, **uncertainty_measure_kwargs) |
| 179 | |
| 180 | if not random_tie_break: |
| 181 | return multi_argmin(margin, n_instances=n_instances) |
| 182 | |
| 183 | return shuffled_argmin(margin, n_instances=n_instances) |
| 184 | |
| 185 | |
| 186 | def entropy_sampling(classifier: BaseEstimator, X: modALinput, |
nothing calls this directly
no test coverage detected
searching dependent graphs…