§
    rŠtjƒ5  ã                   ó  — d dl Zd dlmZmZ d dlmZ d dlmZ d dl	m
Z
mZmZmZmZ  G d„ d¦  «        Z G d„ d	¦  «        Z G d
„ dee¦  «        Z edg d¬¦  «        e_         G d„ de¦  «        Zd„ Z G d„ de¦  «        ZdS )é    N)ÚBaseEstimatorÚClassifierMixin)ÚRequestMethod)Úavailable_if)Ú_check_sample_weightÚ_num_samplesÚcheck_arrayÚcheck_is_fittedÚcheck_random_statec                   ó   — e Zd ZdZd„ Zd„ ZdS )ÚArraySlicingWrapperú-
    Parameters
    ----------
    array
    c                 ó   — || _         d S ©N©Úarray©Úselfr   s     úT/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/sklearn/utils/_mocking.pyÚ__init__zArraySlicingWrapper.__init__   s   € ØˆŒ
ˆ
ˆ
ó    c                 ó6   — t          | j        |         ¦  «        S r   ©ÚMockDataFramer   )r   Úaslices     r   Ú__getitem__zArraySlicingWrapper.__getitem__   s   € Ý˜TœZ¨Ô/Ñ0Ô0Ð0r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   © r   r   r   r      s<   € € € € € ðð ðð ð ð1ð 1ð 1ð 1ð 1r   r   c                   ó:   — e Zd ZdZd„ Zd„ Zd
d„Zd„ Zd„ Zdd	„Z	dS )r   r   c                 óz   — || _         || _        |j        | _        |j        | _        t	          |¦  «        | _        d S r   )r   ÚvaluesÚshapeÚndimr   Úilocr   s     r   r   zMockDataFrame.__init__)   s5   € ØˆŒ
ØˆŒØ”[ˆŒ
Ø”JˆŒ	å'¨Ñ.Ô.ˆŒ	ˆ	ˆ	r   c                 ó*   — t          | j        ¦  «        S r   )Úlenr   )r   s    r   Ú__len__zMockDataFrame.__len__1   s   € Ý�4”:‰ŒÐr   Nc                 ó   — | j         S r   r   )r   Údtypes     r   Ú	__array__zMockDataFrame.__array__4   s   € ð ŒzÐr   c                 ó<   — t          | j        |j        k    ¦  «        S r   r   ©r   Úothers     r   Ú__eq__zMockDataFrame.__eq__:   s   € Ý˜TœZ¨5¬;Ò6Ñ7Ô7Ð7r   c                 ó   — | |k     S r   r!   r/   s     r   Ú__ne__zMockDataFrame.__ne__=   s   € Ø˜5’=Ð Ð r   r   c                 óT   — t          | j                             ||¬¦  «        ¦  «        S )N©Úaxis)r   r   Útake)r   Úindicesr6   s      r   r7   zMockDataFrame.take@   s"   € Ý˜TœZŸ_š_¨W¸4˜_Ñ@Ô@ÑAÔAÐAr   r   )r   )
r   r   r   r    r   r*   r-   r1   r3   r7   r!   r   r   r   r       sˆ   € € € € € ðð ð/ð /ð /ðð ð ðð ð ð ð8ð 8ð 8ð!ð !ð !ðBð Bð Bð Bð Bð Br   r   c            
       óh   ‡ — e Zd ZdZddddddddddœ	d„Zdd„Zdd	„Zd
„ Zd„ Zd„ Z	dd„Z
ˆ fd„Zˆ xZS )ÚCheckingClassifiera$	  Dummy classifier to test pipelining and meta-estimators.

    Checks some property of `X` and `y`in fit / predict.
    This allows testing whether pipelines / cross-validation or metaestimators
    changed the input.

    Can also be used to check if `fit_params` are passed correctly, and
    to force a certain score to be returned.

    Parameters
    ----------
    check_y, check_X : callable, default=None
        The callable used to validate `X` and `y`. These callable should return
        a bool where `False` will trigger an `AssertionError`. If `None`, the
        data is not validated. Default is `None`.

    check_y_params, check_X_params : dict, default=None
        The optional parameters to pass to `check_X` and `check_y`. If `None`,
        then no parameters are passed in.

    methods_to_check : "all" or list of str, default="all"
        The methods in which the checks should be applied. By default,
        all checks will be done on all methods (`fit`, `predict`,
        `predict_proba`, `decision_function` and `score`).

    foo_param : int, default=0
        A `foo` param. When `foo > 1`, the output of :meth:`score` will be 1
        otherwise it is 0.

    expected_sample_weight : bool, default=False
        Whether to check if a valid `sample_weight` was passed to `fit`.

    expected_fit_params : list of str, default=None
        A list of the expected parameters given when calling `fit`.

    Attributes
    ----------
    classes_ : int
        The classes seen during `fit`.

    n_features_in_ : int
        The number of features seen during `fit`.

    Examples
    --------
    >>> from sklearn.utils._mocking import CheckingClassifier

    This helper allow to assert to specificities regarding `X` or `y`. In this
    case we expect `check_X` or `check_y` to return a boolean.

    >>> from sklearn.datasets import load_iris
    >>> X, y = load_iris(return_X_y=True)
    >>> clf = CheckingClassifier(check_X=lambda x: x.shape == (150, 4))
    >>> clf.fit(X, y)
    CheckingClassifier(...)

    We can also provide a check which might raise an error. In this case, we
    expect `check_X` to return `X` and `check_y` to return `y`.

    >>> from sklearn.utils import check_array
    >>> clf = CheckingClassifier(check_X=check_array)
    >>> clf.fit(X, y)
    CheckingClassifier(...)
    NÚallr   ©	Úcheck_yÚcheck_y_paramsÚcheck_XÚcheck_X_paramsÚmethods_to_checkÚ	foo_paramÚexpected_sample_weightÚexpected_fit_paramsÚrandom_statec       	         ó„   — || _         || _        || _        || _        || _        || _        || _        || _        |	| _        d S r   r<   )
