
    -iH                        S SK rS SKrS SKJr  S SKJrJrJrJ	r	  S SK
Jr  S SKJr  S SKJrJr  \R"                  S 5       r\R&                  R)                  SS	S
0\S4SS
0\S4/5      \R&                  R)                  S\S/ SQS.4\S/ SQ04/5      S 5       5       rS rS r\R&                  R)                  S\S/ SQS.4\S/ SQ04/5      S 5       r\R&                  R)                  SSS/5      \R&                  R)                  S\S/ SQS.4\S/ SQ04/5      S 5       5       r\R&                  R)                  S	S5      S 5       r\R&                  R)                  S	S5      S 5       r\R&                  R)                  S\S\R:                  " S S!5      S.S"4\S\R<                  " S#S$S!S%90S"4\S\R>                  " \R@                  " S S&S!S%95      RC                  \RD                  5      S.S'4\S\R@                  " S(S S!S%90S'4/5      S) 5       r#\R&                  R)                  S\S/ SQS.4\S/ SQ04/5      S* 5       r$\R&                  R)                  S\S/ SQS.4\S/ SQ04/5      S+ 5       r%\R&                  R)                  S,/ S-QS"4/ S.QS/4/ S0QS'4/5      S1 5       r&\R&                  R)                  S2\0 4\S/ SQS.4/5      S3 5       r'g)4    N)	load_iris)LearningCurveDisplayValidationCurveDisplaylearning_curvevalidation_curve)DecisionTreeClassifier)shuffle)assert_allcloseassert_array_equalc                  &    [        [        SS9SS06$ )NT)
return_X_yrandom_stater   )r	   r        Z/var/www/html/venv/lib/python3.13/site-packages/sklearn/model_selection/tests/test_plot.pydatar      s    I.?Q??r   zparams, err_type, err_msgstd_display_styleinvalidzUnknown std_display_style:
score_typezUnknown score_type:zCurveDisplay, specific_params	max_depth         
param_nameparam_rangetrain_sizesg333333?g333333??c                     Uu  px[        SS9n	[        R                  " X4S9   UR                  " XU40 UDUD6  SSS5        g! , (       d  f       g= f)zCCheck that we raise a proper error when passing invalid parameters.r   r   )matchN)r   pytestraisesfrom_estimator)
pyplotr   paramserr_typeerr_msgCurveDisplayspecific_paramsXy	estimators
             r   (test_curve_display_parameters_validationr0      sG    $ DA&A6I	x	/##I!QQ&Q 
0	/	/s   A
Ac                    Uu  p#[        SS9n/ SQn[        R                  " XBX5S9nSSKnUR                  b   e[        UR                  [        5      (       d   eUR                   H)  n[        XR                  R                  5      (       a  M)   e   [        UR                  [        5      (       d   eUR                   H?  n	[        XR                  R                  5      (       d   eU	R                  5       S:X  a  M?   e   UR                  S:X  d   eUR                  R!                  5       S:X  d   eUR                  R#                  5       S:X  d   eUR                  R%                  5       u  pUS	S
/:X  d   e['        XBX5S9u  pn[)        UR*                  U5        [-        UR.                  U5        [-        UR0                  U5        g)z:Check the default usage of the LearningCurveDisplay class.r   r"   r   r   N      ?Scorez%Number of samples in the training setTrainTest)r   r   r&   
matplotlib	errorbar_
isinstancelines_listlinesLine2Dfill_between_collectionsPolyCollection	get_alpha
score_nameax_
get_xlabel
get_ylabelget_legend_handles_labelsr   r   r   r
   train_scorestest_scores)r'   r   r-   r.   r/   r   displaympllinefill_legend_labelstrain_sizes_absrG   rH   s                  r   )test_learning_curve_display_default_usagerP   .   s   DA&A6I!K"11aG $$$gnnd++++$		 0 01111  g++T2222%%$ > >????~~3&&& & (((;;!!#'NNNN;;!!#w...{{<<>AWf----1?a2.O; w**O<G((,7G''5r   c                    Uu  p#[        SS9nS/ SQpe[        R                  " XBX5US9nSSKnUR                  b   e[        UR                  [        5      (       d   eUR                   H)  n	[        XR                  R                  5      (       a  M)   e   [        UR                  [        5      (       d   eUR                   H?  n
[        XR                  R                  5      (       d   eU
R                  5       S:X  a  M?   e   UR                  S:X  d   eUR                  R!                  5       U :X  d   eUR                  R#                  5       S:X  d   eUR                  R%                  5       u  pUS	S
/:X  d   e['        XBX5US9u  p[)        UR*                  U5        [-        UR.                  U5        [-        UR0                  U5        g)z<Check the default usage of the ValidationCurveDisplay class.r   r"   r   r   r   Nr3   r4   r5   r6   )r   r   r&   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   r   r   r   r
   rG   rH   )r'   r   r-   r.   r/   r   r   rI   rJ   rK   rL   rM   rN   rG   rH   s                  r   +test_validation_curve_display_default_usagerR   U   s   DA&A6I)9$33aKG $$$gnnd++++$		 0 01111  g++T2222%%$ > >????~~3&&& & (((;;!!#*666;;!!#w...{{<<>AWf---- 0aK!L w**K8G((,7G''5r   c                 T   Uu  pE[        SSS9nSnUR                  " XdU40 UDSU0D6nUR                  S   R                  5       S   n	U	S:  R	                  5       (       d   eUR
                  R                  5       S:X  d   eSnUR                  " XdU40 UDSU0D6nUR                  S   R                  5       S   n
U
S:*  R	                  5       (       d   e[        X* 5        UR
                  R                  5       S:X  d   eSnUR                  " XdU40 UDSU0D6nUR
                  R                  5       S:X  d   eUR                  U(       + S	9  UR
                  R                  5       S:X  d   eUR                  S   R                  5       S   S:  R	                  5       (       d   eg
)zYCheck the behaviour of the `negate_score` parameter calling `from_estimator` and
`plot`.
r   r   r   r   Fnegate_scorer4   TzNegative score)rU   N)	r   r&   r:   get_dataallrC   rE   r
   plot)r'   r   r+   r,   r-   r.   r/   rU   rI   positive_scoresnegative_scoress              r   test_curve_display_negate_scorer[   |   s    DA&CIL))a*9EG nnQ'00215Oq %%'''';;!!#w...L))a*9EG nnQ'00215Oq %%''''O%56;;!!#'7777L))a*9EG ;;!!#w...LL,.L/;;!!#w...NN1&&(+a/446666r   zscore_name, ylabel)Nr4   )Accuracyr\   c                     Uu  pg[        SS9nUR                  " XU40 UDSU0D6n	U	R                  R                  5       U:X  d   eUu  pg[        SSS9nUR                  " XU40 UDSU0D6n	U	R                  U:X  d   eg)zGCheck that we can overwrite the default score name shown on the y-axis.r   r"   rB   r   rT   N)r   r&   rC   rE   rB   )
r'   r   rB   ylabelr+   r,   r-   r.   r/   rI   s
             r   test_curve_display_score_namer_      s     DA&A6I))a*7AG ;;!!#v---DA&CI))a*7AG '''r   )Nerrorbarc           	      R   Uu  p4[        SS9n/ SQn[        XSXFS9u  pxn	Sn
