
    -i
<                         S SK r S SKJr  S SKrSSKJr  SSKJr  SSK	J
r
  SSKJr  SSKJr  SS	KJrJr   " S
 S5      rS rS rS rS rS rS rS rg)    N)Mapping   )check_consistent_length)check_matplotlib_support)_get_response_values_binary)parse_version)type_of_target)_check_pos_label_consistency_num_samplesc                       \ rS rSrSrSSS.S jr\SSSS.S j5       r\SSSS	.S
 j5       r\S 5       r	\
S 5       r\
S 5       rSrg)"_BinaryClassifierCurveDisplayMixin   zMixin class to be used in Displays requiring a binary classifier.

The aim of this class is to centralize some validations regarding the estimator and
the target and gather the response of the estimator.
N)axnamec          	          [        U R                  R                   S35        SS KJn  Uc  UR                  5       u  pAUc  [        U S[        U SS 5      5      nXR                  U4$ )Nz.plotr   estimator_namer   )r   	__class____name__matplotlib.pyplotpyplotsubplotsgetattrfigure)selfr   r   plt_s        J/var/www/html/venv/lib/python3.13/site-packages/sklearn/utils/_plotting.py_validate_plot_params8_BinaryClassifierCurveDisplayMixin._validate_plot_params   s_     DNN$;$;#<E!BC':LLNEA <4!1743NOD99d""    auto)response_method	pos_labelr   c                    [        U R                   S35        Uc  UR                  R                  OUn[        UUUUS9u  puXuU4$ )Nz.from_estimator)r"   r#   )r   r   r   r   )cls	estimatorXyr"   r#   r   y_preds           r   !_validate_and_get_response_valuesD_BinaryClassifierCurveDisplayMixin._validate_and_get_response_values$   sT     	!CLL>!AB/3|y""++7+	
 $&&r    )sample_weightr#   r   c                    [        U R                   S35        [        U5      S:w  a  [        S[        U5       S35      e[	        XU5        [        XA5      nUb  UOSnXE4$ )Nz.from_predictionsbinaryz The target y is not binary. Got  type of target.
Classifier)r   r   r	   
ValueErrorr   r
   )r%   y_truer)   r,   r#   r   s         r   !_validate_from_predictions_paramsD_BinaryClassifierCurveDisplayMixin._validate_from_predictions_params5   st     	!CLL>1B!CD&!X-2>&3I2J K  
 	 >0C	't\r    c                &  ^ [        U R                   S35        SS1n[        U4S jU 5       5      (       d  [        SU S35      e[	        TS   S   S   5      [	        TS   S	   S   5      p[        U5      Xx-   :w  a  [        S