r   r=   r>   r?   r@   rA   rB   rC   rD   rE   s
             r   r   zCheckingClassifier.__init__†   sO   € ð ˆŒØ,ˆÔØˆŒØ,ˆÔØ 0ˆÔØ"ˆŒØ&<ˆÔ#Ø#6ˆÔ Ø(ˆÔÐÐr   Tc                 ód  — |rt          | ¦  «         | j        �F| j        €i n| j        } | j        |fi |¤Ž}t          |t          t
          j        f¦  «        r|sJ ‚n|}|�M| j        �F| j        €i n| j        } | j        |fi |¤Ž}t          |t          t
          j        f¦  «        r|sJ ‚n|}||fS )at  Validate X and y and make extra check.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features)
            The data set.
            `X` is checked only if `check_X` is not `None` (default is None).
        y : array-like of shape (n_samples), default=None
            The corresponding target, by default `None`.
            `y` is checked only if `check_y` is not `None` (default is None).
        should_be_fitted : bool, default=True
            Whether or not the classifier should be already fitted.
            By default True.

        Returns
        -------
        X, y
        )	r
   r?   r@   Ú
isinstanceÚboolÚnpÚbool_r=   r>   )r   ÚXÚyÚshould_be_fittedÚparamsÚ	checked_XÚ	checked_ys          r   Ú
_check_X_yzCheckingClassifier._check_X_y�   sé   € ð& ð 	"Ý˜DÑ!Ô!Ð!ØŒ<Ð#ØÔ.Ð6�R�R¸DÔ<OˆFØ$˜œ QÐ1Ð1¨&Ð1Ð1ˆIÝ˜)¥d­B¬HÐ%5Ñ6Ô6ð Ø Ð Ð �yÐ à�Øˆ=˜Tœ\Ð5ØÔ.Ð6�R�R¸DÔ<OˆFØ$˜œ QÐ1Ð1¨&Ð1Ð1ˆIÝ˜)¥d­B¬HÐ%5Ñ6Ô6ð Ø Ð Ð �yÐ à�Ø�!ˆtˆr   c                 óü  — t          |¦  «        t          |¦  «        k    sJ ‚| j        dk    s	d| j        v r|                      ||d¬¦  «        \  }}t          j        |¦  «        d         | _        t          j        t          |dd¬¦  «        ¦  «        | _        | j	        r³t          | j	        ¦  «        t          |¦  «        z
  }|r t          dt          |¦  «        › d	�¦  «        ‚|                     ¦   «         D ]X\  }}t          |¦  «        t          |¦  «        k    r3t          d
