Ë
    ÷Q(hD5  ã                   óâ   — 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y)é    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y)ÚArraySlicingWrapperú-
    Parameters
    ----------
    array
    c                 ó   — || _         y ©N©Úarray©Úselfr   s     úT/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/sklearn/utils/_mocking.pyÚ__init__zArraySlicingWrapper.__init__   s	   € Øˆ�
ó    c                 ó2   — t        | j                  |   «      S r   ©ÚMockDataFramer   )r   Úaslices     r   Ú__getitem__zArraySlicingWrapper.__getitem__   s   € Ü˜TŸZ™Z¨Ñ/Ó0Ð0r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   © r   r   r   r      s   „ ñòó1r   r   c                   ó8   — e Zd ZdZd„ Zd„ Zd	d„Zd„ Zd„ Zd
d„Z	y)r   r   c                 ó„   — || _         || _        |j                  | _        |j                  | _        t	        |«      | _        y r   )r   ÚvaluesÚshapeÚndimr   Úilocr   s     r   r   zMockDataFrame.__init__)   s2   € ØˆŒ
ØˆŒØ—[‘[ˆŒ
Ø—J‘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‰zÐr   c                 óF   — t        | j                  |j                  k(  «      S r   r   ©r   Úothers     r   Ú__eq__zMockDataFrame.__eq__:   s   € Ü˜TŸZ™Z¨5¯;©;Ñ6Ó7Ð7r   c                 ó   — | |k(   S r   r#   r1   s     r   Ú__ne__zMockDataFrame.__ne__=   s   € Ø˜5‘=Ð Ð r   c                 óN   — t        | j                  j                  ||¬«      «      S )N©Úaxis)r   r   Útake)r   Úindicesr8   s      r   r9   zMockDataFrame.take@   s   € Ü˜TŸZ™ZŸ_™_¨W¸4˜_Ó@ÓAÐAr   r   )r   )
r   r    r!   r"   r   r,   r/   r3   r5   r9   r#   r   r   r   r       s&   „ ñò/òóò8ò!ô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       	         ó‚   — || _         || _        || _        || _        || _        || _        || _        || _        |	| _        y r   r>   )
r   r?   r@   rA   rB   rC   rD   rE   rF   rG   s
             r   r   zCheckingClassifier.__init__†   sI   € ð ˆŒØ,ˆÔØˆŒØ,ˆÔØ 0ˆÔØ"ˆŒØ&<ˆÔ#Ø#6ˆÔ Ø(ˆÕr   c                 ó¬  — |rt        | «       | j                  �S| j                  €i n| j                  } | j                  |fi |¤Ž}t        |t        t
        j                  f«      r|sJ ‚|}|�c| j                  �W| j                  €i n| j                  } | j                  |fi |¤Ž}t        |t        t
        j                  f«      r|sJ ‚||fS |}||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   rA   rB   Ú
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¸D×<OÑ<OˆFØ$˜Ÿ™ QÑ1¨&Ñ1ˆIÜ˜)¤d¬B¯H©HÐ%5Ô6Ù Ð �yà�Øˆ=˜TŸ\™\Ð5Ø×.Ñ.Ð6‘R¸D×<OÑ<OˆFØ$˜Ÿ™ QÑ1¨&Ñ1ˆIÜ˜)¤d¬B¯H©HÐ%5Ô6Ù Ð �yð �!ˆtˆð �Ø�!ˆtˆr   c                 óª  — t        |«      t        |«      k(  sJ ‚| j                  dk(  sd| j                  v r| j                  ||d¬«      \  }}t        j                  |«      d   | _        t        j                  t        |dd¬«      «      | _        | j                  r‘t        | j                  «      t        |«      z
  }|rt        dt        |«      › d	�«      ‚|j                  «       D ]C  \  }}t        |«      t        |«      k7  sŒt        d
