simple_batch#

skactiveml.utils.simple_batch(utilities, random_state=None, batch_size=1, return_utilities=False, method='max')[source]#

Select a batch of entries from the given utilities without replacement.

Each entry represents one action. For example, a utility matrix can represent sample-annotator pairs. Selection is global over all entries, and only selected entries are excluded from subsequent batch steps.

Parameters:
utilitiesnp.ndarray

The utilities of the actions. np.nan excludes an entry. For proportional selection, utilities must be nonnegative, with at least batch_size positive entries after reducing the batch size to the number of available entries. If no entries are available, the result is empty.

random_stateint, RandomState instance or None, default=None

The random state to use.

batch_sizeint, default=1

The number of entries to select. If larger than the number of available entries, it is reduced with a warning.

return_utilitiesbool, default=False

If True, the utilities are returned.

methodstr, default=’max’

‘max’ selects the largest utilities. ‘proportional’ samples entries with probabilities proportional to their utilities.

Returns:
best_indicesnp.ndarray of shape (batch_size,) if utilities.ndim == 1 else (batch_size, utilities.ndim)

The indices of the selected entries, using one coordinate per utility dimension for multidimensional input.

batch_utilitiesnp.ndarray of shape (batch_size, *utilities.shape)

Utilities before each batch selection, with previously selected entries set to np.nan (if return_utilities=True).

Examples using skactiveml.utils.simple_batch#

Dual Strategy for Active Learning

Dual Strategy for Active Learning