|› dt          |¦  «        › dt          |¦  «        › d�¦  «        ‚ŒY| j        r!|€t          d¦  «        ‚t          ||¦  «         | S )a   Fit classifier.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features)
            Training vector, where `n_samples` is the number of samples and
            `n_features` is the number of features.

        y : array-like of shape (n_samples, n_outputs) or (n_samples,),                 default=None
            Target relative to X for classification or regression;
            None for unsupervised learning.

        sample_weight : array-like of shape (n_samples,), default=None
            Sample weights. If None, then samples are equally weighted.

        **fit_params : dict of string -> object
            Parameters passed to the ``fit`` method of the estimator

        Returns
        -------
        self
        r;   ÚfitF)rN   é   T)Ú	ensure_2dÚallow_ndzExpected fit parameter(s) z
 not seen.zFit parameter z has length z; expected ú.Nz#Expected sample_weight to be passed)r   rA   rR   rJ   r%   Ún_features_in_Úuniquer	   Úclasses_rD   ÚsetÚAssertionErrorÚlistÚitemsrC   r   )r   rL   rM   Úsample_weightÚ
fit_paramsÚmissingÚkeyÚvalues           r   rT   zCheckingClassifier.fitÂ   s¤  € õ0 ˜A‰Œ¥,¨q¡/¤/Ò1Ð1Ð1Ð1ØÔ  EÒ)Ð)¨U°dÔ6KÐ-KÐ-KØ—?’? 1 a¸%�?Ñ@Ô@‰DˆAˆqÝ œh q™kœk¨!œnˆÔÝœ	¥+¨a¸5È4Ð"PÑ"PÔ"PÑQÔQˆŒØÔ#ð 	Ý˜$Ô2Ñ3Ô3µc¸*±o´oÑEˆGØð Ý$ØJµ°g±´ÐJÐJÐJñô ð ð )×.Ò.Ñ0Ô0ð ð ‘
��UÝ Ñ&Ô&­,°q©/¬/Ò9Ð9Ý(ð9¨ð 9ð 9½,ÀuÑ:MÔ:Mð 9ð 9Ý&2°1¡o¤oð9ð 9ð 9ñô ð ð :ð
 Ô&ð 	3ØÐ$Ý$Ð%JÑKÔKÐKÝ  °Ñ2Ô2Ð2àˆr   c                 óÔ   — | j         dk    s	d| j         v r|                      |¦  «        \  }}t          | j        ¦  «        }|                     | j        t          |¦  «        ¬¦  «        S )a=  Predict the first class seen in `classes_`.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features)
            The input data.

        Returns
        -------
        preds : ndarray of shape (n_samples,)
            Predictions of the first class seen in `classes_`.
        r;   Úpredict)Úsize)rA   rR   r   rE   Úchoicer[   r   ©r   rL   rM   Úrngs       r   rf   zCheckingClassifier.predictò   sb   € ð Ô  EÒ)Ð)¨Y¸$Ô:OÐ-OÐ-OØ—?’? 1Ñ%Ô%‰DˆAˆqÝ  Ô!2Ñ3Ô3ˆØ�zŠz˜$œ-­l¸1©o¬oˆzÑ>Ô>Ð>r   c                 óv  — | j         dk    s	d| j         v r|                      |¦  «        \  }}t          | j        ¦  «        }|                     t          |¦  «        t          | j        ¦  «        ¦  «        }t          j	        ||¬¦  «        }|t          j
        |d¬¦  «        dd…t          j        f         z  }|S )aº  Predict probabilities for each class.

        Here, the dummy classifier will provide a probability of 1 for the
        first class of `classes_` and 0 otherwise.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features)
            The input data.

        Returns
        -------
        proba : ndarray of shape (n_samples, n_classes)
            The probabilities for each sample and class.
        r;   Úpredict_proba)ÚoutrU   r5   N)rA   rR   r   rE   Úrandnr   r)   r[   rJ   ÚabsÚsumÚnewaxis)r   rL   rM   rj   Úprobas        r   rl   z CheckingClassifier.predict_proba  s¨   € ð  Ô  EÒ)Ð)¨_ÀÔ@UÐ-UÐ-UØ—?’? 1Ñ%Ô%‰DˆAˆqÝ  Ô!2Ñ3Ô3ˆØ—	’	�, q™/œ/­3¨t¬}Ñ+=Ô+=Ñ>Ô>ˆÝ”�u %Ð(Ñ(Ô(ˆØ•”˜ AÐ&Ñ&Ô& q q q­"¬* }Ô5Ñ5ˆØˆr   c                 ó`  — | j         dk    s	d| j         v r|                      |¦  «        \  }}t          | j        ¦  «        }t	          | j        ¦  «        dk    r"|                     t          |¦  «        ¦  «        S |                     t          |¦  «        t	          | j        ¦  «        ¦  «        S )aB  Confidence score.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features)
            The input data.

        Returns
        -------
        decision : ndarray of shape (n_samples,) if n_classes == 2                else (n_samples, n_classes)
            Confidence score.
        r;   Údecision_functioné   )rA   rR   r   rE   r)   r[   rn   r   ri   s       r   rt   z$CheckingClassifier.decision_function  s˜   € ð Ô! UÒ*Ð*Ø" dÔ&;Ð;Ð;à—?’? 1Ñ%Ô%‰DˆAˆqÝ  Ô!2Ñ3Ô3ˆÝˆtŒ}ÑÔ Ò"Ð"ð —9’9�\¨!™_œ_Ñ-Ô-Ð-à—9’9�\¨!™_œ_­c°$´-Ñ.@Ô.@ÑAÔAÐAr   c                 óz   — | j         dk    s	d| j         v r|                      ||¦  «         | j        dk    rd}nd}|S )aQ  Fake score.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features)
            Input data, where `n_samples` is the number of samples and
            `n_features` is the number of features.

        Y : array-like of shape (n_samples, n_output) or (n_samples,)
            Target relative to X for classification or regression;
            None for unsupervised learning.

        Returns
        -------
        score : float
            Either 0 or 1 depending of `foo_param` (i.e. `foo_param > 1 =>
            score=1` otherwise `score=0`).
        r;   ÚscorerU   g      ð?g        )rA   rR   rB   )r   rL   ÚYrw   s       r   rw   zCheckingClassifier.score7  sQ   € ð& Ô  EÒ)Ð)¨W¸Ô8MÐ-MÐ-MØ�OŠO˜A˜qÑ!Ô!Ð!ØŒ>˜AÒÐØˆEˆEàˆEØˆr   c                 ó†   •— t          ¦   «                              ¦   «         }d|_        d|j        _        d|j        _        |S )NTF)ÚsuperÚ__sklearn_tags__Ú