|› dt        |«      › dt        |«      › d�«      ‚ | 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)rP   r   T)Ú	ensure_2dÚallow_ndzExpected fit parameter(s) z
 not seen.zFit parameter z has length z; expected ú.z#Expected sample_weight to be passed)r
   rC   rT   rL   r'   Ún_features_in_Úuniquer   Úclasses_rF   ÚsetÚAssertionErrorÚlistÚitemsrE   r	   )r   rN   rO   Úsample_weightÚ
fit_paramsÚmissingÚkeyÚvalues           r   rV   zCheckingClassifier.fitÂ   sJ  € ô0 ˜A‹¤,¨q£/Ò1Ð1Ð1Ø× Ñ  EÒ)¨U°d×6KÑ6KÑ-KØ—?‘? 1 a¸%�?Ó@‰DˆAˆqÜ Ÿh™h q›k¨!™nˆÔÜŸ	™	¤+¨a¸5È4Ô"PÓQˆŒØ×#Ò#Ü˜$×2Ñ2Ó3´c¸*³oÑEˆGÙÜ$Ø0´°g³°¸zÐJóð ð )×.Ñ.Ó0ò ‘
��UÜ Ó&¬,°q«/Ó9Ü(Ø(¨¨¨\¼,ÀuÓ:MÐ9NØ%¤l°1£oÐ%6°að9óð ðð ×&Ò&ØÐ$Ü$Ð%JÓKÐKÜ  °Ô2àˆr   c                 óÚ   — | j                   dk(  sd| j                   v r| j                  |«      \  }}t        | j                  «      }|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)rC   rT   r   rG   Úchoicer\   r
   ©r   rN   rO   Úrngs       r   rg   zCheckingClassifier.predictò   s\   € ð × Ñ  EÒ)¨Y¸$×:OÑ:OÑ-OØ—?‘? 1Ó%‰DˆAˆqÜ  ×!2Ñ!2Ó3ˆØ�z‰z˜$Ÿ-™-¬l¸1«oˆzÓ>Ð>r   c                 óz  — | j                   dk(  sd| j                   v r| j                  |«      \  }}t        | j                  «      }|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   r7   N)rC   rT   r   rG   Úrandnr
   r+   r\   rL   ÚabsÚsumÚnewaxis)r   rN   rO   rk   Úprobas        r   rm   z CheckingClassifier.predict_proba  s•   € ð  × Ñ  EÒ)¨_À×@UÑ@UÑ-UØ—?‘? 1Ó%‰DˆAˆqÜ  ×!2Ñ!2Ó3ˆØ—	‘	œ, q›/¬3¨t¯}©}Ó+=Ó>ˆÜ—‘�u %Ô(ˆØ”—‘˜ AÔ&¢q¬"¯*©* }Ñ5Ñ5ˆØˆr   c                 óN  — | j                   dk(  sd| j                   v r| j                  |«      \  }}t        | j                  «      }t	        | j
                  «      dk(  r|j                  t        |«      «      S |j                  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   )rC   rT   r   rG   r+   r\   ro   r
   rj   s       r   ru   z$CheckingClassifier.decision_function  s†   € ð ×!Ñ! UÒ*Ø" d×&;Ñ&;Ñ;à—?‘? 1Ó%‰DˆAˆqÜ  ×!2Ñ!2Ó3ˆÜˆt�}‰}Ó Ò"ð —9‘9œ\¨!›_Ó-Ð-à—9‘9œ\¨!›_¬c°$·-±-Ó.@ÓAÐAr   c                 óŽ   — | j                   dk(  sd| j                   v r| j                  ||«       | j                  dkD  rd}|S 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        )rC   rT   rD   )r   rN   ÚYrw   s       r   rw   zCheckingClassifier.score7  sQ   € ð& × Ñ  EÒ)¨W¸×8MÑ8MÑ-MØ�O‰O˜A˜qÔ!Ø�>‰>˜AÒØˆEð ˆð ˆEØˆr   c                 óv   •— 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  s6   ø€ Ü‰wÑ'Ó)ˆØˆŒØ&+ˆ�‰Ô#Ø(,ˆ×ÑÔ%Øˆr   ©NTr   )NN)r   r    r!   r"   r   rT   rV   rg   rm   ru   rw   r{   Ú__classcell__©rƒ   s   @r   r<   r<   D   sV   ø„ ñ?ðH ØØØØØØ#Ø Øô)ó.#óJ.ò`?ò$ò0Bó6÷6ð r   r<   rV   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.
    c                 ó   — || _         y r   )Úest)r   r�   s     r   r   zNoSampleWeightWrapper.__init__k  s	   € Øˆ�r   c                 ó:   — | j                   j                  ||«      S r   )r�   rV   ©r   rN   rO   s      r   rV   zNoSampleWeightWrapper.fitn  s   € Ø�x‰x�|‰|˜A˜qÓ!Ð!r   c                 ó8   — | j                   j                  |«      S r   )r�   rg   ©r   rN   s     r   rg   zNoSampleWeightWrapper.predictq  s   € Ø�x‰x×Ñ Ó"Ð"r   c                 ó8   — | j                   j                  |«      S r   )r�   rm   r‘   s     r   rm   z#NoSampleWeightWrapper.predict_probat  s   € Ø�x‰x×%Ñ% aÓ(Ð(r   c                 ó2   •— t         ‰| �  «       }d|_        |S r„   )rz   r{   r|   r�   s     €r   r{   z&NoSampleWeightWrapper.__sklearn_tags__w  s   ø€ Ü‰wÑ'Ó)ˆØˆŒØˆr   r   )
