Batch sampling query strategy. Selects the least sure instances for labelling. This strategy differs from :func:`~modAL.uncertainty.uncertainty_sampling` because, although it is supported, traditional active learning query strategies suffer from sub-optimal record selection when passin
(classifier: Union[BaseLearner, BaseCommittee],
X: Union[np.ndarray, sp.csr_matrix],
n_instances: int = 20,
metric: Union[str, Callable] = 'euclidean',
n_jobs: Optional[int] = None,
**uncertainty_measure_kwargs
)
| 185 | |
| 186 | |
| 187 | def uncertainty_batch_sampling(classifier: Union[BaseLearner, BaseCommittee], |
| 188 | X: Union[np.ndarray, sp.csr_matrix], |
| 189 | n_instances: int = 20, |
| 190 | metric: Union[str, Callable] = 'euclidean', |
| 191 | n_jobs: Optional[int] = None, |
| 192 | **uncertainty_measure_kwargs |
| 193 | ) -> np.ndarray: |
| 194 | """ |
| 195 | Batch sampling query strategy. Selects the least sure instances for labelling. |
| 196 | |
| 197 | This strategy differs from :func:`~modAL.uncertainty.uncertainty_sampling` because, although it is supported, |
| 198 | traditional active learning query strategies suffer from sub-optimal record selection when passing |
| 199 | `n_instances` > 1. This sampling strategy extends the interactive uncertainty query sampling by allowing for |
| 200 | batch-mode uncertainty query sampling. Furthermore, it also enforces a ranking -- that is, which records among the |
| 201 | batch are most important for labeling? |
| 202 | |
| 203 | Refer to Cardoso et al.'s "Ranked batch-mode active learning": |
| 204 | https://www.sciencedirect.com/science/article/pii/S0020025516313949 |
| 205 | |
| 206 | Args: |
| 207 | classifier: One of modAL's supported active learning models. |
| 208 | X: Set of records to be considered for our active learning model. |
| 209 | n_instances: Number of records to return for labeling from `X`. |
| 210 | metric: This parameter is passed to :func:`~sklearn.metrics.pairwise.pairwise_distances` |
| 211 | n_jobs: If not set, :func:`~sklearn.metrics.pairwise.pairwise_distances_argmin_min` is used for calculation of |
| 212 | distances between samples. Otherwise it is passed to :func:`~sklearn.metrics.pairwise.pairwise_distances`. |
| 213 | **uncertainty_measure_kwargs: Keyword arguments to be passed for the :meth:`predict_proba` of the classifier. |
| 214 | |
| 215 | Returns: |
| 216 | Indices of the instances from `X` chosen to be labelled |
| 217 | Records from `X` chosen to be labelled. |
| 218 | The uncertainty scores of the chosen instances. |
| 219 | |
| 220 | """ |
| 221 | uncertainty = classifier_uncertainty(classifier, X, **uncertainty_measure_kwargs) |
| 222 | return ranked_batch(classifier, unlabeled=X, uncertainty_scores=uncertainty, |
| 223 | n_instances=n_instances, metric=metric, n_jobs=n_jobs) |
| 224 |
nothing calls this directly
no test coverage detected
searching dependent graphs…