Xx-    S[        U5       S35      e[        U5      S:w  a  [        S[        U5       S35      e[        X#U5         [        XS5      nU$ ! [         a)  n	[        [        U	5      R                  SS5      5      eS n	A	ff = f)Nz.from_cv_resultsr&   indicesc              3   ,   >#    U  H	  oT;   v   M     g 7f)N ).0key
cv_resultss     r   	<genexpr>V_BinaryClassifierCurveDisplayMixin._validate_from_cv_results_params.<locals>.<genexpr>U   s     >*$s   zB`cv_results` does not contain one of the following required keys: zr. Set explicitly the parameters `return_estimator=True` and `return_indices=True` to the function`cross_validate`.trainr   testz=`X` does not contain the correct number of samples. Expected z, got .r.   z"The target `y` is not binary. Got r/   r2   r(   )r   r   allr1   lenr   r	   r   r
   strreplace)
r%   r;   r'   r(   r,   r#   required_keys
train_size	test_sizees
    `        r    _validate_from_cv_results_paramsC_BinaryClassifierCurveDisplayMixin._validate_from_cv_results_paramsH   sE    	!CLL>1A!BC$i0>>>>T / "$$  
9%g.q12
9%f-a01 
 ?j44&236,q/9J!M 
 !(4^A5F4GGWX  	 m4	<4YBI
 	  	<SV^^Hc:;;	<s   C 
D'$DDc                 Z    U b  Ub  U SU SU S S3nU$ U b
  U SU S 3nU$ Ub  UnU$ SnU$ )z;Helper to get legend label using `name` and `legend_metric`Nz (z = 0.2f)r8   )curve_legend_metric
curve_namelegend_metric_namelabels       r   _get_legend_label4_BinaryClassifierCurveDisplayMixin._get_legend_labelv   sz     *z/E!l"%7$8<OPT;UUVWE  !,)*#.A$-GHE
 	 #E  Er    c           	      0   U(       a  U(       a  [        S5      eU(       a  [        R                  " S[        5        Un[	        U[
        5      (       a!  [        U5      U :w  a  [        SU  SU S35      e[	        U[
        5      (       a3  [        U5      S:w  a$  [	        U[
        5      (       d  [        SU  S35      e[	        U[        5      (       a  U/n[	        U[
        5      (       a  [        U5      S:X  a  X-  nUc  S	/U -  OUn[	        U[        5      (       a  U/U -  nS
SSS.nUc  U S:  a  U/U -  nO0 /n/ nSU;   ac  [        R                  US   US   U5      nUS   b#  US   b  US	S SUS   S S3-   nOUSUS   S 3-   nUR                  U/S	/U S-
  -  -   5        O=[        US   U5       H*  u  pUR                  [        R                  XU5      5        M,     [        U5       VVs/ s H  u  p[        SU0XK   5      PM     nnnU$ s  snnf )aB  Get validated line kwargs for each curve.

Parameters
----------
n_curves : int
    Number of curves.

name : list of str or None
    Name for labeling legend entries.

legend_metric : dict
    Dictionary with "mean" and "std" keys, or "metric" key of metric
    values for each curve. If None, "label" will not contain metric values.

legend_metric_name : str
    Name of the summary value provided in `legend_metrics`.

curve_kwargs : dict or list of dict or None
    Dictionary with keywords passed to the matplotlib's `plot` function
    to draw the individual curves. If a list is provided, the
    parameters are applied to the curves sequentially. If a single
    dictionary is provided, the same parameters are applied to all
    curves.

**kwargs : dict
    Deprecated. Keyword arguments to be passed to matplotlib's `plot`.
zCannot provide both `curve_kwargs` and `kwargs`. `**kwargs` is deprecated in 1.7 and will be removed in 1.9. Pass all matplotlib arguments to `curve_kwargs` as a dictionary.z}`**kwargs` is deprecated and will be removed in 1.9. Pass all matplotlib arguments to `curve_kwargs` as a dictionary instead.z>`curve_kwargs` must be None, a dictionary or a list of length z. Got: r@   r   zfTo avoid labeling individual curves that have the same appearance, `curve_kwargs` should be a list of z dictionaries. Alternatively, set `name` to `None` or a single string to label a single legend entry with mean ROC AUC score of all curves.Ng      ?z--blue)alpha	linestylecolormeanr   stdz +/- rL   rM   metricrQ   )r1   warningswarnFutureWarning
isinstancelistrB   rC   r   r   rR   extendzipappend	enumerate_validate_style_kwargs)n_curvesr   legend_metricrP   curve_kwargskwargsdefault_multi_curve_kwargslabelslabel_aggregaterN   rO   fold_idxrQ   curve_kwargs_s                 r   _validate_curve_kwargs9_BinaryClassifierCurveDisplayMixin._validate_curve_kwargs   s~   J F? 
 MMR
 "LlD))c,.?8.KP*GL>4  tT""D	Q|T2266>Z @OO  dC  6DdD!!c$i1n?D$(Lv d lG,,(>H4L/2PV%W"!| :;hF "t]"@RRf%tAw0BO
 U#/7&',}U7KD6QQR/SS $
 (E-2Ft1L*MM $ MM?+tf1.EEF36}X7NPT3U/#6HH+9K 4V $-V#4
#4 #GU#3\5KL#4 	 
 	
s   1Hr8   )r   
__module____qualname____firstlineno____doc__r   classmethodr*   r3   rI   staticmethodrR   rp   __static_attributes__r8   r    r   r   r      s     +/T # 174d' '  .2d $ + +Z 
 
 v vr    r   c                 6   U b  U $ Uc  U(       a  S$ S$ [        U5      (       a  UR                  OUn U(       a"  U R                  S5      (       a  U SS n O$SU  3n OU R                  S5      (       a  SU SS  3n U R                  SS5      n U R	                  5       $ )	a  Validate the `score_name` parameter.

If `score_name` is provided, we just return it as-is.
If `score_name` is `None`, we use `Score` if `negate_score` is `False` and
`Negative score` otherwise.
If `score_name` is a string or a callable, we infer the name. We replace `_` by
spaces and capitalize the first letter. We remove `neg_` and replace it by
`"Negative"` if `negate_score` is `False` or just remove it otherwise.
NzNegative scoreScoreneg_   z	Negative r    )callabler   
startswithrD   
capitalize)
score_namescoringnegate_scores      r   _validate_score_namer      s     	#/<W<)1'):):W%%
$$V,,'^
(5
""6**$Z^$45J''S1
$$&&r    c                     [         R                  " [         R                  " U 5      5      nUR                  5       UR	                  5       -  $ )zCompute the ratio between the largest and smallest inter-point distances.

A value larger than 5 typically indicates that the parameter range would
better be displayed with a log scale while a linear scale would be more
suitable otherwise.
)npdiffsortmaxmin)datar   s     r   _interval_max_min_ratior     s1     772774=!D88:
""r    c                 j   0 SS_SS_SS_SS_S	S
_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS _S!S"_S#S$S%S&S'S(S).EnUR                  5        H#  u  p4X1;   d  M  XA;   d  M  [        S*U S+U S,35      e   U R                  5       nUR                  5        H  nXb;   a  X   XRU   '   M  X   XV'   M     U$ )-a  Create valid style kwargs by avoiding Matplotlib alias errors.

Matplotlib raises an error when, for example, 'color' and 'c', or 'linestyle' and
'ls', are specified together. To avoid this, we automatically keep only the one
specified by the user and raise an error if the user specifies both.

Parameters
----------
default_style_kwargs : dict
    The Matplotlib style kwargs used by default in the scikit-learn display.
user_style_kwargs : dict
    The user-defined Matplotlib style kwargs.

Returns
-------
valid_style_kwargs : dict
    The validated style kwargs taking into account both default and user-defined
    Matplotlib style kwargs.
lsrW   crX   ec	edgecolorfc	facecolorlw	linewidthmecmarkeredgecolormfcaltmarkerfacecoloraltms
markersizemewmarkeredgewidthmfcmarkerfacecoloraaantialiasedds	drawstylefontfontpropertiesfamily
fontfamilyr   fontnamesizefontsizestretchfontstretch	fontstylefontvariant
fontweighthorizontalalignmentverticalalignmentmultialignment)stylevariantweighthavamaz	Got both  and z", which are aliases of one another)items	TypeErrorcopykeys)default_style_kwargsuser_style_kwargsinvalid_to_valid_kwinvalid_key	valid_keyvalid_style_kwargsr:   s          r   rf   rf   #  s   *kW 	k 	k	
 	k 	  	& 	l 	  	  	m 	k 	  	, 	
  	
!" 	=#$  #!/2 #6";";"=+	0NK=i[ 9   #> .224 %%'%;L;Q378&7&<#	 ( r    c                     S H!  nU R                   U   R                  S5        M#     S H"  nU R                   U   R                  SS5        M$     g)zRemove the top and right spines of the plot.

Parameters
----------
ax : matplotlib.axes.Axes
    The axes of the plot to despine.
)toprightF)bottomleftr   r   N)spinesset_visible
set_bounds)r   ss     r   _despiner   b  sF     
		!  ' 
		!1%  r    c                     [        U5      nUR                   SUR                  S-    3nU S:w  a=  U(       a  [        SU SU S35      e[        R
                  " SU SU S3[        5        U $ U$ )	z/Deprecate `estimator_name` in favour of `name`.r@      
deprecatedzSCannot provide both `estimator_name` and `name`. `estimator_name` is deprecated in z and will be removed in z. Use `name` only.z"`estimator_name` is deprecated in z. Use `name` instead.)r   majorminorr1   r]   r^   r_   )r   r   versionversion_removes       r   _deprecate_estimator_namer   p  s    G$Ga(9':;N%$$+9,D^DT U## 
 	0	9Q35	

 Kr    c                 >    U c  g[        U [        5      (       a  U $ U /$ )z3Convert parameters to a list, leaving `None` as is.N)r`   ra   )params    r   _convert_to_list_leaving_noner     s#    }%7Nr    c           	         0 nUR                  5        H   u  pE[        U[        5      (       d  M  XSU'   M"     0 U EUEn[        UR	                  5        Vs1 s H  n[        U5      iM     sn5      S:  a  UR                  5        Vs/ s H  owPM     nnSR                  SR                  USS 5      US   /5      n	Sn
SU;   a  Sn
SR                  S	 UR                  5        5       5      n[        U	 S
U SU
 SU 35      egs  snf s  snf )z>Check required and optional parameters are of the same length.r   r   z, Nr[    z'name' (or self.name)z (or `plot`)c              3   F   #    U  H  u  pU S [        U5       3v   M     g7f)z: N)rB   )r9   r:   values      r   r<   '_check_param_lengths.<locals>.<genexpr>  s%      &
5Gzsse2c%j\"5Gs   !z from `z` initializationz/, should all be lists of the same length. Got: )r   r`   ra   rB   valuesr   joinr1   )requiredoptional
class_nameoptional_providedr   r   
all_paramsr:   
param_keysparams_formattedor_plotlengths_formatteds               r   _check_param_lengthsr     s*   ~~'eT""&+d# ( 3H2 12J
J$5$5$78$75CJ$789A=%/__%67%6cc%6
7 #<<:cr?)CZPR^(TU"j0$G II &
5?5E5E5G&
 
  
|3CG9 M<<M;NP
 	
 >87s   DD)r]   collections.abcr   numpyr   r   r   _optional_dependenciesr   	_responser   fixesr   
multiclassr	   
validationr
   r   r   r   r   rf   r   r   r   r   r8   r    r   <module>r      sS     #  % < 2   & Bj jZ'6#<~&(
r    