§
    §éUg54  ã                   ó  — 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     úU/var/www/surfInsights/venv3-11/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__.   s   € Ý�4”:‰ŒÐr   Nc                 ó   — | j         S r   r   )r   Údtypes     r   Ú	__array__zMockDataFrame.__array__1   s   € ð ŒzÐr   c                 ó<   — t          | j        |j        k    ¦  «        S r   r   ©r   Úothers     r   Ú__eq__zMockDataFrame.__eq__7   s   € Ý˜TœZ¨5¬;Ò6Ñ7Ô7Ð7r   c                 ó   — | |k     S r   r#   r2   s     r   Ú__ne__zMockDataFrame.__ne__:   s   € Ø˜5’=Ð Ð r   r   c                 óT   — t          | j                             ||¬¦  «        ¦  «        S )N©Úaxis)r   r   Útake)r   Úindicesr9   s      r   r:   zMockDataFrame.take=   s"   € Ý˜TœZŸ_š_¨W¸4˜_Ñ@Ô@ÑAÔAÐAr   r   )r   )
r   r    r!   r"   r   r-   r0   r4   r6   r:   r#   r   r   r   r      sˆ   € € € € € ðð ð/ð /ð /ðð ð ðð ð ð ð8ð 8ð 8ð!ð !ð !ðBð Bð Bð Bð Bð Br   r   c            
       ó^   — 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
d„ Zd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@   rA   rB   rC   rD   rE   rF   rG   rH   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   rB   rC   Ú
isinstanceÚboolÚnpÚbool_r@   rA   )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ð Ø Ð Ð Ð Ð à�Øˆ=˜Tœ\Ð5ØÔ.Ð6�R�R¸DÔ<OˆFØ$˜œ QÐ1Ð1¨&Ð1Ð1ˆIÝ˜)¥d­B¬HÐ%5Ñ6Ô6ð Ø Ð Ð Ð Ð à�Ø�!ˆ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)rQ   r   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
   rD   rU   rM   r'   Ún_features_in_Úuniquer   Úclasses_rG   ÚsetÚAssertionErrorÚlistÚitemsrF   r	   )r   rO   rP   Úsample_weightÚ
fit_paramsÚmissingÚkeyÚvalues           r   rW   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 seens in `classes_`.
        r>   Úpredict)Úsize)rD   rU   r   rH   Úchoicer]   r
   ©r   rO   rP   Úrngs       r   rh   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)Úoutr   r8   N)rD   rU   r   rH   Úrandnr
   r+   r]   rM   ÚabsÚsumÚnewaxis)r   rO   rP   rl   Úprobas        r   rn   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_functionr   )rD   rU   r   rH   r+   r]   rp   r
   rk   s       r   rv   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>   Úscorer   g      ð?g        )rD   rU   rE   )r   rO   ÚYrx   s       r   rx   zCheckingClassifier.score4  sQ   € ð& Ô  EÒ)Ð)¨W¸Ô8MÐ-MÐ-MØ�OŠO˜A˜qÑ!Ô!Ð!ØŒ>˜AÒÐØˆEˆEàˆEØˆr   c                 ó   — ddgdœS )NTÚ1dlabel)Ú
_skip_testÚX_typesr#   r,   s    r   Ú
_more_tagszCheckingClassifier._more_tagsO  s   € Ø"°	¨{Ð;Ð;Ð;r   )NTr   )NN)r   r    r!   r"   r   rU   rW   rh   rn   rv   rx   r~   r#   r   r   r=   r=   A   sÒ   € € € € € ð?ð ?ðH ØØØØØØ#Ø Øð)ð )ð )ð )ð )ð.#ð #ð #ð #ðJ.ð .ð .ð .ð`?ð ?ð ?ð$ð ð ð0Bð Bð Bð6ð ð ð ð6<ð <ð <ð <ð <r   r=   rW   F)ÚnameÚkeysÚvalidate_keysc                   ó2   — e Zd ZdZdd„Zd„ Zd„ Zd„ Zd„ Zd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__d  s   € ØˆŒˆˆr   c                 ó8   — | j                              ||¦  «        S r   )r…   rW   ©r   rO   rP   s      r   rW   zNoSampleWeightWrapper.fitg  s   € ØŒx�|Š|˜A˜qÑ!Ô!Ð!r   c                 ó6   — | j                              |¦  «        S r   )r…   rh   ©r   rO   s     r   rh   zNoSampleWeightWrapper.predictj  s   € ØŒx×Ò Ñ"Ô"Ð"r   c                 ó6   — | j                              |¦  «        S r   )r…   rn   r‰   s     r   rn   z#NoSampleWeightWrapper.predict_probam  s   € ØŒx×%Ò% aÑ(Ô(Ð(r   c                 ó
   — ddiS )Nr|   Tr#   r,   s    r   r~   z NoSampleWeightWrapper._more_tagsp  s   € Ø˜dÐ#Ð#r   r   )	r   r    r!   r"   r   rW   rh   rn   r~   r#   r   r   rƒ   rƒ   [  sn   € € € € € ðð ðð ð ð ð"ð "ð "ð#ð #ð #ð)ð )ð )ð$ð $ð $ð $ð $r   rƒ   c                 ó   ‡ — ˆ fd„}|S )Nc                 ó(   •— | j         d uo‰| j         v S r   ©Úresponse_methods)r   Úmethods    €r   Úcheckz_check_response.<locals>.checku  s   ø€ ØÔ$¨DÐ0ÐT°V¸tÔ?TÐ5TÐTr   r#   )r�   r‘   s   ` r   Ú_check_responser’   t  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   )rM   r\   r]   r‡   s      r   rW   z!_MockEstimatorOnOffPrediction.fitŒ  s   € Ýœ	 !™œˆŒØˆr   rh   c                 ó   — dS )Nrh   r#   r‰   s     r   rh   z%_MockEstimatorOnOffPrediction.predict�  s   € àˆyr   rn   c                 ó   — dS )Nrn   r#   r‰   s     r   rn   z+_MockEstimatorOnOffPrediction.predict_proba”  s   € àˆr   rv   c                 ó   — dS )Nrv   r#   r‰   s     r   rv   z/_MockEstimatorOnOffPrediction.decision_function˜  s   € à"Ð"r   r   )r   r    r!   r"   r   rW   r   r’   rh   rn   rv   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”   )ÚnumpyrM   Úbaser   r   Úutils._metadata_requestsr   Úmetaestimatorsr   Ú
validationr	   r
   r   r   r   r   r   r=   Úset_fit_requestrƒ   r’   r”   r#   r   r   ú<module>r       s±  ðØ Ð Ð Ð à 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø 4Ð 4Ð 4Ð 4Ð 4Ð 4Ø (Ð (Ð (Ð (Ð (Ð (ðð ð ð ð ð ð ð ð ð ð ð ð ð ð1ð 1ð 1ð 1ð 1ñ 1ô 1ð 1ð!Bð !Bð !Bð !Bð !Bñ !Bô !Bð !BðHO<ð O<ð O<ð O<ð O<˜¨-ñ O<ô O<ð O<ðj &3 ]Ø	�R uð&ñ &ô &Ð Ô "ð
$ð $ð $ð $ð $˜Mñ $ô $ð $ð2ð ð ð#ð #ð #ð #ð # Mñ #ô #ð #ð #ð #r   