sklearn.utils.multiclass
.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
- 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])