unique_labels#
- sklearn.utils.multiclass.unique_labels(*ys)[source]#
Extract an ordered array of unique labels.
- We donβt allow:
mix of multilabel and multiclass (single label) targets
mix of label indicator matrix and anything else, because there are no explicit labels)
mix of label indicator matrices of different sizes
mix of string and integer labels
At the moment, we also donβt allow βmulticlass-multioutputβ input type.
- Parameters:
- *ysarray-likes
Label values.
- Returns:
- outndarray of shape (n_unique_labels,)
An ordered array of unique labels.
Examples
>>> from sklearn.utils.multiclass import unique_labels >>> unique_labels([3, 5, 5, 5, 7, 7]) array([3, 5, 7]) >>> unique_labels([1, 2, 3, 4], [2, 2, 3, 4]) array([1, 2, 3, 4]) >>> unique_labels([1, 2, 10], [5, 11]) array([ 1, 2, 5, 10, 11])