�
J�g�N � �� � d Z ddlZddlmZ ddlmZ ddlZddlm Z ddl
mZ ddlm
Z
d d
lmZmZ d dlmZmZ dd�Zdd
�Zeeed�Zd� Zd� Zd� Zd� Zdd�Zdd�Zdd�Zd� ZdS )zAUtilities to handle multiclass/multioutput target in classifiers.� N)�Sequence)�chain)�issparse� )�
get_namespace)�VisibleDeprecationWarning� )�
attach_unique�
cached_unique)�_assert_all_finite�check_arrayc � � t | |�� � \ }}t | d� � s|r$t |� | � � |�� � S t | � � S )N��xp� __array__)r �hasattrr �asarray�set��yr �is_array_api_compliants �h/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/sklearn/utils/multiclass.py�_unique_multiclassr s\ � �!.�q�R�!8�!8�!8��B���q�+��� �"8� ��R�Z�Z��]�]�r�2�2�2�2��1�v�v�
� c � � t | |�� � \ }}|� t | dg d��� � j d � � S )Nr r ��csr�csc�coo)�
input_name�
accept_sparser )r �aranger
�shape)r r �_s r �_unique_indicatorr% sP � ��!��#�#�#�E�B��
�9�9��A�#�5J�5J�5J�K�K�K�Q�RS�T�� � r )�binary�
multiclass�multilabel-indicatorc � ��� t | ddi�} t | � \ �}t | � � dk rt d� � �t d� | D � � � � }|ddhk rdh}t |� � dk rt d |z � � �|� � � }|d
k r9t t d� | D � � � � � � dk rt d� � �t � |d
� � ��st dt | � � z � � �|r7�� ��fd�| D � � � � }��
|� � S t t j ��fd�| D � � � � � � }t t d� |D � � � � � � dk rt d� � ���
t |� � � � S )a� 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
----------
*ys : array-likes
Label values.
Returns
-------
out : ndarray 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])
�return_tupleTr zNo argument has been passed.c 3 �4 K � | ]}t |� � V � �d S �N)�type_of_target)�.0�xs r � <genexpr>z unique_labels.<locals>.<genexpr>O s* � � � �1�1��>�!�$�$�1�1�1�1�1�1r r&