majority_vote#
- skactiveml.utils.majority_vote(y, w=None, classes=None, missing_label=nan, random_state=None)[source]#
Assigns a label to each sample based on weighted voting. Samples with no labels are assigned with missing_label.
A matrix without any observed label therefore aggregates to missing_label for every sample. That result needs no class vocabulary, so it is returned for classes=None as well.
- Parameters:
- yarray-like, shape (n_samples,) or (n_samples, n_annotators)
Class labels, which may contain also missing labels.
- warray-like, shape (n_samples) or (n_samples, n_annotators) or None, default=None
Class label weights. One-dimensional weights apply to every annotation of the corresponding sample. Two-dimensional weights specify one weight per annotation. If None, every annotation has unit weight.
- classesarray-like of shape (n_classes,), default=None
Holds the label for each class.
- missing_labelscalar or string or np.nan or None, default=np.nan
Value to represent a missing label.
- random_stateint or RandomState instance or None, default=None
Determines random number generation for shuffling the data. Pass an int for reproducible results across multiple function calls.
- Returns:
- y_aggregatednumpy.ndarray of shape (n_samples,)
Assigned labels for each sample.