_skip_testÚ
input_tagsÚtwo_d_arrayÚtarget_tagsÚone_d_labels©r   ÚtagsÚ	__class__s     €r   r{   z#CheckingClassifier.__sklearn_tags__R  s9   ø€ Ý‰wŒw×'Ò'Ñ)Ô)ˆØˆŒØ&+ˆŒÔ#Ø(,ˆÔÔ%Øˆr   ©NTr   )NN)r   r   r   r    r   rR   rT   rf   rl   rt   rw   r{   Ú__classcell__©rƒ   s   @r   r:   r:   D   sç   ø€ € € € € ð?ð ?ðH ØØØØØØ#Ø Øð)ð )ð )ð )ð )ð.#ð #ð #ð #ðJ.ð .ð .ð .ð`?ð ?ð ?ð$ð ð ð0Bð Bð Bð6ð ð ð ð6ð ð ð ð ð ð ð ð r   r:   rT   F)ÚnameÚkeysÚvalidate_keysc                   ó<   ‡ — e Zd ZdZdd„Zd„ Zd„ Zd„ Zˆ fd„Zˆ xZ	S )	ÚNoSampleWeightWrapperzšWrap estimator which will not expose `sample_weight`.

    Parameters
    ----------
    est : estimator, default=None
        The estimator to wrap.
    Nc                 ó   — || _         d S r   )Úest)r   r�   s     r   r   zNoSampleWeightWrapper.__init__k  s   € ØˆŒˆˆr   c                 ó8   — | j                              ||¦  «        S r   )r�   rT   ©r   rL   rM   s      r   rT   zNoSampleWeightWrapper.fitn  s   € ØŒx�|Š|˜A˜qÑ!Ô!Ð!r   c                 ó6   — | j                              |¦  «        S r   )r�   rf   ©r   rL   s     r   rf   zNoSampleWeightWrapper.predictq  s   € ØŒx×Ò Ñ"Ô"Ð"r   c                 ó6   — | j                              |¦  «        S r   )r�   rl   r‘   s     r   rl   z#NoSampleWeightWrapper.predict_probat  s   € ØŒx×%Ò% aÑ(Ô(Ð(r   c                 óV   •— t          ¦   «                              ¦   «         }d|_        |S r„   )rz   r{   r|   r�   s     €r   r{   z&NoSampleWeightWrapper.__sklearn_tags__w  s$   ø€ Ý‰wŒw×'Ò'Ñ)Ô)ˆØˆŒØˆr   r   )
