
    Mpj.              
       b   S r SSKrSSK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JrJr  SSKJr  SS	KJr  SS
KJrJrJr  S r\R4                  " \R6                  " SSS5      5      R8                  r\R4                  " / SQ5      R8                  r\R>                  " \" \5      RA                  5       S:  \!S9r"\" \5      RA                  5       r#\RH                  " \"RJ                  \!S9r&S\&\#S:  '   S\&\#S:  \#S:  -  '   S\&\#S:  '   \" SSS9r'\" SS9\'\" SSS9\" SS5      \" SSS9-  /r(\( V s/ s H  o \':w  d  M
  U PM     sn r)\RT                  RW                  S\(5      S 5       r,S r-\RT                  RW                  S\)5      S 5       r.\RT                  RW                  S\(5      S 5       r/\RT                  RW                  S\(5      S  5       r0\RT                  RW                  S\)5      S! 5       r1\RT                  Re                  \3S"S#9\RT                  RW                  S\)5      \RT                  RW                  S$\Rh                  " S%S&S'5      5      S( 5       5       5       r5S) r6\RT                  RW                  S\)5      S* 5       r7\RT                  RW                  S\(5      S+ 5       r8\RT                  RW                  S\(5      S, 5       r9S- r:\RT                  RW                  S.S\" S5      0\;S/4/5      S0 5       r<\RT                  RW                  S\(5      S1 5       r=S2 r>S3 r?gs  sn f )4z+Testing for Gaussian process classification    N)approx_fprime)clone)ConvergenceWarning)GaussianProcessClassifier)RBFCompoundKernelWhiteKernel)ConstantKernel)MiniSeqKernel)assert_allcloseassert_almost_equalassert_array_equalc                 .    [         R                  " U 5      $ )N)npsin)xs    c/var/www/html/pdf-tiff/venv/lib/python3.13/site-packages/sklearn/gaussian_process/tests/test_gpc.pyfr      s    66!9    
      )       @g      @g      @g      @g      @dtypegffffffֿ   gffffff?         ?fixedlength_scalelength_scale_boundsg?)r    )MbP?     @@g{Gz?      Y@kernelc                     [        U S9R                  [        [        5      n[	        UR                  [        5      UR                  [        5      S S 2S4   S:  5        g )Nr&   r         ?)r   fitXyr   predictpredict_probar&   gpcs     r   test_predict_consistentr1   7   sF     $6
2
6
6q!
<Cs{{1~s'8'8';AqD'AS'HIr   c                      / SQn [         R                  " / SQ5      n[        SS9n[        US9R	                  X5      n[        UR                  U 5      UR                  U 5      S S 2S4   S:  5        g )NAABBTFTr   baseline_similarity_boundsr(   r   r)   )r   arrayr   r   r*   r   r-   r.   r+   r,   r&   r0   s       r   "test_predict_consistent_structuredr<   >   s`    A
$%Ag>F
#6
2
6
6q
<Cs{{1~s'8'8';AqD'AS'HIr   c                     [        U S9R                  [        [        5      nUR	                  UR
                  R                  5      UR	                  U R                  5      :  d   eg )Nr(   )r   r*   r+   r,   log_marginal_likelihoodkernel_thetar/   s     r   test_lml_improvingrA   G   sV     $6
2
6
6q!
<C&&s{{'8'89C<W<W=   r   c                     [        U S9R                  [        [        5      n[	        UR                  UR                  R                  5      UR                  5       S5        g )Nr(      )r   r*   r+   r,   r   r>   r?   r@   r/   s     r   test_lml_precomputedrD   P   sI     $6
2
6
6q!
<C##CKK$5$568S8S8UWXr   c                 *   [        U S9R                  [        [        5      n[        R
                  " UR                  R                  R                  [        R                  S9nUR                  USS9  [        UR                  R                  US5        g )Nr(   r   F)clone_kernelrC   )r   r*   r+   r,   r   onesr?   r@   shapefloat64r>   r   )r&   r0   input_thetas      r   test_lml_without_cloning_kernelrK   Y   sh     $6
2
6
6q!
<C''#++++11DK%@));:r   c                    [        U S9R                  [        [        5      nUR	                  UR
                  R                  S5      u  p#[        R                  " [        R                  " U5      S:  UR
                  R                  UR
                  R                  S S 2S4   :H  -  UR
                  R                  UR
                  R                  S S 2S4   :H  -  5      (       d   eg )Nr(   T-C6?r   r   )r   r*   r+   r,   r>   r?   r@   r   allabsbounds)r&   r0   lmllml_gradients       r   test_converged_to_local_maximumrS   c   s     $6
2
6
6q!
<C33CKK4E4EtLC66			$;; 2 21a4 88	:;; 2 21a4 88	:   r   z9https://github.com/scikit-learn/scikit-learn/issues/31366)raisesreasonr          c                 j  ^ [        U 5      n [        S U R                  5        5       5      nU R                  " S0 X!0D6  [	        U S9R                  [        [        5      mTR                  U R                  SS9u  p4Sn[        U R                  R                  5       U4S jUS9n[        XFSUS	-  S
9  g )Nc              3   T   #    U  H  oR                  S 5      (       d  M  Uv   M      g7f)r    N)endswith).0names     r   	<genexpr>$test_lml_gradient.<locals>.<genexpr>{   s      #,n0M,s   (	(r(   Teval_gradientg&.>c                 (   > TR                  U S5      $ )NF)r>   )r@   gprs    r   <lambda>#test_lml_gradient.<locals>.<lambda>   s    c11%?r   )epsilonrM   d   )rtolatol )r   next
get_params
set_paramsr   r*   r+   r,   r>   r@   r   copyr   )r&   r    length_scale_param_name_rR   rf   lml_gradient_approxrc   s          @r   test_lml_gradientrr   q   s     6]F" #**,#  @0?@ $6
2
6
6q!
<C11&,,d1SOAG'?
 LDwQT}Ur   c                    Su  p[         R                  R                  U 5      nUR                  X5      S-  S-
  n[         R                  " U5      R                  SS9[         R                  " SU-  5      R                  SS9-   S:  n[        SS5      [        S	/U-  S
/U-  S9-  n[         R                  * n[        S5       Hz  n[        UUU S9R                  XE5      n	U	R                  U	R                  R                  5      n
X[         R                  " [         R                   5      R"                  -
  :  d   eU
nM|     g )N)   r   r   r   )axisrW   r   r   r$   r"   )rM   r%   r      )r&   n_restarts_optimizerrandom_state)r   randomRandomStaterandnr   sumCr   infranger   r*   r>   r?   r@   finfofloat32eps)global_random_seed	n_samples
n_featuresrngr+   r,   r&   last_lmlrw   gprQ   s              r   test_random_startsr      s"    "I
))

 2
3C		)(1,q0A	A	A!2!2!2!:	:a?AsK 3Vj({mj>X$ F wH %a&!5+
 #a)	 	
 (()9)9: 4 8 88888 !)r   c                    ^ U4S jn[        XS9nUR                  [        [        5        UR	                  UR
                  R                  5      UR	                  U R                  5      :  d   eg )Nc                 X  > [         R                  R                  T	5      nUU " USS9pT[        S5       Hq  n[         R                  " UR                  [         R                  " SUS S 2S4   5      [         R                  " SUS S 2S4   5      5      5      nU " USS9nX:  d  Mo  XxpTMs     XE4$ )NFr`   r   r   r   )r   ry   rz   r   
atleast_1duniformmaximumminimum)
obj_funcinitial_thetarP   r   	theta_optfunc_minrp   r@   r   r   s
            r   	optimizer(test_custom_optimizer.<locals>.optimizer   s    ii##$67]%8  rAMMBJJr6!Q$<8"**QqRSt:UVE e4A|&+8  ""r   )r&   r   )r   r*   r+   y_mcr>   r?   r@   )r&   r   r   r0   s    `  r   test_custom_optimizerr      s^    # $6
GCGGAt&&		$	$V\\	23 3 3r   c                    [        U S9nUR                  [        [        5        UR	                  [
        5      n[        UR                  S5      S5        UR                  [
        5      n[        [        R                  " US5      U5        g )Nr(   r   )r   r*   r+   r   r.   X2r   r|   r-   r   r   argmax)r&   r0   y_proby_preds       r   test_multi_classr      s`     $6
2CGGAtr"F

1q)[[_Fryy+V4r   c                     [        U S9nUR                  [        [        5        [        U SS9nUR                  [        [        5        UR	                  [
        5      nUR	                  [
        5      n[        X45        g )Nr(   r   )r&   n_jobs)r   r*   r+   r   r.   r   r   )r&   r0   gpc_2r   y_prob_2s        r   test_multi_class_n_jobsr      s^     $6
2CGGAt%VA>E	IIar"F""2&H)r   c                  Z   [        SS/S9n [        U S9nSn[        R                  " [        US9   UR                  [        [        5        S S S 5        [        SS/S9[        SS	/S9-   n[        US9n[        R                  " S
S9 n[        R                  " S5        UR                  [        [        5        [        U5      S:X  d   e[        US   R                  [        5      (       d   eUS   R                  R                   S   S:X  d   e[        US   R                  [        5      (       d   eUS   R                  R                   S   S:X  d   e S S S 5        ["        R$                  " [        S5      n[        SS/SS/S9n[        US9n[        R                  " S
S9 n[        R                  " S5        UR                  U[        5        [        U5      S:X  d   e[        US   R                  [        5      (       d   eUS   R                  R                   S   S:X  d   e[        US   R                  [        5      (       d   eUS   R                  R                   S   S:X  d   e S S S 5        g ! , (       d  f       GN4= f! , (       d  f       GN;= f! , (       d  f       g = f)Ngh㈵>r"   )r!   r(   zThe optimal value found for dimension 0 of parameter length_scale is close to the specified upper bound 0.001. Increasing the bound and calling fit again may find a better value.match)noise_level_boundsr#   g     j@T)recordalwaysr   r   zThe optimal value found for dimension 0 of parameter k1__noise_level is close to the specified upper bound 0.001. Increasing the bound and calling fit again may find a better value.r   zThe optimal value found for dimension 0 of parameter k2__length_scale is close to the specified lower bound 1000.0. Decreasing the bound and calling fit again may find a better value.r   r   g      $@r%   r   zThe optimal value found for dimension 0 of parameter length_scale is close to the specified upper bound 100.0. Increasing the bound and calling fit again may find a better value.zThe optimal value found for dimension 1 of parameter length_scale is close to the specified upper bound 100.0. Increasing the bound and calling fit again may find a better value.)r   r   pytestwarnsr   r*   r+   r,   r	   warningscatch_warningssimplefilterlen
issubclasscategorymessageargsr   tile)	r&   r0   warning_message
kernel_sumgpc_sumr   X_tilekernel_dimsgpc_dimss	            r   test_warning_boundsr      sy   dD\2F
#6
2C	  
(	@1 
A t= #JA J (z:G		 	 	-h'Aq6{a&),,.@AAAA1I""1% *1 1	
1 &),,.@AAAA1I""1% *1 1	
1% 
.4 WWQ]FC:C:NK(<H		 	 	-h'VQ6{a&),,.@AAAA1I""1% *1 1	
1 &),,.@AAAA1I""1% *1 1	
1% 
.	-K 
A	@ 
.	-< 
.	-s%   I8CJ
$C
J8
J

J
J*zparams, error_type, err_msgz!kernel cannot be a CompoundKernelc                     [        S0 U D6n[        R                  " XS9   UR                  [        [
        5        SSS5        g! , (       d  f       g= f)z0Check that expected error are raised during fit.r   Nrj   )r   r   rT   r*   r+   r,   )params
error_typeerr_msgr0   s       r   test_gpc_fit_errorr   "  s6     $
-f
-C	z	11 
2	1	1s   A
Ac                    [        U S9nUR                  [        [        5        UR	                  [        5      u  p#UR
                  [        R
                  S   4:X  d   eUR
                  [        R
                  S   4:X  d   eg)>Checks that the latent mean and variance have the right shape.r(   r   N)r   r*   r+   r,   latent_mean_and_variancerH   )r&   r0   latent_meanlatent_variances       r   'test_gpc_latent_mean_and_variance_shaper   3  sl     $6
2CGGAqM $'#?#?#B K---  QWWQZM111r   c                      [        [        5       S9n U R                  [        [        5        [
        R                  " [        SS9   U R                  [        5        SSS5        g! , (       d  f       g= f)r   r(   zdReturning the mean and variance of the latent function f is only supported for binary classificationr   N)	r   r   r*   r+   r   r   rT   
ValueErrorr   )r0   s    r   Atest_gpc_latent_mean_and_variance_complain_on_more_than_2_classesr   ?  sR    
#35
1CGGAt 
6

 	$$Q'
 
 
s   A$$
A2c                      / SQn [         R                  " / SQ5      n[        SS9n[        US9R	                  X5      nUR                  U 5        g )Nr3   r7   r   r8   r(   )r   r:   r   r   r*   r   r;   s       r   9test_latent_mean_and_variance_works_on_structured_kernelsr   M  sC    A
$%Ag>F
#6
2
6
6q
<C  #r   )@__doc__r   numpyr   r   scipy.optimizer   sklearn.baser   sklearn.exceptionsr   sklearn.gaussian_processr    sklearn.gaussian_process.kernelsr   r   r	   r
   r}   4sklearn.gaussian_process.tests._mini_sequence_kernelr   sklearn.utils._testingr   r   r   r   
atleast_2dlinspaceTr+   r   r:   ravelintr,   fXemptyrH   r   fixed_kernelkernelsnon_fixed_kernelsmarkparametrizer1   r<   rA   rD   rK   rS   xfailAssertionErrorlogspacerr   r   r   r   r   r   r   r   r   r   r   r(   s   0r   <module>r      sx   1
    (  1 > 
 O  MM"++aR()++]],-//HHQqTZZ\AS)qTZZ\	xxs#R%Z $%bEkb4i  !R$Y ASSk:c;#3KPP	 +2L'|5KV'L  7+J ,JJ #45 6 7+ , 7+; ,; #45
 6
 F   #45RB)?@V A 6	V*. #453 634 7+	5 ,	5 7+
* ,
*F
R ! ~a()/	
		 7+2 ,2($s Ms   6	L,L,