[        R                  " UUUUU
US9nUR                  R                  5       u  pUS/:X  d   eUcJ  [        UR                  5      S	:X  d   eUR                  b   eUR                  S   R                  5       u  pOVUR                  b   e[        UR                  5      S	:X  d   eUR                  S   R                  S   R                  5       u  p[        X5        [        XR                  S	S
95        Sn
[        R                  " UUUUU
US9nUR                  R                  5       u  pUS/:X  d   eUcJ  [        UR                  5      S	:X  d   eUR                  b   eUR                  S   R                  5       u  pOVUR                  b   e[        UR                  5      S	:X  d   eUR                  S   R                  S   R                  5       u  p[        X5        [        XR                  S	S
95        Sn
[        R                  " UUUUU
US9nUR                  R                  5       u  pUSS/:X  d   eUck  [        UR                  5      S:X  d   eUR                  b   eUR                  S   R                  5       u  nnUR                  S	   R                  5       u  nnOUR                  b   e[        UR                  5      S:X  d   eUR                  S   R                  S   R                  5       u  nnUR                  S	   R                  S   R                  5       u  nn[        UU5        [        UUR                  S	S
95        [        UU5        [        UU	R                  S	S
95        g):Check the behaviour of setting the `score_type` parameter.r   r"   r   r2   train)r   r   r   r5   Nr   axistestr6   both   )r   r   r   r&   rC   rF   lenr:   r8   rV   r<   r   r
   mean)r'   r   r   r-   r.   r/   r   rO   rG   rH   r   rI   rM   legend_labelx_datay_datax_data_trainy_data_trainx_data_testy_data_tests                       r   &test_learning_curve_display_score_typerr      s    DA&A6I!K1?a2.O; J"11		+G kk;;=OAG9$$$ 7>>"a'''  ((( *335~~%%%7$$%*** **1-33A6??Av/F--1-56J"11		+G kk;;=OAF8### 7>>"a'''  ((( *335~~%%%7$$%*** **1-33A6??Av/F,,!,45J"11		+G kk;;=OAGV,,,, 7>>"a'''  (((%,^^A%6%?%?%A"l#*>>!#4#=#=#? [~~%%%7$$%***%,%6%6q%9%?%?%B%K%K%M"l#*#4#4Q#7#=#=a#@#I#I#K [|_5L,"3"3"3";<{O4K!1!1q!1!9:r   c           
      Z   Uu  p4[        SS9nS/ SQpv[        XSXFUS9u  pSn
[        R                  " UUUUUU
US9nUR                  R                  5       u  pUS/:X  d   eUcJ  [        UR                  5      S
:X  d   eUR                  b   eUR                  S   R                  5       u  pOVUR                  b   e[        UR                  5      S
:X  d   eUR                  S   R                  S   R                  5       u  p[        X5        [        XR                  S
S95        Sn
[        R                  " UUUUUU
US9nUR                  R                  5       u  pUS/:X  d   eUcJ  [        UR                  5      S
:X  d   eUR                  b   eUR                  S   R                  5       u  pOVUR                  b   e[        UR                  5      S
:X  d   eUR                  S   R                  S   R                  5       u  p[        X5        [        XR                  S
S95        Sn
[        R                  " UUUUUU
US9nUR                  R                  5       u  pUSS/:X  d   eUck  [        UR                  5      S:X  d   eUR                  b   eUR                  S   R                  5       u  nnUR                  S
   R                  5       u  nnOUR                  b   e[        UR                  5      S:X  d   eUR                  S   R                  S   R                  5       u  nnUR                  S
   R                  S   R                  5       u  nn[        UU5        [        UUR                  S
S95        [        UU5        [        UU	R                  S
S95        g	)rb   r   r"   r   r   r   rc   )r   r   r   r   r5   Nr   rd   rf   r6   rg   rh   )r   r   r   r&   rC   rF   ri   r:   r8   rV   r<   r   r
   rj   )r'   r   r   r-   r.   r/   r   r   rG   rH   r   rI   rM   rk   rl   rm   rn   ro   rp   rq   s                       r   (test_validation_curve_display_score_typert   "  s    DA&A6I)9 0aK!L J$33		+G kk;;=OAG9$$$ 7>>"a'''  ((( *335~~%%%7$$%*** **1-33A6??Av+F--1-56J$33		+G kk;;=OAF8### 7>>"a'''  ((( *335~~%%%7$$%*** **1-33A6??Av+F,,!,45J$33		+G kk;;=OAGV,,,, 7>>"a'''  (((%,^^A%6%?%?%A"l#*>>!#4#=#=#? [~~%%%7$$%***%,%6%6q%9%?%?%B%K%K%M"l#*#4#4Q#7#=#=a#@#I#I#K [|[1L,"3"3"3";<{K0K!1!1q!1!9:r   z.CurveDisplay, specific_params, expected_xscaler   r   linearg?r    )numrh   logc                     Uu  pV[        SS9nUR                  " XuU40 UD6nUR                  R                  5       U:X  d   eg)zICheck the behaviour of the x-axis scaling depending on the data provided.r   r"   N)r   r&   rC   
get_xscale)	r'   r   r+   r,   expected_xscaler-   r.   r/   rI   s	            r   test_curve_display_xscale_autor|     sG    0 DA&A6I)))M_MG;;!!#666r   c                    Uu  pE[        SS9nSSKnSnUR                  " UUU40 UDSU0D6n	[        U	R                  5      S:X  d   eU	R                   H)  n
[        XR                  R                  5      (       a  M)   e   U	R                  b   eU	R                  b   eU	R                  R                  5       u  p[        U5      S:X  d   eSnUR                  " UUU40 UDSU0D6n	[        U	R                  5      S:X  d   eU	R                   H)  n
[        XR                  R                  5      (       a  M)   e   U	R                  b   e[        U	R                  5      S:X  d   eU	R                   H)  n[        XR                  R                  5      (       a  M)   e   U	R                  R                  5       u  p[        U5      S:X  d   eSnUR                  " UUU40 UDSU0D6n	U	R                  b   e[        U	R                  5      S:X  d   eU	R                   H)  n[        XR                  R                  5      (       a  M)   e   U	R                  b   eU	R                  R                  5       u  p[        U5      S:X  d   eg)z9Check the behaviour of the parameter `std_display_style`.r   r"   Nr   rh   fill_betweenr`   )r   r7   r&   ri   r:   r9   r<   r=   r8   r>   rC   rF   r?   r@   	containerErrorbarContainer)r'   r   r+   r,   r-   r.   r/   rJ   r   rI   rK   rM   rk   r~   r`   s                  r   $test_curve_display_std_display_styler     s    DA&A6I))		 	
 ,G w~~!###$		 0 01111 $$$  (((kk;;=OA|!!!&))		 	
 ,G w~~!###$		 0 01111 $$$w$$%***--,(F(FGGGG .kk;;=OA|!!!"))		 	
 ,G >>!!!w  !Q&&&%%(MM$C$CDDDD &  (((kk;;=OA|!!!r   c                    Uu  pE[        SS9nSnSS0nSSS.n	UR                  " UUU40 UDUUU	S.D6n
U
R                  S   R                  5       S:X  d   e[	        U
R
                  S   R                  5       / S	Q/5        S
nSS0nUR                  " UUU40 UDUUS.D6n
U
R                  S   R                  S   R                  5       S:X  d   eg)zqCheck the behaviour of the different plotting keyword arguments: `line_kw`,
`fill_between_kw`, and `errorbar_kw`.r   r"   r~   colorred      ?)r   alpha)r   line_kwfill_between_kw)r           r   r   r`   )r   errorbar_kwN)	r   r&   r:   	get_colorr
   r>   get_facecolorr8   r<   )r'   r   r+   r,   r-   r.   r/   r   r   r   rI   r   s               r   test_curve_display_plot_kwargsr     s    DA&A6I&G %4O))		 	
 ,'G >>!&&(E111a ..0	
 #E"K))		 	
 ,G Q%%a(224===r   zparam_range, xscale)r   
      )ir   2     symlog)r   r   r   c                     Uu  pE[        SS9nSn[        R                  " UUUUUS9nUR                  R	                  5       U:X  d   eg)z>Check the induced xscale from the provided param_range values.r   r"   r   r   N)r   r   r&   rC   rz   )	r'   r   r   xscaler-   r.   r/   r   rI   s	            r   @test_validation_curve_xscale_from_param_range_provided_as_a_listr     sV     DA&A6IJ$33		G ;;!!#v---r   zDisplay, paramsc                     Uu  pE[        SS9n " S SU5      nUR                  " XdU40 UD6n[        X5      (       d   eg)zCheck that named constructors return the correct type when subclassed.

Non-regression test for:
https://github.com/scikit-learn/scikit-learn/pull/27675
r   r"   c                       \ rS rSrSrg)4test_subclassing_displays.<locals>.SubclassOfDisplayi8  r   N)__name__
__module____qualname____firstlineno____static_attributes__r   r   r   SubclassOfDisplayr   8  s    r   r   N)r   r&   r9   )	r'   r   Displayr(   r-   r.   r/   r   rI   s	            r   test_subclassing_displaysr   (  sK     DA&A6IG   ..yQI&IGg1111r   )(numpynpr$   sklearn.datasetsr   sklearn.model_selectionr   r   r   r   sklearn.treer   sklearn.utilsr	   sklearn.utils._testingr
   r   fixturer   markparametrize
ValueErrorr0   rP   rR   r[   r_   rr   rt   arangelinspaceroundlogspaceastypeint64r|   r   r   r   r   r   r   r   <module>r      s     &  0 ! F @ @ 
y	):7ST
		"J0EF #	I!VW	?@RR$6N$6N #	I!VW	?@!7!7H ?,DE #	I!VW	?@((, ,.@AW; BW;t ,.@AZ; BZ;z 4 #&ryyAG	

 
r{{3/KLhW")!xxAqa(@AHHR 	
 
r{{2qa/HI5Q(7)(7 #	I!VW	?@:":"z #	I!VW	?@$>$>N 80(;lE=RS.	.& 	r"	I!VW22r   