r   r   r   r    r   rT   rf   rl   r{   r…   r†   s   @r   r‹   r‹   b  sƒ   ø€ € € € € ðð ðð ð ð ð"ð "ð "ð#ð #ð #ð)ð )ð )ðð ð ð ð ð ð ð ð r   r‹   c                 ó   ‡ — ˆ fd„}|S )Nc                 ó(   •— | j         d uo‰| j         v S r   ©Úresponse_methods)r   Úmethods    €r   Úcheckz_check_response.<locals>.check~  s   ø€ ØÔ$¨DÐ0ÐT°V¸tÔ?TÐ5TÐTr   r!   )r˜   r™   s   ` r   Ú_check_responserš   }  s(   ø€ ðUð Uð Uð Uð Uð €Lr   c                   óÎ   — e Zd ZdZdd„Zd„ Z e ed¦  «        ¦  «        d„ ¦   «         Z e ed¦  «        ¦  «        d„ ¦   «         Z	 e ed	¦  «        ¦  «        d
„ ¦   «         Z
dS )Ú_MockEstimatorOnOffPredictiona  Estimator for which we can turn on/off the prediction methods.

    Parameters
    ----------
    response_methods: list of             {"predict", "predict_proba", "decision_function"}, default=None
        List containing the response implemented by the estimator. When, the
        response is in the list, it will return the name of the response method
        when called. Otherwise, an `AttributeError` is raised. It allows to
        use `getattr` as any conventional estimator. By default, no response
        methods are mocked.
    Nc                 ó   — || _         d S r   r–   )r   r—   s     r   r   z&_MockEstimatorOnOffPrediction.__init__’  s   € Ø 0ˆÔÐÐr   c                 ó8   — t          j        |¦  «        | _        | S r   )rJ   rZ   r[   r�   s      r   rT   z!_MockEstimatorOnOffPrediction.fit•  s   € Ýœ	 !™œˆŒØˆr   rf   c                 ó   — dS )Nrf   r!   r‘   s     r   rf   z%_MockEstimatorOnOffPrediction.predict™  s   € àˆyr   rl   c                 ó   — dS )Nrl   r!   r‘   s     r   rl   z+_MockEstimatorOnOffPrediction.predict_proba�  s   € àˆr   rt   c                 ó   — dS )Nrt   r!   r‘   s     r   rt   z/_MockEstimatorOnOffPrediction.decision_function¡  s   € à"Ð"r   r   )r   r   r   r    r   rT   r   rš   rf   rl   rt   r!   r   r   rœ   rœ   „  sÒ   € € € € € ðð ð1ð 1ð 1ð 1ðð ð ð €\�/�/ )Ñ,Ô,Ñ-Ô-ðð ñ .Ô-ðð €\�/�/ /Ñ2Ô2Ñ3Ô3ðð ñ 4Ô3ðð €\�/�/Ð"5Ñ6Ô6Ñ7Ô7ð#ð #ñ 8Ô7ð#ð #ð #r   rœ   )ÚnumpyrJ   Úsklearn.baser   r   Ú sklearn.utils._metadata_requestsr   Úsklearn.utils.metaestimatorsr   Úsklearn.utils.validationr   r   r	   r
   r   r   r   r:   Úset_fit_requestr‹   rš   rœ   r!   r   r   ú<module>r¨      s³  ðð Ð Ð Ð à 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ø :Ð :Ð :Ð :Ð :Ð :Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5ðð ð ð ð ð ð ð ð ð ð ð ð ð ð1ð 1ð 1ð 1ð 1ñ 1ô 1ð 1ð!Bð !Bð !Bð !Bð !Bñ !Bô !Bð !BðHSð Sð Sð Sð S˜¨-ñ Sô Sð Sðr &3 ]Ø	�R uð&ñ &ô &Ð Ô "ð
ð ð ð ð ˜Mñ ô ð ð6ð ð ð#ð #ð #ð #ð # Mñ #ô #ð #ð #ð #r   