Uncertainty sampling query strategy. Selects the least sure instances for labelling. Args: classifier: The classifier for which the labels are to be queried. X: The pool of samples to query from. n_instances: Number of samples to be queried. random_tie_break
(classifier: BaseEstimator, X: modALinput,
n_instances: int = 1, random_tie_break: bool = False,
**uncertainty_measure_kwargs)
| 131 | |
| 132 | |
| 133 | def uncertainty_sampling(classifier: BaseEstimator, X: modALinput, |
| 134 | n_instances: int = 1, random_tie_break: bool = False, |
| 135 | **uncertainty_measure_kwargs) -> np.ndarray: |
| 136 | """ |
| 137 | Uncertainty sampling query strategy. Selects the least sure instances for labelling. |
| 138 | |
| 139 | Args: |
| 140 | classifier: The classifier for which the labels are to be queried. |
| 141 | X: The pool of samples to query from. |
| 142 | n_instances: Number of samples to be queried. |
| 143 | random_tie_break: If True, shuffles utility scores to randomize the order. This |
| 144 | can be used to break the tie when the highest utility score is not unique. |
| 145 | **uncertainty_measure_kwargs: Keyword arguments to be passed for the uncertainty |
| 146 | measure function. |
| 147 | |
| 148 | Returns: |
| 149 | The indices of the instances from X chosen to be labelled. |
| 150 | The uncertainty metric of the chosen instances. |
| 151 | """ |
| 152 | uncertainty = classifier_uncertainty(classifier, X, **uncertainty_measure_kwargs) |
| 153 | |
| 154 | if not random_tie_break: |
| 155 | return multi_argmax(uncertainty, n_instances=n_instances) |
| 156 | |
| 157 | return shuffled_argmax(uncertainty, n_instances=n_instances) |
| 158 | |
| 159 | |
| 160 | def margin_sampling(classifier: BaseEstimator, X: modALinput, |
nothing calls this directly
no test coverage detected
searching dependent graphs…