§
    rŠtjŠ  ã                   ó¦   — d dl mZ d dlZd dlmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ d„ Zd	„ Z e
d
dgd
gdœd¬¦  «        d„ ¦   «         Zd„ Zd„ ZdS )é    )ÚsuppressN)Úsparse)Úis_scalar_nan)Úvalidate_params)Ú_align_api_if_sparse)Ú_object_dtype_isnanc                 óº  — t          t          t          ¦  «        5  dd l}||j        u r!|                     | ¦  «        cd d d ¦  «         S 	 d d d ¦  «         n# 1 swxY w Y   t          |¦  «        rd| j        j        dk    rt          j
        | ¦  «        }nE| j        j        dv r!t          j        | j        t          ¬¦  «        }nt          | ¦  «        }n| |k    }|S )Nr   Úf)ÚiÚu©Údtype)r   ÚImportErrorÚAttributeErrorÚpandasÚNAÚisnar   r   ÚkindÚnpÚisnanÚzerosÚshapeÚboolr   )ÚXÚvalue_to_maskr   ÚXts       úQ/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/sklearn/utils/_mask.pyÚ_get_dense_maskr      s0  € Ý	•+�~Ñ	.Ô	.ð "ð "ð 	ˆˆˆà˜FœIÐ%Ð%Ø—;’;˜q‘>”>ð"ð "ð "ð "ñ "ô "ð "ð "ð
 &ð"ð "ð "ñ "ô "ð "ð "ð "ð "ð "ð "øøøð "ð "ð "ð "õ �]Ñ#Ô#ð 
 ØŒ7Œ<˜3ÒÐÝ”˜!‘”ˆBˆBØŒWŒ\˜ZÐ'Ð'å”˜!œ'­Ð.Ñ.Ô.ˆBˆBõ % QÑ'Ô'ˆBˆBà�-Òˆà€Is   ›"AÁAÁAc                 ój  — t          j        | ¦  «        st          | |¦  «        S t          | j        |¦  «        }| j        dk    rt           j        nt           j        } ||| j                             ¦   «         | j	                             ¦   «         f| j
        t          ¬¦  «        }t          |¦  «        S )aÏ  Compute the boolean mask X == value_to_mask.

    Parameters
    ----------
    X : {ndarray, sparse matrix} of shape (n_samples, n_features)
        Input data, where ``n_samples`` is the number of samples and
        ``n_features`` is the number of features.

    value_to_mask : {int, float}
        The value which is to be masked in X.

    Returns
    -------
    X_mask : {ndarray, sparse matrix} of shape (n_samples, n_features)
        Missing mask.
    Úcsr)r   r   )ÚspÚissparser   ÚdataÚformatÚ	csr_arrayÚ	csc_arrayÚindicesÚcopyÚindptrr   r   r   )r   r   r   Úsparse_constructorÚ	Xt_sparses        r   Ú	_get_maskr,   '   sž   € õ" Œ;�q‰>Œ>ð 1õ ˜q -Ñ0Ô0Ð0å	˜œ Ñ	/Ô	/€Bà)*¬°UÒ):Ð):�œ˜ÅÄÐØ"Ð"Ø	ˆQŒY�^Š^ÑÔ˜qœxŸ}š}™œÐ/°q´wÅdðñ ô €Iõ   	Ñ*Ô*Ð*ó    z
array-likezsparse matrix)r   ÚmaskT)Úprefer_skip_nested_validationc                 óè   — t          j        |¦  «        }t          j        |j        t           j        ¦  «        r|S t          | d¦  «        r't          j        |j        d         ¦  «        }||         }|S )aq  Return a mask which is safe to use on X.

    Parameters
    ----------
    X : {array-like, sparse matrix}
        Data on which to apply mask.

    mask : array-like
        Mask to be used on X.

    Returns
    -------
    mask : ndarray
        Array that is safe to use on X.

    Examples
    --------
    >>> from sklearn.utils import safe_mask
    >>> from scipy.sparse import csr_array
    >>> data = csr_array([[1], [2], [3], [4], [5]])
    >>> condition = [False, True, True, False, True]
    >>> mask = safe_mask(data, condition)
    >>> data[mask].toarray()
    array([[2],
           [3],
           [5]])
    Útoarrayr   )r   ÚasarrayÚ