r   r    r!   r"   r   rV   rg   rm   r{   r…   r†   s   @r   r‹   r‹   b  s&   ø„ ñóò"ò#ò)÷ð r   r‹   c                 ó   ‡ — ˆ fd„}|S )Nc                 ó@   •— | j                   d uxr ‰| j                   v S r   ©Úresponse_methods)r   Úmethods    €r   Úcheckz_check_response.<locals>.check~  s$   ø€ Ø×$Ñ$¨DÐ0ÒT°V¸t×?TÑ?TÐ5TÐTr   r#   )r˜   r™   s   ` r   Ú_check_responserš   }  s   ø€ ô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
y)Ú_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                 ó   — || _         y r   r–   )r   r—   s     r   r   z&_MockEstimatorOnOffPrediction.__init__’  s
   € Ø 0ˆÕr   c                 ó:   — t        j                  |«      | _        | S r   )rL   r[   r\   r�   s      r   rV   z!_MockEstimatorOnOffPrediction.fit•  s   € ÜŸ	™	 !›ˆŒØˆr   rg   c                  ó   — y)Nrg   r#   r‘   s     r   rg   z%_MockEstimatorOnOffPrediction.predict™  s   € àr   rm   c                  ó   — y)Nrm   r#   r‘   s     r   rm   z+_MockEstimatorOnOffPrediction.predict_proba�  s   € àr   ru   c                  ó   — y)Nru   r#   r‘   s     r   ru   z/_MockEstimatorOnOffPrediction.decision_function¡  s   € à"r   r   )r   r    r!   r"   r   rV   r   rš   rg   rm   ru   r#   r   r   rœ   rœ   „  sl   „ ñó1òñ ‘/ )Ó,Ó-ñó .ðñ ‘/ /Ó2Ó3ñó 4ðñ ‘/Ð"5Ó6Ó7ñ#ó 8ñ#r   rœ   )ÚnumpyrL   Úbaser   r   Úutils._metadata_requestsr   Úmetaestimatorsr   Ú
validationr	   r
   r   r   r   r   r   r<   Úset_fit_requestr‹   rš   rœ   r#   r   r   ú<module>r¨      sy   ðó ç 1Ý 4Ý (÷õ ÷1ñ 1÷!Bñ !BôHS˜¨-ô Sñr &3Ø	�R uô&Ð Ô "ô
˜Mô ò6ô# Mõ #r   