
    -i]5                         S SK rSSKJrJr  SSKJr  SSKJr  SSK	J
r
JrJrJrJr   " S S	5      r " S
 S5      r " S S\\5      r\" S/ SS9\l         " S S\5      rS r " S S\5      rg)    N   )BaseEstimatorClassifierMixin)RequestMethod   )available_if)_check_sample_weight_num_samplescheck_arraycheck_is_fittedcheck_random_statec                   $    \ rS rSrSrS rS rSrg)ArraySlicingWrapper   
Parameters
----------
array
c                     Xl         g Narrayselfr   s     I/var/www/html/venv/lib/python3.13/site-packages/sklearn/utils/_mocking.py__init__ArraySlicingWrapper.__init__   s    
    c                 2    [        U R                  U   5      $ r   MockDataFramer   )r   aslices     r   __getitem__ArraySlicingWrapper.__getitem__   s    TZZ/00r   r   N)__name__
__module____qualname____firstlineno____doc__r   r    __static_attributes__ r   r   r   r      s    1r   r   c                   D    \ rS rSrSrS rS rSS jrS rS r	SS	 jr
S
rg)r       r   c                     Xl         Xl        UR                  U l        UR                  U l        [	        U5      U l        g r   )r   valuesshapendimr   ilocr   s     r   r   MockDataFrame.__init__)   s.    
[[
JJ	'.	r   c                 ,    [        U R                  5      $ r   )lenr   )r   s    r   __len__MockDataFrame.__len__1   s    4::r   Nc                     U R                   $ r   r   )r   dtypes     r   	__array__MockDataFrame.__array__4   s     zzr   c                 F    [        U R                  UR                  :H  5      $ r   r   r   others     r   __eq__MockDataFrame.__eq__:   s    TZZ5;;677r   c                     X:X  + $ r   r(   r:   s     r   __ne__MockDataFrame.__ne__=   s      r   c                 F    [        U R                  R                  XS95      $ )Naxis)r   r   take)r   indicesrC   s      r   rD   MockDataFrame.take@   s    TZZ__W_@AAr   )r   r/   r.   r-   r,   r   )r   )r"   r#   r$   r%   r&   r   r3   r7   r<   r?   rD   r'   r(   r   r   r   r       s&    /8!Br   r   c            
       z   ^  \ rS rSrSrSSSSSSSSSS.	S jrSS jrSS	 jrS
 rS r	S r
SS jrU 4S jrSrU =r$ )CheckingClassifierD   ad  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       	         p    Xl         X l        X0l        X@l        XPl        X`l        Xpl        Xl        Xl        g r   rK   )
r   rL   rM   rN   rO   rP   rQ   rR   rS   rT   s
             r   r   CheckingClassifier.__init__   s7     ,, 0"&<##6 (r   c                    U(       a  [        U 5        U R                  b_  U R                  c  0 OU R                  nU R                  " U40 UD6n[        U[        [
        R                  45      (       a
  U(       d   eOUnUbo  U R                  bb  U R                  c  0 OU R                  nU R                  " U40 UD6n[        U[        [
        R                  45      (       a  U(       d   e X4$ UnX4$ )a  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   rN   rO   
isinstanceboolnpbool_rL   rM   )r   Xyshould_be_fittedparams	checked_X	checked_ys          r   
_check_X_yCheckingClassifier._check_X_y   s    & D!<<#..6RD<O<OFQ1&1I)dBHH%566  y=T\\5..6RD<O<OFQ1&1I)dBHH%566  y t tr   c                    [        U5      [        U5      :X  d   eU R                  S:X  d  SU R                  ;   a  U R                  XSS9u  p[        R                  " U5      S   U l        [        R                  " [        USSS95      U l        U R                  (       a  [        U R                  5      [        U5      -
  nU(       a  [        S[        U5       S	35      eUR                  5        HD  u  pg[        U5      [        U5      :w  d  M  [        S
U S[        U5       S[        U5       S35      e   U R                  (       a  Uc  [        S5      e[        X15        U $ )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
rJ   fitF)r^   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
   rP   rb   rZ   r-   n_features_in_uniquer   classes_rS   setAssertionErrorlistitemsrR   r	   )r   r\   r]   sample_weight
fit_paramsmissingkeyvalues           r   re   CheckingClassifier.fit   s=   0 A,q/111  E)Ud6K6K-K??1%?@DA hhqk!n		+a54"PQ##$223c*oEG$0gzJ  )..0
&,q/9((\,u:M9N%l1o%6a9  1 &&$$%JKK 2r   c                     U R                   S:X  d  SU R                   ;   a  U R                  U5      u  p[        U R                  5      nUR	                  U R
                  [        U5      S9$ )zPredict 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_`.
rJ   predict)size)rP   rb   r   rT   choicerk   r
   r   r\   r]   rngs       r   rw   CheckingClassifier.predict   sZ       E)Y$:O:O-O??1%DA !2!23zz$--l1oz>>r   c                 t   U R                   S:X  d  SU R                   ;   a  U R                  U5      u  p[        U R                  5      nUR	                  [        U5      [        U R                  5      5      n[        R                  " XDS9nU[        R                  " USS9SS2[        R                  4   -  nU$ )ab  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.
rJ   predict_proba)outr   rB   N)rP   rb   r   rT   randnr
   r2   rk   rZ   abssumnewaxis)r   r\   r]   r{   probas        r   r~    CheckingClassifier.predict_proba  s        E)_@U@U-U??1%DA !2!23		,q/3t}}+=>u(A&q"**}55r   c                 T   U R                   S:X  d  SU R                   ;   a  U R                  U5      u  p[        U R                  5      n[	        U R
                  5      S:X  a  UR                  [        U5      5      $ UR                  [        U5      [	        U R
                  5      5      $ )zConfidence 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.
rJ   decision_functionr   )rP   rb   r   rT   r2   rk   r   r
   rz   s       r   r   $CheckingClassifier.decision_function  s     !!U*"d&;&;;??1%DA !2!23t}}" 99\!_--99\!_c$--.@AAr   c                     U R                   S:X  d  SU R                   ;   a  U R                  X5        U R                  S:  a  SnU$ SnU$ )a  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`).
rJ   scorer   g      ?g        )rP   rb   rQ   )r   r\   Yr   s       r   r   CheckingClassifier.score7  sO    &   E)W8M8M-MOOA!>>AE  Er   c                 v   > [         TU ]  5       nSUl        SUR                  l        SUR
                  l        U$ )NTF)super__sklearn_tags__
_skip_test
input_tagstwo_d_arraytarget_tagsone_d_labelsr   tags	__class__s     r   r   #CheckingClassifier.__sklearn_tags__R  s6    w')&+#(,%r   )rN   rO   rL   rM   rk   rS   rR   rQ   rP   ri   rT   NTr   )NN)r"   r#   r$   r%   r&   r   rb   re   rw   r~   r   r   r   r'   __classcell__r   s   @r   rH   rH   D   sV    ?H # ).#J.`?$0B66 r   rH   re   F)namekeysvalidate_keysc                   H   ^  \ rS rSrSrS	S jrS rS rS rU 4S jr	Sr
U =r$ )
NoSampleWeightWrapperib  zWrap estimator which will not expose `sample_weight`.