issubdtyper   ÚsignedintegerÚhasattrÚaranger   )r   r.   Úinds      r   Ú	safe_maskr8   G   sg   € õF Œ:�dÑÔ€DÝ	„}�T”Z¥Ô!1Ñ2Ô2ð Øˆåˆq�)ÑÔð ÝŒi˜œ
 1œÑ&Ô&ˆØ�4ŒyˆØ€Kr-   c                 ó†   — |dk    r| t          | |¦  «        dd…f         S t          j        d| j        d         f¬¦  «        S )a’  Return a mask which is safer to use on X than safe_mask.

    This mask is safer than safe_mask since it returns an
    empty array, when a sparse matrix is sliced with a boolean mask
    with all False, instead of raising an unhelpful error in older
    versions of SciPy.

    See: https://github.com/scipy/scipy/issues/5361

    Also note that we can avoid doing the dot product by checking if
    the len_mask is not zero in _huber_loss_and_gradient but this
    is not going to be the bottleneck, since the number of outliers
    and non_outliers are typically non-zero and it makes the code
    tougher to follow.

    Parameters
    ----------
    X : {array-like, sparse matrix}
        Data on which to apply mask.

    mask : ndarray
        Mask to be used on X.

    len_mask : int
        The length of the mask.

    Returns
    -------
    mask : ndarray
        Array that is safe to use on X.
    r   Né   )r   )r8   r   r   r   )r   r.   Úlen_masks      r   Úaxis0_safe_slicer<   t   sI   € ð@ �1‚}€}Ø•˜1˜dÑ#Ô# Q Q QÐ&Ô'Ð'ÝŒ8˜1˜aœg aœj˜/Ð*Ñ*Ô*Ð*r-   c                 ó”   — |t          j        | ¦  «        k    rt          d¦  «        ‚t          j        |t          ¬¦  «        }d|| <   |S )aY  Convert list of indices to boolean mask.

    Parameters
    ----------
    indices : list-like
        List of integers treated as indices.
    mask_length : int
        Length of boolean mask to be generated.
        This parameter must be greater than max(indices).

    Returns
    -------
    mask : 1d boolean nd-array
        Boolean array that is True where indices are present, else False.

    Examples
    --------
    >>> from sklearn.utils._mask import indices_to_mask
    >>> indices = [1, 2 , 3, 4]
    >>> indices_to_mask(indices, 5)
    array([False,  True,  True,  True,  True])
    z-mask_length must be greater than max(indices)r   T)r   ÚmaxÚ
ValueErrorr   r   )r'   Úmask_lengthr.   s      r   Úindices_to_maskrA   ™   sH   € ð. •b”f˜W‘o”oÒ%Ð%ÝÐHÑIÔIÐIåŒ8�K¥tÐ,Ñ,Ô,€DØ€Dˆ�Mà€Kr-   )Ú
contextlibr   Únumpyr   Úscipyr   r!   Úsklearn.utils._missingr   Úsklearn.utils._param_validationr   Úsklearn.utils._sparser   Úsklearn.utils.fixesr   r   r,   r8   r<   rA   © r-   r   ú<module>rJ      s  ðð  Ð Ð Ð Ð Ð à Ð Ð Ð Ø Ð Ð Ð Ð Ð à 0Ð 0Ð 0Ð 0Ð 0Ð 0Ø ;Ð ;Ð ;Ð ;Ð ;Ð ;Ø 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3ðð ð ð0+ð +ð +ð@ €à˜OÐ,Ø�ðð ð #'ðñ ô ð#ð #ñô ð#ðL"+ð "+ð "+ðJð ð ð ð r-   