Parameters
----------
est : estimator, default=None
    The estimator to wrap.
c                     Xl         g r   est)r   r   s     r   r   NoSampleWeightWrapper.__init__k  s    r   c                 8    U R                   R                  X5      $ r   )r   re   r   r\   r]   s      r   re   NoSampleWeightWrapper.fitn  s    xx||A!!r   c                 8    U R                   R                  U5      $ r   )r   rw   r   r\   s     r   rw   NoSampleWeightWrapper.predictq  s    xx""r   c                 8    U R                   R                  U5      $ r   )r   r~   r   s     r   r~   #NoSampleWeightWrapper.predict_probat  s    xx%%a((r   c                 2   > [         TU ]  5       nSUl        U$ r   )r   r   r   r   s     r   r   &NoSampleWeightWrapper.__sklearn_tags__w  s    w')r   r   r   )r"   r#   r$   r%   r&   r   re   rw   r~   r   r'   r   r   s   @r   r   r   b  s&    "#) r   r   c                    ^  U 4S jnU$ )Nc                 L   > U R                   S L=(       a    TU R                   ;   $ r   response_methods)r   methods    r   check_check_response.<locals>.check~  s$    $$D0TVt?T?T5TTr   r(   )r   r   s   ` r   _check_responser   }  s    U Lr   c                       \ rS rSrSrSS jrS r\" \" S5      5      S 5       r	\" \" S5      5      S	 5       r
\" \" S
5      5      S 5       rSrg)_MockEstimatorOnOffPredictioni  a  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                     Xl         g r   r   )r   r   s     r   r   &_MockEstimatorOnOffPrediction.__init__  s     0r   c                 <    [         R                  " U5      U l        U $ r   )rZ   rj   rk   r   s      r   re   !_MockEstimatorOnOffPrediction.fit  s    		!r   rw   c                     g)Nrw   r(   r   s     r   rw   %_MockEstimatorOnOffPrediction.predict  s    r   r~   c                     g)Nr~   r(   r   s     r   r~   +_MockEstimatorOnOffPrediction.predict_proba  s    r   r   c                     g)Nr   r(   r   s     r   r   /_MockEstimatorOnOffPrediction.decision_function  s    "r   )rk   r   r   )r"   r#   r$   r%   r&   r   re   r   r   rw   r~   r   r'   r(   r   r   r   r     sl    1 /),- . //23 4 /"567# 8#r   r   )numpyrZ   baser   r   utils._metadata_requestsr   metaestimatorsr   
validationr	   r
   r   r   r   r   r   rH   set_fit_requestr   r   r   r(   r   r   <module>r      sy     1 4 ( 1 1!B !BHS- Sr &3	Ru&  "
M 6#M #r   