
    e!h9                    :   U d Z ddlZddlZddlZddlZddlZddlZddlmZm	Z	 ddl
Z
ddlZddlZddlmZ ddlmZ ddlmZmZmZ ddlmZ ddlmZ dd	lmZ dd
lmZmZm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+ ddl,m-Z-m.Z.m/Z/m0Z0 ddl1m2Z2 ddl3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z: ddl3m;Z< ddl=m>Z> ddl?m@Z@mAZAmBZBmCZCmDZDmEZE ddlFmGZGmHZHmIZImJZJ ddlKmLZL dZMdZNe(e*dZOe)e+dZP eQ       ZReQeSd<   eRj                  eO       eRj                  eP       g dZU ej                  g dg dg dg dg d g d!g d"g d#g d$g d%g d&g d'g d(g d)g d*g d+g d,g d-g d.g d/g d0g d1g d2g      ZWg d3ZXg d4ZYd5d6gd6d6gd6d5gd7d7gd7d8gd8d7ggZZg d9Z[d6d6gd8d8gd:d8ggZ\g d;Z] ej                         Z_ej                  j                  d7      Zbebj                  e_j                  j                        Zfe_j                  ef   e__g        e_j                  ef   e__d         ej                         Ziebj                  eij                  j                        Zfeij                  ef   ei_g        eij                  ef   ei_d         ej                         Zkebj                  ekj                  j                        Zfekj                  ef   ek_g        ekj                  ef   ek_d         eLd      Zl ej                  dd<d=>      \  ZnZoelj                  d?@      ZqdAeqeqdBk  <   elj                  ddCdD@      Zs e&dEd=dFdG      j                         Zue_j                  e_j                  dHeij                  eij                  dHekj                  ekj                  dHeZe[dHeWeXdHeWeYdHeneodHeqesdHeq esdHeuesdH ej                  dI      esdHdJZwdK ZxdL ZydM Zzej                  j                  dNePj                               ej                  j                  dOeN      dP               Z~dQ ZdR Zej                  j                  dSePj                               ej                  j                  dOeN      dT               ZeEej                  j                  dSePj                               ej                  j                  dUdVdWedXfdYdEedXfdZdWedXfd[dWed<fg      d\                      Zd] Zd^ Zd_ Zd` Zda Zdb Zdc Zdd Zde Zdf Zdg ZddhZej                  j                  dieR      dj        Zej                  j                  dieU      ej                  j                  dkeI      dl               Z	 ddmZej                  j                  dieR      dn        Zej                  j                  dieU      ej                  j                  dkeI      do               Zdp Zdq Zdr Zds Zdt Zdu Zdv Zdw Zej                  j                  dieO      dx        Zej                  j                  dieO      dy        Zdz Zd{ Zd| Zd} Zd~ Zd Zd Zd Zd ZddZej                  j                  deU      ej                  j                  dd      d               Zej                  j                  d e eeU      jY                  eP                  ej                  j                  dddg      d               Zej                  j                  deU      ej                  j                  dg d      ej                  j                  dkeI      d                      Zej                  j                  d e e	eUD  cg c]	  } | ePv s|  c} eN             e e	eUD  cg c]	  } | eOv s|  c} eM            z         ej                  j                  dg d      ej                  j                  dkeI      d                      Zej                  j                  deU      ej                  j                  d eeIeJ            d               Zd Zej                  j                  dieR      d        Zej                  j                  dieR      ej                  j                  ddgeIz         d               Zej                  j                  dieR      d        Zej                  j                  dieU      ej                  j                  deJ      d               Zd Zej                  j                  dieR      d        Zej                  j                  dieR      ej                  j                  deJ      d               Zd Zd Zej                  j                  ddgeIz         d        Zej                  j                  d e eewj}                               ddhz
              ej                  j                  de(e*g      d               Zej                  j                  dewj}                               ej                  j                  de)e+g      d               Zd Zd Zd Zej                  j                  dieR      ej                  j                  dddg      ej                  j                  ddgeIz   eJz         d                      Zej                  j                  dOg d      ej                  j                  dNePj                               d               Zej                  j                  d ed:            d        Zd Zej                  j                  dNe(e*g      ej                  j                  dd8dCg      d               Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zej                  j                  d e e/j                          e0j                                     d        Zd Zej                  j                  dNeRj                               d        Zej                  j                  dOdVdZg      d        Zej                  j                  d ed:            ej                  j                  dOdVdZg      d               Zej                  j                  dOddg      d        Zej                  j                  dOddg      d        Zej                  j                  dOddg      dÄ        Zej                  j                  dOddg      dĄ        Zej                  j                  ddgeJz         ej                  j                  d e)dYƫ       e+dYƫ      g      dǄ               Zej                  j                  dNePj                               dȄ        ZdɄ Zej                  j                  dej                  e)dfej                  e+dfee(dfee*dfg      ej                  j                  dddg      dЄ               Zej                  j                  d eeOj                         ddg            dԄ        Zej                  j                  dej                  e)fej                  e(fg      dք        Zdׄ Zej                  j                  dNe)e+g      ej                  j                  d ej                  ej                  d8ej                  dCddg       ej                  ej                  ej                  d:dCddg       ej                  d7d8d:dCej                  ej                  g       ej                  d7d8d:ej                  dej                  g      g      ej                  j                  dOdVdZg      dۄ                      Zd܄ Zd݄ Zdބ Zd߄ Zd Zyc c} w c c} w )z-
Testing for the tree module (sklearn.tree).
    N)chainproduct)NumpyPickler)assert_allclose)clonedatasetstree)DummyRegressor)NotFittedError)SimpleImputer)accuracy_scoremean_poisson_deviancemean_squared_error)cross_val_scoretrain_test_split)make_pipeline)_sparse_random_matrix)DecisionTreeClassifierDecisionTreeRegressorExtraTreeClassifierExtraTreeRegressor)CRITERIA_CLFCRITERIA_REGDENSE_SPLITTERSSPARSE_SPLITTERS)_py_sort)
NODE_DTYPE	TREE_LEAFTREE_UNDEFINED_build_pruned_tree_py_check_n_classes_check_node_ndarray_check_value_ndarray)Tree)compute_sample_weight)assert_almost_equalassert_array_almost_equalassert_array_equalcreate_memmap_backed_dataignore_warningsskip_if_32bit)	_IS_32BITCOO_CONTAINERSCSC_CONTAINERSCSR_CONTAINERS)check_random_state)ginilog_loss)squared_errorabsolute_errorfriedman_msepoisson)r   r   )r   r   	ALL_TREES)r   r      r   r   r      ir   r   r   r   r   )r   r         r   r:   r   r   r9   皙?r   r8   r9   )r?   r   r         r   r    @r9   r   r   r@   r   r9   )r?   r?   r   g333333r   r   r   r   r   r   r>   r   r   r9   )r?   r?   r   r   r   r   r   r<   r   r   r   r   r   r9   )r?   r   r8   
   r8   r   皙	r   r8   r<   r:   r9   )zG @r         r      r   r   rE            ?r   rC   r9   )rF   r   rG   rH   r   rI   r   r   rE   rJ   r   r   rB   r9   )rF      rG   rH   r   rI   r   r   rE   rJ   r   r   rB   r9   )rF   rL   rG   rH   r   rI   r   r   rE   rJ   rK   r   r?   r   )   rL   r;   r9   rK   r:   rD   r   r9   r=   r<   r   rM   r   )rM   r   r9   r9   r9   r?   r9   r   r   rB   r<   r   r9   r   )rM   r   r9   rM   r<   r?   rD   rM   r   r?   r9   rM   rM   r   )r9   r9   r   rM   rM   r?   r9   rM   r   r=   r9   rM   r<   r   )r<   r9   r   r<   r   r:   rD   r   r9   r=   r<   r   r<   r9   )rF   rL   rG   rH   r   r9   r   r   rE   rJ   rK   r   rC   r9   )rF   rL   rG   rH   r   r9   r   r   rE   rJ         ?r9   r?   r?   )rF   rL   rG   rH   r   rD   r   r   rE   rJ   rK   r   r?   r?   )rM   r   r;   r9   rK   rB   rD   r   r9   r=   r<   r9   r   r?   )rM   r   r9   r9   r9   rB   r9   r   r   rB   r   r   r   r9   )rM   r9   r9   r9   rM   r?   rD   rM   r   r?   r   rM   r9   r9   )r9   r9   r   r   r9   rC   r9   rM   r   r=   r9   rM   r9   r9   )r<   r9   r   r9   r   r:   r9   r   r9   rB   r   r   r9   r   )r9   r9   r   r   r   r   r9   r9   r9   r9   r9   r9   r   r   r   r9   r   r   r9   r   r   r   r   )      ?rA   333333?皙?rD   g333333@@g)\(?{Gz?gףp=
@rR   g?        rP   rM   rI   r   r         @g|?5^?g(\??r   rB   r?   r9   rM   )r?   r?   r?   r9   r9   r9   r<   )r?   r9   r9      rD   )random_state	n_samples
n_features)   r;   sizerT   g?r8   )r[   r[   g      ?)densityrX   Xy)r[   r<   )irisdiabetesdigitstoy	clf_small	reg_small
multilabel
sparse-pos
sparse-neg
sparse-mixzerosc                 ~   |j                   | j                   k(  s,J dj                  ||j                   | j                                t        | j                  |j                  |dz          t        | j                  |j                  |dz          | j                  t
        k(  }t        j                  |      }t        | j                  |   |j                  |   |dz          t        | j                  |   |j                  |   |dz          t        | j                  j                         |j                  j                         |dz          t        | j                  |j                  |dz          t        | j                  |j                  |dz   	       t        | j                  |   |j                  |   |d
z   	       y )Nz({0}: inequal number of node ({1} != {2})z: inequal children_rightz: inequal children_leftz: inequal featuresz: inequal thresholdz: inequal sum(n_node_samples)z: inequal n_node_samplesz: inequal impurityerr_msgz: inequal value)
node_countformatr(   children_rightchildren_leftr   nplogical_notfeature	thresholdn_node_samplessumr&   impurityr'   value)dsmessageexternalinternals        d/var/www/html/diagnosisapp-backend/venv/lib/python3.12/site-packages/sklearn/tree/tests/test_tree.pyassert_tree_equalr      s   	$188q||$
 	!**G6P,P 	'4M*M 9,H~~h'H			(QYYx0'<P2P 	Hq{{84g@U6U 		11
 	!**G6P,P 

AJJBV8VW	1778,g@Q6Q    c                     t         j                         D ]  \  } } |d      }|j                  t        t               t        |j                  t              t        dj                  |               |dd      }|j                  t        t               t        |j                  t              t        dj                  |               y )Nr   rX   Failed with {0}r9   )max_featuresrX   )
	CLF_TREESitemsfitr`   ra   r(   predictTtrue_resultrq   namer$   clfs      r   test_classification_toyr      s    oo' X
d"13;;q>;8I8P8PQU8VW213;;q>;8I8P8PQU8VWXr   c            
         t         j                         D ]  \  } } |d      }|j                  t        t        t        j                  t        t                           t        |j                  t              t        dj                  |              |j                  t        t        t        j                  t        t              d             t        |j                  t              t        dj                  |               y )Nr   r   sample_weightr   rK   )r   r   r   r`   ra   rt   oneslenr(   r   r   r   rq   fullr   s      r    test_weighted_classification_toyr      s    oo' X
d"1BGGCFO43;;q>;8I8P8PQU8VW1BGGCFC$893;;q>;8I8P8PQU8VWXr   r$   	criterionc                    |dk(  rht        j                  t        j                  t                    dz   }t        j                  t              |z   }t        j                  t
              |z   }nt        }t
        } | |d      }|j                  t        |       t        |j                  t              |        | |dd      }|j                  t        |       t        |j                  t              |       y )Nr6   r9   r   rX   r   r   rX   )rt   absminra   arrayr   r   r`   r   r   r   )r$   r   ay_trainy_testregr   s          r   test_regression_toyr     s     I FF266!9!((1+/+&*

3CGGAwCKKNF+

CCGGAwCKKNF+r   c                     t        j                  d      } d| d dd df<   d| dd dd f<   t        j                  | j                        \  }}t        j                  |j                         |j                         g      j                  }| j                         } t        j                         D ]  \  }} |d      }|j                  ||        |j                  ||       dk(  sJ dj                  |              |dd      }|j                  ||        |j                  ||       dk(  r~J dj                  |              y )	N)rD   rD   r9   r;   r   r   rO   r   rX   r   )rt   rl   indicesshapevstackravelr   r   r   r   scorerq   )ra   gridxgridyr`   r   r$   r   s          r   test_xorr     s   
AAbqb"1"fIAab!"fI::agg&LE5
		5;;=%++-0133A		Aoo' F
d"1yyA#%E'8'?'?'EE%21yyA#%E'8'?'?'EE%Fr   c                     t        t        j                         t              D ]"  \  \  } }} ||d      }|j	                  t
        j                  t
        j                         t        |j                  t
        j                        t
        j                        }|dkD  sJ dj                  | ||              ||dd      }|j	                  t
        j                  t
        j                         t        |j                  t
        j                        t
        j                        }|dkD  rJ dj                  | ||              y )Nr   r   rV   z0Failed with {0}, criterion = {1} and score = {2}rM   r   rK   )r   r   r   CLF_CRITERIONSr   rb   datatargetr   r   rq   )r   r$   r   r   r   s        r   	test_irisr   3  s    #*9??+<n#M 
tiYQ7		4;;'s{{4995t{{Cs{ 	
NUU)U
 	
{ YQQG		4;;'s{{4995t{{Cs{ 	
NUU)U
 	
{
r   z
name, Treec                 2    ||d      }|j                  t        j                  t        j                         t	        t        j                  |j                  t        j                              }|t        j                  d      k(  sJ d|  d| d|        y )Nr   r   zFailed with z, criterion = z and score = )r   rc   r   r   r   r   pytestapprox)r   r$   r   r   r   s        r   test_diabetes_overfitr   E  s    
 
3CGGHMM8??+xHMM0JKEFMM	  J	dV>)M%IJ r   z&criterion, max_depth, metric, max_lossr3      <   r4   r5   r6   c                      |||dd      }|j                  t        j                  t        j                          |t        j                  |j	                  t        j                              }d|cxk  r|k  sJ  J y )NrJ   r   )r   	max_depthr   rX   )r   rc   r   r   r   )r   r$   r   r   metricmax_lossr   losss           r   test_diabetes_underfitr   R  sa     iaVW
XCGGHMM8??+(//3;;x}}#=>Dthr   c            	          t         j                         D ]v  \  } } |ddd      }|j                  t        j                  t        j
                         |j                  t        j                        }t        t        j                  |d      t        j                  t        j                  j                  d         dj                  |              t        t        j                  |d      |j                  t        j                        dj                  |              t!        |j                  t        j                        t        j"                  |j%                  t        j                              ddj                  |              y y )Nr9   *   r   r   rX   r   r   rn   rL   )r   r   r   rb   r   r   predict_probar'   rt   ry   r   r   rq   r(   argmaxr   r&   exppredict_log_proba)r   r$   r   prob_predicts       r   test_probabilityr   g  s     oo' 

dQQR@		4;;'((3!FF<#GGDIIOOA&'%,,T2	

 	IIlA&KK		"%,,T2	

 	dii(FF3((34%,,T2		

r   c                      t        j                  d      d d t         j                  f   } t        j                  d      }t        j	                         D ]!  \  }} |d d      }|j                  | |       # y )Ni'  r   r   rX   )rt   arangenewaxis	REG_TREESr   r   r`   ra   r   r$   r   s        r   test_arrayreprr     s`     			%BJJ'A
		%Aoo' 
dT21r   c                     ddgddgddgddgddgddgg} g d}t         j                         D ]L  \  }} |d      }|j                  | |       t        |j	                  |       |dj                  |      	       N t        j                         D ]L  \  }} |d      }|j                  | |       t        |j	                  |       |dj                  |      	       N y )
NrB   r?   r9   rM   )r9   r9   r9   r9   r9   r9   r   r   r   rn   )r   r   r   r(   r   rq   r   r&   )r`   ra   r   TreeClassifierr   TreeRegressorr   s          r   test_pure_setr     s    
bB8b"X1v1v1v>AA ) 1 Vn!,13;;q>16G6N6Nt6TUV
  )0 Wm+1CKKNA7H7O7OPT7UVWr   c            
         t        j                  g dg dg dg dg dg dg dg      } t        j                  g d      }t        j                  d	
      5  t        j	                         D ]Z  \  }} |d      }|j                  | |       |j                  | |        |j                  |  |       |j                  |  |        \ 	 d d d        y # 1 sw Y   y xY w)N)gs_c@d	a@籛 `8`@?c@)g_9a@g 8`@g-Vu]@g    @Xd@)gSW j_@r   r   r   )g ً`@4Ta@	lKa@{c@)g|@Y@g~G`a@gwI?lKa@g/"c@)g_@r   r   r   )g:^@r   r   r   )rO   gAw?gtQ?5??rT   g7G?gۺ?gb'?raise)allr   r   )rt   r   errstater   r   r   r   s        r   test_numerical_stabilityr     s    
DDDDDDD	

	A 	WXA		! #//+ 	JD$A&CGGAqMGGArNGGQBNGGQBO	  s   A2CCc            	         t        j                  ddddddd      \  } }t        j                         D ]  \  }} |d      }|j	                  | |       |j
                  }t        j                  |dkD        }|j                  d   dk(  sJ d	j                  |             |dk(  rsJ d	j                  |              t        d      }|j	                  t        j                  t        j                         t        dt        t        j                        
      }|j	                  t        j                  t        j                         t        |j
                  |j
                         y )N  rD   r<   r   FrY   rZ   n_informativen_redundant
n_repeatedshufflerX   r   皙?r   rX   max_leaf_nodes)r   make_classificationr   r   r   feature_importances_rt   ry   r   rq   r   rb   r   r   r   r(   )r`   ra   r   r$   r   importancesn_importantclf2s           r   test_importancesr     s)   ''DAq  oo' @
d"1..ff[3./  #r)I+<+C+CD+II)a?!2!9!9$!??@ !a
0CGGDIIt{{#!qTYYPDHHTYY$s//1J1JKr   c                      t               } t        j                  t              5  t	        | d       d d d        y # 1 sw Y   y xY w)Nr   )r   r   raises
ValueErrorgetattr)r   s    r   test_importances_raisesr     s6    
 
"C	z	" -+,- - -s	   :Ac            	         t        j                  ddddddd      \  } }t        ddd	      j                  | |      }t	        d
dd	      j                  | |      }t        |j                  |j                         t        |j                  j                  |j                  j                         t        |j                  j                  |j                  j                         t        |j                  j                  |j                  j                         t        |j                  j                  |j                  j                         y )Ni  rD   r<   r   Fr   r1   r;   )r   r   rX   r3   )r   r   r   r   r   r&   r   r(   tree_rv   rs   rr   rx   )r`   ra   r   r   s       r   )test_importances_gini_equal_squared_errorr     s     ''DAq !6QQ
O
S
S	1C  !QQ	c!Qi  00#2J2JKsyy((#))*;*;<syy..		0G0GHsyy//1I1IJsyy//1I1IJr   c                  V   t         j                         D ]  \  } } |d      }|j                  t        j                  t        j
                         |j                  t        t        j                  t        j                  j                  d               k(  sJ  |d      }|j                  t        j                  t        j
                         |j                  t        t        j                  t        j                  j                  d               k(  sJ  |d      }|j                  t        j                  t        j
                         |j                  dk(  sJ  |d      }|j                  t        j                  t        j
                         |j                  dk(  sJ  |d      }|j                  t        j                  t        j
                         |j                  dk(  sJ  |d      }|j                  t        j                  t        j
                         |j                  t        dt        j                  j                  d   z        k(  sJ  |d      }|j                  t        j                  t        j
                         |j                  t        j                  j                  d   k(  sJ  |d       }|j                  t        j                  t        j
                         |j                  t        j                  j                  d   k(  rJ  y )	Nsqrt)r   r9   log2r<   rS   rK   rO   )r7   r   r   rb   r   r   max_features_intrt   r   r   r   )r   TreeEstimatorests      r   test_max_featuresr     s$   (0 7m0		4;;'  C		0B(C$DDDD0		4;;'  C		0B(C$DDDD+		4;;'  A%%%+		4;;'  A%%%.		4;;'  A%%%-		4;;'  Cdiiooa.@(@$AAAA-		4;;'  DIIOOA$6666.		4;;'  DIIOOA$6666?7r   c                  J	   t         j                         D ]o  \  } } |       }t        j                  t              5  |j                  t               d d d        |j                  t        t               g dg}t        j                  t              5  |j                  |       d d d         |       }t        d d }t        j                  t              5  |j                  t        |       d d d        t        j                  t              } |       }|j                  |t               t        |j                  t              t                |       }t        j                  t              5  |j                  t               d d d        |j                  t        t               t        j                   t              }t        j                  t              5  |j                  |d d dd f          d d d        t        j"                  t              j                  } |       }|j                  t        j$                  t        |      t               t        j                  t              5  |j                  t               d d d        t        j                  t              5  |j'                  t               d d d         |       }|j                  t        t               t        j                  t              5  |j                  |       d d d        t        j                  t              5  |j'                  |       d d d         |       }t        j                  t              5  |j'                  t               d d d        r t)        d      }t        j                  t        d      5  |j                  g dgg d	       d d d        t        j                  t        d
      5  |j                  g dgg d       d d d        y # 1 sw Y   xY w# 1 sw Y   vxY w# 1 sw Y   ;xY w# 1 sw Y   xY w# 1 sw Y   OxY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   \xY w# 1 sw Y   6xY w# 1 sw Y   uxY w# 1 sw Y   xY w# 1 sw Y   y xY w)N)rB   r?   r9   r?   r9   r6   r   zy is not positive.*Poissonmatchr   r9   rM   )r   r   r   zSome.*y are negative.*Poisson)r;   grM   )r   r   r   r   r   r   r`   r   ra   r   rt   asfortranarrayr&   r   r   r   asarrayr   dotapplyr   )	r   r   r   X2y2XftXtr   s	            r   
test_errorr    sH   (0 6mo]]>* 	!a 	! 	1]]]:& 	"b!	" osV]]:& 	GGArN	 q!oACKKNK8 o]]>* 	KKN	 	1JJqM]]:& 	"KK!QR%!	" XXa[]]oq"q!]]:& 	KKN	]]:& 	IIaL	 o1]]:& 	KKO	]]:& 	IIbM	 o]]>* 	IIaL	 	k6r  )
4C	z)E	F (Y'(	z)H	I +\*+ +s	! 	!
	" 	"	 		 		" 	"	 		 	
	 		 	
	 	
( (+ +s   PPP%-P2P?+Q"Q:Q&-Q3'R /R*RP	P"	%P/	2P<	?Q		Q	Q#	&Q0	3Q=	 R
	RR"c                     t        j                  t        j                  t        j
                  j                        } t        j                  }t        dt        j                               D ]  \  }}t        |   } |d|d      }|j                  | |       |j                  j                  |j                  j                  dk7     }t        j                  |      dkD  sJ dj!                  |              |d	|d      }|j                  | |       |j                  j                  |j                  j                  dk7     }t        j                  |      dkD  rJ dj!                  |              y
)z Test min_samples_split parameterdtypeN  rD   r   )min_samples_splitr   rX   r?   	   r   r>   N)rt   r  rb   r   r	   _treeDTYPEr   r   r7   keysr   r   rx   rs   r   rq   )r`   ra   r   r   r   r   node_sampless          r   test_min_samples_splitr  _  s4   
$))4::+;+;<AA !(inn6F G H!$  a
 	1yy//		0G0G20MNvvl#a'G):)A)A$)GG' !.q
 	1yy//		0G0G20MNvvl#a'G):)A)A$)GG'+Hr   c                     t        j                  t        j                  t        j
                  j                        } t        j                  }t        dt        j                               D ]  \  }}t        |   } |d|d      }|j                  | |       |j                  j                  |       }t        j                  |      }||dk7     }t        j                  |      dkD  sJ dj!                  |              |d|d      }|j                  | |       |j                  j                  |       }t        j                  |      }||dk7     }t        j                  |      dkD  rJ dj!                  |              y )	Nr  r  r;   r   )min_samples_leafr   rX   r8   r   r   )rt   r  rb   r   r	   r  r  r   r   r7   r  r   r   r  bincountr   rq   )	r`   ra   r   r   r   r   outnode_counts
leaf_counts	            r   test_min_samples_leafr   ~  sL   
$))4::+;+;<AA !(inn6F G F!$ ~A
 	1iiooa kk#& !12
vvj!A%E'8'?'?'EE%  a
 	1iiooa kk#& !12
vvj!A%E'8'?'?'EE%/Fr   c                    t         |   d   j                  t        j                        }| ||      }t         |   d   }t        j                  |j                  d         }t        j                  |      }t        |    }t        dt        j                  ddd            D ]  \  }}	 ||	|d      }
|
j                  |||	       |*|
j                  j                  |j                               }n|
j                  j                  |      }t        j                  ||
      }||dk7     }t        j                   |      ||
j"                  z  k\  rJ dj%                  | |
j"                                |j                  d   }t        dt        j                  ddd            D ]  \  }}	 ||	|d      }
|
j                  ||       |*|
j                  j                  |j                               }n|
j                  j                  |      }t        j                  |      }||dk7     }t        j                   |      ||
j"                  z  k\  rJ dj%                  | |
j"                                y)zPTest if leaves contain at least min_weight_fraction_leaf of the
    training setr`   Nra   r   r  rK   rJ   )min_weight_fraction_leafr   rX   r   )weightsz,Failed with {0} min_weight_fraction_leaf={1})DATASETSastypert   float32rngrandr   ry   r7   r   linspacer   r   r  tocsrr  r   r"  rq   )r   r   sparse_containerr`   ra   r#  total_weightr   r   fracr   r  node_weightsleaf_weightss                 r   check_min_weight_fraction_leafr0    s5    	3&&rzz2A#Q3Ahhqwwqz"G66'?LdOM !(bkk!S!6L M 
%).WX
 	1G,'))//!''),C))//!$C{{38#LA$56FF< L33O3O$OO	
9@@#..
	
O
* 771:L 'bkk!S!6L M 
%).WX
 	1'))//!''),C))//!$C{{3'#LA$56FF< L33O3O$OO	
9@@#..
	
O
r   r   c                     t        | d       y Nrb   r0  r   s    r   ,test_min_weight_fraction_leaf_on_dense_inputr5    s    "40r   csc_containerc                      t        | d|       y Nrh   )r+  r3  r   r6  s     r   -test_min_weight_fraction_leaf_on_sparse_inputr:    s     #4Vr   c                    t         |   d   j                  t        j                        }| ||      }t         |   d   }|j                  d   }t
        |    }t        dt        j                  ddd            D ]  \  }} |||dd	      }	|	j                  ||       |*|	j                  j                  |j                               }
n|	j                  j                  |      }
t        j                  |
      }||dk7     }t        j                  |      t        ||	j                  z  d      k\  rJ d
j!                  | |	j                  |	j"                                t        dt        j                  ddd            D ]  \  }} |||dd	      }	|	j                  ||       |*|	j                  j                  |j                               }
n|	j                  j                  |      }
t        j                  |
      }||dk7     }t        j                  |      t        ||	j                  z  ||	j"                  z        k\  rJ d
j!                  | |	j                  |	j"                                y)zzTest the interaction between min_weight_fraction_leaf and
    min_samples_leaf when sample_weights is not provided in fit.r`   Nra   r   r  rK   r<   r;   )r"  r   r  rX   zBFailed with {0} min_weight_fraction_leaf={1}, min_samples_leaf={2}r   )r$  r%  rt   r&  r   r7   r   r)  r   r   r  r*  r  r   maxr"  rq   r  )r   r   r+  r`   ra   r,  r   r   r-  r   r  r.  r/  s                r   4check_min_weight_fraction_leaf_with_min_samples_leafr=    sL   
 	3&&rzz2A#Q3A771:LdOM 'bkk!S!6L M 
%))	
 	1'))//!''),C))//!$C{{3'#LA$56vvl#sC8881(
 
 	
OVV#..0D0D
	
 
%
. !(bkk!S!6L M 
%)) 	
 	1'))//!''),C))//!$C{{3'#LA$56vvl#sC888C000(
 
 	
 PVV#..0D0D
	
 
%
r   c                     t        | d       y r2  r=  r4  s    r   Btest_min_weight_fraction_leaf_with_min_samples_leaf_on_dense_inputr@  "  s    8vFr   c                      t        | d|       y r8  r?  r9  s     r   Ctest_min_weight_fraction_leaf_with_min_samples_leaf_on_sparse_inputrB  '  s    
 9l]r   c                    t        j                  d|       \  }}t        dt        j	                               D ]  \  }}t        |   } ||d      } ||dd      } ||dd      } ||d	d      }	|d
f|df|df|	d	ffD ]  \  }
}|
j
                  |k  s!J dj                  |
j
                  |             |
j                  ||       t        |
j                  j                        D ]M  }|
j                  j                  |   t        k7  s%|
j                  j                  |   }|
j                  j                  |   }|
j                  j                  |   }|
j                  j                  |   }|
j                  j                  |   }||z  }|
j                  j                  |   }|
j                  j                  |   }|
j                  j                  |   }||z  }||z   }||z  }|
j                  j                  |   |j                   d   z  }|||z
  z  }||k\  r9J dj                  ||                y )Nd   rY   rX   r  r   r   rX   rQ   )r   min_impurity_decreaserX   g-C6?r   gHz>z)Failed, min_impurity_decrease = {0} > {1}z2Failed with {0} expected min_impurity_decrease={1})r   r   r   r7   r  rG  rq   r   ranger   rp   rs   r   rz   weighted_n_node_samplesrr   r   )global_random_seedr`   ra   r   r   r   est1est2est3est4r   expected_decreasenode
imp_parent
wtd_n_nodeleft
wtd_n_leftimp_leftwtd_imp_leftrightwtd_n_right	imp_rightwtd_imp_rightwtd_avg_left_right_impfractional_node_weightactual_decreases                             r   test_min_impurity_decreaser^  1  st    ''#DVWDAq !(inn6F G >!$ NK)TU
 )VW
 )ST

 4L4L6N3K	'
 ,	"C" ))->>:AA))+<> GGAqMcii223   99**40I=!$!3!3D!9J!$!B!B4!HJ992248D!$!B!B4!HJ"yy11$7H#-#8LII44T:E"%))"C"CE"JK #		 2 25 9I$/)$;M-:\-I**j8* 		99$?!''!*L + '="%;;'O
 (+<<KRR'):<; ,	%>r   c            
         t         j                         D ]C  \  } }d| v r!t        j                  t        j                  }}n t
        j                  t
        j                  }} |d      }|j                  ||       |j                  ||      }g d}|D ci c]  }|t        |j                  |       }}t        j                  |      }	t        j                  |	      }
t        |
      |j                  k(  sJ |
j                  ||      }||k(  sJ dj                  |              |D ]-  }t!        t        |
j                  |      ||   d| d|         / F y	c c}w )
z8Test pickling preserves Tree properties and performance.
Classifierr   r   )r   rp   capacity	n_classesrs   rr   n_leavesrv   rw   rz   rx   rI  r{   z6Failed to generate same score  after pickling with {0}z"Failed to generate same attribute z after pickling with rn   N)r7   r   rb   r   r   rc   r   r   r   r   pickledumpsloadstype	__class__rq   r(   )r   r   r`   ra   r   r   
attributes	attributefitted_attributeserialized_objectrL  score2s               r   test_picklern  y  sW   (0 .m499dkkqA==(//qA+1		!Q

  GQ
9BIwsyy)44
 
 #LL-||-.DzS]]***Aq!VO	QCJJ4P	Q) 	I

I. +8 Dv		M.4
s   Ec                     ddgddgddgddgddgddgddgddgddgddgddgddgg} ddgddgddgddgddgddgddgddgddgddgddgddgg}ddgddgddgddgg}ddgddgddgddgg}t         j                         D ]  \  }} |d      }|j                  | |      j                  |      }t	        ||       |j
                  dk(  sJ |j                  |      }t        |      dk(  sJ |d   j
                  dk(  sJ |d   j
                  d	k(  sJ |j                  |      }	t        |	      dk(  sJ |	d   j
                  dk(  sJ |	d   j
                  d	k(  rJ  t        j                         D ]L  \  }}
 |
d      }|j                  | |      j                  |      }t        ||       |j
                  dk(  rLJ  y )
NrB   r?   r9   rM   r   r<   r   r8   rM   )r8   r8   )r   r   r   r   r(   r   r   r   r   r   r&   )r`   ra   r   y_truer   r   r   y_hatproba	log_probar   r   s               r   test_multioutputru    sR    
R	R	R	
A	
A	
A	Q	Q	Q	
B	
B	
B	A  
Q	Q	Q	
A	
A	
A	Q	Q	Q	
A	
A	
A	A bAq6B7QG,A1g1vAwA/F !* 1 ,n!,1%%a(5&){{f$$$!!!$5zQQx~~'''Qx~~'''))!,	9~"""|!!V+++|!!V+++,"  )0 %m+1%%a(E6*{{f$$$	%r   c                  d   t         j                         D ]  \  } } |d      }|j                  t        t               |j
                  dk(  sJ t        |j                  ddg       t        j                  t        t        j                  t              dz  f      j                  } |d      }|j                  t        |       t        |j
                        dk(  sJ t        |j                        dk(  sJ t        |j
                  ddg       t        |j                  ddgddgg        y )Nr   r   rM   r?   r9   rB   )r   r   r   r`   ra   
n_classes_r(   classes_rt   r   r   r   r   )r   r   r   _ys       r   test_classes_shaperz    s     ) 1 =n!,1~~"""3<<"a1 YY288A;?+,..!,23>>"a'''3<< A%%%3>>Aq623<<2q'B7);<=r   c                     t         j                  d d } t         j                  d d }t        d|      }t        j                         D ]=  \  }} |d      }|j                  | ||       t        |j                  |       |       ? y )N}   balancedr   r   r   )	rb   r   r   r%   r   r   r   r&   r   )unbalanced_Xunbalanced_yr   r   r   r   s         r   test_unbalanced_irisr    sy    99Tc?L;;t$L)*lCM ) 1 En!,l-HCKK5|DEr   c                     t        t        j                         t        j                  t        j
                  g      D ]  \  \  } }} |d      }t        j                  t        j                  |      }t        j                  }t        |j                  ||      j                  |      |       t        j                  t        j                  d|      }t        j                  }t        |j                  ||      j                  |      |       t        j                  t        j                  d|      }t        j                  }t        |j                  ||      j                  |      |       t        j                  t        j                  |      }t        j                  }t        |j                  ||      j                  |      |       t        D ]U  } |t        j                  |      }t        j                  }t        |j                  ||      j                  |      |       W t        D ]U  } |t        j                  |      }t        j                  }t        |j                  ||      j                  |      |       W t        j                  t        j                  d d d   |      }t        j                  d d d   }t        |j                  ||      j                  |      |        y )Nr   r   r  C)orderr  Fr<   )r   r7   r   rt   float64r&  r  rb   r   r   r(   r   r   ascontiguousarrayr/   r.   )r   r   r  r   r`   ra   csr_containerr6  s           r   test_memory_layoutr    s%   (/BJJ

3) (8$}u + JJtyy.KK3771a=003Q7 JJtyy59KK3771a=003Q7 JJtyy59KK3771a=003Q7   %8KK3771a=003Q7 , 	<Mdiiu5AAswwq!}44Q7;	< , 	<Mdiiu5AAswwq!}44Q7;	< JJtyy1~U3KK!3771a=003Q7Q(8r   c                  z   t        j                  d      d d t         j                  f   } t        j                  d      }d|d d t        j                  d      }d||dk(  <   t	        d      }|j                  | ||       t        |j                  |       t        j                  d             t        j                  d      d d t         j                  f   } t        j                  d      }d|dd d	|dd d| dddf<   t        j                  d      }d
||d	k(  <   t	        dd      }|j                  | ||       |j                  j                  d   dk(  sJ d||d	k(  <   t	        dd      }|j                  | ||       |j                  j                  d   dk(  sJ t        j                  } t        j                  }t        j                  d| j                   d   d      }t	        d      }|j                  | |   ||          t        j"                  || j                   d         }t	        d      }|j                  | ||       |j                  j$                  t&        j(                  j*                  k7  }t-        |j                  j                  |   |j                  j                  |          y )NrD  rT   2   r   r   r      r9   rM   gRQ?r   g     b@rK   g     H@)	minlength)rt   r   r   r   r   r   r(   r   rl   r   rw   rb   r   r   r'  randintr   r  rs   r	   r  r   r'   )r`   ra   r   r   
duplicatesr   r   s          r   test_sample_weightr  5  sA    			#q"**}%A
AAcrFGGCLMM!q&
 a
0CGGAqG.s{{1~rwws|4 			#q"**}%A
AAbIAc#JAc#gqjMGGCLM M!q&
 11
=CGGAqG.99q!U***M!q&
 11
=CGGAqG.99q!T))) 			AAQ
C0J
 a
0CGGAjM1Z=)KK
aggajAM!q1DHHQH/yy&&$***>*>>H		H%tzz';';H'Er   c                  D   t        j                  d      d d t         j                  f   } t        j                  d      }d|d d t	        d      }t         j
                  j                  dd      }t        j                  t              5  |j                  | ||       d d d        t        j                  d      }t        j                  d      }t        j                  t        |	      5  |j                  | ||       d d d        y # 1 sw Y   lxY w# 1 sw Y   y xY w)
NrD  rT   r  r   r   r9   r   zgInput should have at least 1 dimension i.e. satisfy `len(x.shape) > 0`, got scalar `array(0.)` instead.r  )rt   r   r   r   r   randomr(  r   r   r   r   r   reescape	TypeError)r`   ra   r   r   expected_errs        r   test_sample_weight_invalidr  i  s    
		#q"**}%A
AAcrF
 a
0CIINN3*M	z	" 31M23 HHQKM99BL 
y	5 31M23 33 33 3s   
D
,D
DDc                    t         |    } |d      }|j                  t        j                  t        j                          |dd      }|j                  t        j                  t        j                         t        |j                  |j                         t        j                  t        j                  t        j                  t        j                  f      j                  } |ddddddddddddgd      }|j                  t        j                  |       t        |j                  |j                          |dd      }|j                  t        j                  |       t        |j                  |j                         t        j                  t        j                  j                        }|t        j                  dk(  xx   d	z  cc<   dd
dd} |d      }|j                  t        j                  t        j                  |        ||d      }|j                  t        j                  t        j                         t        |j                  |j                          |d      }|j                  t        j                  t        j                  |dz          ||d      }|j                  t        j                  t        j                  |       t        |j                  |j                         y )Nr   r   r}  class_weightrX   g       @rO   r  r9   rD  g      Y@rM   )r   r   rb   r   r   r&   r   rt   r   r   r   r   )	r   r   clf1r   
iris_multiclf3clf4r   r  s	            r   test_class_weightsr    s    t_N q)DHHTYY$zBDHHTYY$1143L3LM DKKdkkBCEEJ$$$

 D 	HHTYY
#1143L3LMzBDHHTYY
#1143L3LM GGDKK--.M$++"#s*#u-Lq)DHHTYY]3|!DDHHTYY$1143L3LM q)DHHTYY]A%56|!DDHHTYY]31143L3LMr   c                 @   t         |    }t        j                  t        t        j                  t              dz  f      j
                  } |dddgd      }d}t        j                  t        |      5  |j                  t        |       d d d        y # 1 sw Y   y xY w)	NrM   rK   rO   r?   r9   r   r  zBnumber of elements in class_weight should match number of outputs.r  )r   rt   r   ra   r   r   r   r   r   r   r`   )r   r   ry  r   ro   s        r   test_class_weight_errorsr    s}     t_N	Arxx{Q'	(	*	*B CC'8&9
JCRG	z	1 2  s   4BBc                      t        j                  dd      \  } }d}t        j                         D ]:  \  }} |d |dz         j	                  | |      }|j                         |dz   k(  r:J  y NrD  r9   rE  r8   )r   r   )r   make_hastie_10_2r7   r   r   get_n_leavesr`   ra   kr   r   r   s         r   test_max_leaf_nodesr    sp    $$sCDAq	A(0 +md1q5AEEaK!QU***+r   c                      t        j                  dd      \  } }d}t        j                         D ]4  \  }} |d|      j	                  | |      }|j                         dk(  r4J  y r  )r   r  r7   r   r   	get_depthr  s         r   test_max_leaf_nodes_max_depthr    se    $$sCDAq	A(0 $ma:>>q!D}}!###$r   c                      dD ]]  } t        t               j                  dgdggddg      j                  |       }d|j                  d   cxk  rdk  rPJ d        J d        y )N)rb  r{   rs   rr   rw   rz   rv   rx   r   r9   rC   r<   z Array points to arbitrary memory)r   r   r   r   flat)attrr{   s     r   test_arrays_persistr    st    	 K .044qcA3Z!QHNNPTUUZZ]&Q&J(JJ&J(JJ&Kr   c                     t        d      } t        j                  d      }| j                  ddd      }t        j                         D ];  \  }} |d      }|j                  ||       |j                  j                  dk(  r;J  y )Nr   )rD   r[   rM   )rD   r   )	r0   rt   rl   r  r7   r   r   r   r   )rX   r`   ra   r   r   r   s         r   test_only_constant_featuresr    sx    %a(L
AQ5)A(0 (m+1yy""a'''(r   c                  r   t        j                  t        j                  g dgt        j                  d      f            } g d}t        j                         D ]\  \  }}d|vs |dd      }|j                  | |       |j                  j                  dk(  sJ |j                  j                  d	k(  r\J  y )
N)r   r   r   r   r   r9   rM   r8   r;   rJ      )r8   rI   )r   r   r   r9   r9   rM   rM   rM   r<   r<   r<   	ExtraTreer   r9   r   rM   r;   )
rt   	transposer   rl   r7   r   r   r   r   rp   r`   ra   r   r   r   s        r   ,test_behaviour_constant_feature_after_splitsr    s    

		568IJK	A 	*A(0 -md"QQ?CGGAqM99&&!+++99''1,,,-r   c                     t        j                  t        j                  dgdgdgdgg      t        j                  d      g      } t        j                  g d      }t        j                         D ]k  \  }} |dd      }|j                  | |       |j                  j                  dk(  sJ t        |j                  |       t        j                  dd	             m t        j                         D ]k  \  }} |dd      }|j                  | |       |j                  j                  dk(  sJ t        |j                  |       t        j                  d
d	             m y )NrO   rT   )r8   r  )rT   rO   rT   rO   r   r9   r   rp  rK   )r8   )rt   hstackr   rl   r   r   r   r   r   r(   r   r   r   r   r  s        r   (test_with_only_one_non_constant_featuresr    s    
		288cUSEC53%89288I;NOPA
%&A(0 Gm;1yy""a'''3,,Q/1EF	G  )0 ?m;1yy""a'''3;;q>2774+=>	?r   c                  &   t        j                  dd      j                  t         j                        j	                  dd      } t               }t        j                  t        d      5  |j                  | g d       d d d        y # 1 sw Y   y xY w)Ng\)c=Hr8   r?   r9   r&  r  )r   r9   r   r9   )
rt   repeatr%  r  reshaper   r   r   r   r   )r`   r   s     r   test_big_inputr    sg    
		(A%%bjj199"a@A
 
"C	z	3 !< ! ! !s   )BBc                  z    ddl m}  t        j                  t              5   |         d d d        y # 1 sw Y   y xY w)Nr   _realloc_test)sklearn.tree._utilsr  r   r   MemoryErrorr  s    r   test_reallocr    s+    1	{	#   s   1:c                     dt        j                  d      z  } t        j                  j	                  dd      }t        j                  j                  ddd      }d| dz   z  }t        d|      }t        j                  t              5  |j                  ||       d d d        d| dz
  z  dz
  }t        d|      }t        j                  t              5  |j                  ||       d d d        y # 1 sw Y   VxY w# 1 sw Y   y xY w)	NrL   PrD   rM   r   r9   best)splitterr   )structcalcsizert   r  randnr  r   r   r   	Exceptionr   r  )n_bitsr`   ra   huger   s        r   test_huge_allocationsr    s    %%F
		AA
		!Q#A !D
 &
FC	y	! 1
 !q D
 &
FC	{	# 1   s   C0C<0C9<Dc                     t         |    }t        |   d   }t        |   d   }|dv r|j                  d   dz  }|d | }|d | }t        t        z   t
        z   D ]5  } ||      } |d|      j                  ||      }	 |d|      j                  ||      }
t        |	j                  |
j                  dj                  |              |	j                  |      }| t        v r"|	j                  |      }|	j                  |      }t        t
        z   t        z   D ]t  } ||t        j                        }t!        |
j                  |      |       | t        v s?t!        |
j                  |             t!        |
j                  |             v 8 y )	Nr`   ra   )rd   rc   r   r;   rX   r   5{0} with dense and sparse format gave different treesr  )r7   r$  r   r-   r.   r/   r   r   r   rq   r   r   r   r   rt   r&  r'   )r	   datasetr   r   r`   ra   rY   r+  X_sparser|   r}   y_predy_probay_log_probasparse_container_testX_sparse_tests                   r   check_sparse_inputr  /  s|   dOM#A#A ((GGAJ!O	jyMjyM*^;nL #A& qI>BB1aHqI>BB8QOGGGGCJJ4P	
 19ooa(G--a0K%3n%D~%U 		!1("**MM%aii&>Gy )!//-*H'R)''6		%r   	tree_typer  )rf   re   rd   rh   ri   rj   rk   rl   c                 0    |dk(  rdnd }t        | ||       y )Nrd   r<   r  )r  r  r   s      r   test_sparse_inputr  X  s     (dIy'95r   rc   rg   c                     t        | |d       y )NrM   r  )r  r  s     r   test_sparse_input_reg_treesr  k  s    
 y'1-r   )ri   rj   rk   rl   c                    t         |    }t        |   d   } ||      }t        |   d   } |ddd      j                  ||      } |ddd      j                  ||      }t        |j                  |j                  dj                  |              t        |j                  |      |j                  |              |ddd	      j                  ||      } |ddd	      j                  ||      }t        |j                  |j                  dj                  |              t        |j                  |      |j                  |              |d|j                  d   dz  
      j                  ||      } |d|j                  d   dz  
      j                  ||      }t        |j                  |j                  dj                  |              t        |j                  |      |j                  |              |dd      j                  ||      } |dd      j                  ||      }t        |j                  |j                  dj                  |              t        |j                  |      |j                  |             y )Nr`   ra   r   r9   rM   )rX   r   r   r  rD   )rX   r   r  )rX   r  r<   r   )	r7   r$  r   r   r   rq   r'   r   r   )	r  r  r6  r   r`   r  ra   r|   r}   s	            r   test_sparse_parametersr  s  s9    i(M#AQH#A 	11BFFq!LA11BFFxQRSA		?FFyQ
 aiilAIIaL9 	11KOOPQSTUA11KOO!	A 		?FFyQ
 aiilAIIaL9 	1x~~a7HA7MNRRSTVWXA1x~~a7HA7MNRR!	A 		?FFyQ
 aiilAIIaL9 	1Q7;;AqAA1Q7;;HaHA		?FFyQ
 aiilAIIaL9r   ztree_type, criterionc                 v   t         |    }t        |   d   } ||      }t        |   d   } |dd|      j                  ||      } |dd|      j                  ||      }	t        |j                  |	j                  dj                  |              t        |	j                  |      |j                  |             y )Nr`   ra   r   r<   rX   r   r   r  )r7   r$  r   r   r   rq   r'   r   )
r  r  r6  r   r   r`   r  ra   r|   r}   s
             r   test_sparse_criteriar    s     i(M#AQH#A1YGKKAqQA1YGKKHVWXA		?FFyQ
 aiilAIIaL9r   zcsc_container,csr_containerc                    t         |    }d}d}|}t        j                  |      }t        d      }g }	g }
d}|g}t	        |      D ]x  }|j                  |d      }|j                  |      d | }|	j                  |       |j                  dd|f      dz
  }|
j                  |       ||z  }|j                  |       z t        j                  |	      j                  t        j                        }	t        j                  |t        j                        }t        j                  t        j                  |
      t        j                        }
 ||
|	|f||f      }|j                         } ||
|	|f||f      }|j                         }|j                  dd|f      }|j                         }|j                   d	k(  j#                         dkD  sJ |j                   d	k(  j#                         dkD  sJ  |d|
      j%                  ||      } |d|
      j%                  ||      }t'        |j(                  |j(                  dj+                  t,                     ||f}t/        ||      D ]  \  }}t1        |j(                  j3                  |      |j(                  j3                  |             t1        |j3                  |      |j3                  |             t1        |j3                  |      |j(                  j3                  |             t1        |j(                  j5                  |      j                         |j(                  j5                  |      j                                t1        |j5                  |      j                         |j5                  |      j                                t1        |j5                  |      j                         |j(                  j5                  |      j                                t1        |j7                  |      |j7                  |             t,        t8        v st1        |j;                  |      |j;                  |              y )Nr<   rD   r   rK   r\   r9   r  r   rT   r  r  )r7   rt   r   r0   rH  binomialpermutationappendconcatenater%  int32r   r&  toarrayr  copyr   ry   r   r   r   rq   r	   r   r'   r  decision_pathr   r   r   )r  r6  r  r   r   rZ   rY   samplesrX   r   r   offsetindptrin_nonzero_i	indices_idata_ir  r`   r  X_testra   r|   r}   XsX1r  s                              r   test_explicit_sparse_zerosr    s   
 i(MIJ Iii	"G &a(LGDFXF: "++Is; ,,W5l{C	y!&&q#[N&CaGF+f nnW%,,RXX6GXXfBHH-F88BNN4(

;DdGV4Y
<STHA!	w	:'>M ""$FQ5A "&&(M MMS %%'!+++#%**,q000 	1	:>>q!DA1	:>>xKA		?FFtL -	 B"b/ PB!!''--"3QWW]]25FG!!''"+qwwr{;!!''"+qww}}R/@A!GG!!"%--/1F1Fr1J1R1R1T	
 	"OOB'')1??2+>+F+F+H	
 	"OOB'')177+@+@+D+L+L+N	
 	"!))B-2?9%aoob&91??2;NO%Pr   c                    t         |    }t        j                  d d df   j                         }t        j                  d d df   j	                  d      }t        j
                  }t        j                  t              5   |d      j                  ||       d d d         |d      }|j                  ||       t        j                  t              5  |j                  |g       d d d        y # 1 sw Y   YxY w# 1 sw Y   y xY w)Nr   r  r   )r7   rb   r   r   r  r   r   r   r   r   r   )r   r   r`   X_2dra   r   s         r   check_raise_error_on_1d_inputr    s    dOM		!Q$A99QT?""7+DA	z	" 01%))!Q/0 Q
'CGGD!	z	" QC 0 0
 s   >C0C<0C9<Dc                 X    t               5  t        |        d d d        y # 1 sw Y   y xY wN)r*   r  r4  s    r   test_1d_inputr   "  s%    		 ,%d+, , ,s    )r+  c                 Z   t         |    }t        j                  dgdgdgdgdgg      }g d}g d}| ||      } |d      }|j                  |||       |j                  j
                  dk(  sJ  |dd      }|j                  |||       |j                  j
                  dk(  sJ y )	Nr   r9   )r   r   r   r   r9   )r>   r>   r>   r>   r>   r   r   g?)rX   r"  )r7   rt   r   r   r   r   )r   r+  r   r`   ra   r   r   s          r    test_min_weight_leaf_split_levelr  (  s     dOM
1#sQC!qc*+AA-M#Q
Q
'CGGAqG.99!###
Q
ECGGAqG.99!###r   c                     t         j                  t        j                  j                  d      }t        |           }|j                  t         t               t        |j                  t               |j                  j                  |             y NFr  X_smallr%  r	   r  r  r7   r   y_smallr(   r  r   )r   	X_small32r   s      r   test_public_apply_all_treesr
  <  sX    tzz//e<I
D/
CGGGWsyy)399??9+EFr   r  c                 ,    |t         j                  t        j                  j                  d            }t        |           }|j                  t         t               t        |j                  t               |j                  j                  |             y r  r  )r   r  r	  r   s       r   test_public_apply_sparse_treesr  E  s_     gnnTZZ-=-=EnJKI
D/
CGGGWsyy)399??9+EFr   c                      t         j                  } t         j                  }t        dd      j	                  | |      }|j                  | d d       j                         }t        |g dg dg       y )Nr   r9   r  rM   )r9   r9   r   r9   r   r9   )rb   r   r   r   r   r  r  r(   )r`   ra   r   node_indicators       r   test_decision_path_hardcodedr  O  s[    		AA
 a1
=
A
A!Q
GC&&q!u-557N~	9'=>r   c                    t         j                  }t         j                  }|j                  d   }t        |    } |dd      }|j                  ||       |j                  |      }|j                         }|j                  ||j                  j                  fk(  sJ |j                  |      }t        |      D 	
cg c]  \  }	}
||	|
f    }}	}
t        |t        j                  |             |j                  j                  t         k(  }t        t        j"                  ||      t        j                  |             |j%                  d      j'                         }|j                  j(                  |k  sJ y c c}
}	w )Nr   rM   r  r  r9   axis)rb   r   r   r   r7   r   r  r  r   rp   r  	enumerater'   rt   r   rs   r   r  ry   r<  r   )r   r`   ra   rY   r   r   node_indicator_csrr  leavesr  jleave_indicator
all_leavesr   s                 r   test_decision_pathr  W  s?   		AA
IdOM
Q!
4CGGAqM**1-'//1NIsyy/C/C#DDDD YYq\F8A&8IJ1~ad+JOJorwwY/GH ((I5J
~z*BGG),D
 """*..0I99)+++ Ks   <E=c                     t          |t              }}t        |    }t        j                  t
              5   |d      j                  ||       d d d        y # 1 sw Y   y xY wNr   r   )X_multilabely_multilabelr7   r   r   r  r   )r   r  r`   ra   r   s        r   test_no_sparse_y_supportr  u  sQ     |4qAdOM	y	! 01%))!Q/0 0 0s   AA!c                     t        ddd      } | j                  dgdgdgdgdggg dg d	
       t        | j                  j                  g d       t        | j                  j                  j                  g d       | j                  dgdgdgdgdggg dt        j                  d      
       t        | j                  j                  g d       t        | j                  j                  j                  g d       | j                  dgdgdgdgdggg d       t        | j                  j                  g d       t        | j                  j                  j                  g d       y)aQ	  Check MAE criterion produces correct results on small toy dataset:

    ------------------
    | X | y | weight |
    ------------------
    | 3 | 3 |  0.1   |
    | 5 | 3 |  0.3   |
    | 8 | 4 |  1.0   |
    | 3 | 6 |  0.6   |
    | 5 | 7 |  0.3   |
    ------------------
    |sum wt:|  2.3   |
    ------------------

    Because we are dealing with sample weights, we cannot find the median by
    simply choosing/averaging the centre value(s), instead we consider the
    median where 50% of the cumulative weight is found (in a y sorted data set)
    . Therefore with regards to this test data, the cumulative weight is >= 50%
    when y = 4.  Therefore:
    Median = 4

    For all the samples, we can get the total error by summing:
    Absolute(Median - y) * weight

    I.e., total error = (Absolute(4 - 3) * 0.1)
                      + (Absolute(4 - 3) * 0.3)
                      + (Absolute(4 - 4) * 1.0)
                      + (Absolute(4 - 6) * 0.6)
                      + (Absolute(4 - 7) * 0.3)
                      = 2.5

    Impurity = Total error / total weight
             = 2.5 / 2.3
             = 1.08695652173913
             ------------------

    From this root node, the next best split is between X values of 3 and 5.
    Thus, we have left and right child nodes:

    LEFT                    RIGHT
    ------------------      ------------------
    | X | y | weight |      | X | y | weight |
    ------------------      ------------------
    | 3 | 3 |  0.1   |      | 5 | 3 |  0.3   |
    | 3 | 6 |  0.6   |      | 8 | 4 |  1.0   |
    ------------------      | 5 | 7 |  0.3   |
    |sum wt:|  0.7   |      ------------------
    ------------------      |sum wt:|  1.6   |
                            ------------------

    Impurity is found in the same way:
    Left node Median = 6
    Total error = (Absolute(6 - 3) * 0.1)
                + (Absolute(6 - 6) * 0.6)
                = 0.3

    Left Impurity = Total error / total weight
            = 0.3 / 0.7
            = 0.428571428571429
            -------------------

    Likewise for Right node:
    Right node Median = 4
    Total error = (Absolute(4 - 3) * 0.3)
                + (Absolute(4 - 4) * 1.0)
                + (Absolute(4 - 7) * 0.3)
                = 1.2

    Right Impurity = Total error / total weight
            = 1.2 / 1.6
            = 0.75
            ------
    r   r4   rM   )rX   r   r   r<   r;   rL   )rJ   r  r<   r8   r<   )333333?333333?r   rO   r"  )r`   ra   r   )g,d?gܶm۶m?g?)      @g      @r#  )ffffff?rN   gUUUUUU?)r8   rU   r#  r_   N)
r   r   r   r   rz   r(   r{   r  rt   r   )dt_maes    r   test_maer&    s0   T #"21F
 JJ3aS1#s
#
/  
 FLL))+LMv||))..@ JJ1#sQC!qc*oRWWUVZJXv||,,.CDv||))..>
 JJ1#sQC!qc*oJ>v||,,.CDv||))..>r   c                     d} t        j                  dt         j                        }d}d }t        j                  t        j                  |fD ]  }t        j                         D ]G  \  }} || |      } ||      j                         }|\  }	\  }
}}||	k(  sJ | |
k(  sJ t        ||       I t        j                         D ]B  \  }} || |      } ||      j                         }|\  }	\  }
}}||	k(  sJ | |
k(  sJ ||k(  rBJ   y )Nr<   r  rD  c                 R    t        j                  t        j                  |             S r  )rd  rf  re  )objs    r   _pickle_copyz)test_criterion_copy.<locals>._pickle_copy  s    ||FLL-..r   )
rt   r   intpr  deepcopyr   r   
__reduce__r(   r   )	n_outputsrb  rY   r*  	copy_func_typenamecriteriaresult	typename_
n_outputs_rw  
n_samples_s                r   test_criterion_copyr7    s1    I		!277+II/ ii= +	'--/ 	6KAx	95Hx(335F5;2I/
Jy(((
***y*5	6 (--/ 	+KAx	95Hx(335F5;2I/
Jy(((
***
***	++r   c                    t         j                  j                  d      j                  dd      dz  }t        j                  |j                  d            }|d d d df   }|  | |      }|d d df   }t        d      j                  ||      } |j                  |      }t        t        j                  |j                  j                  t        k(        d         }|j                  |      }t        j                  t        j                  |j                  j                                d   }t#        |      dk(  sJ t#        |      dk(  sJ y )Nr   rD  rI   g*Gr&  r?   r   )rt   r  RandomStater  
nan_to_numr%  r   r   r  setwherer   rs   r   
differenceisfiniterw   r   )	r+  r   r`   ra   r	   terminal_regions	left_leaf
empty_leafinfinite_thresholds	            r   "test_empty_leaf_infinite_thresholdrC    s    99  #))#r2T9D==Y/0DQVA#QQUA a044Q:D!tzz!}BHHTZZ55BCAFGI%%&67J2;;tzz/C/C#D"DEaH!"a'''z?ar   tree_clsc                 b   t         |    } | d   | d   }} |dd      }|j                  ||      }|j                  }|j                  }t	        j
                  t	        j                  |      dk\        sJ t	        j
                  t	        j                  |      dk\        sJ t        ||||       y Nr`   ra   r[   r   rF  r$  cost_complexity_pruning_path
ccp_alphas
impuritiesrt   r   diffassert_pruning_creates_subtreer  rD  r`   ra   r   infopruning_pathrJ  s           r   'test_prune_tree_classifier_are_subtreesrP    s    
 wG3<qA
"1
5C++Aq1D??LJ66"'','1,---66"''*%*+++"8Q<@r   c                 b   t         |    } | d   | d   }} |dd      }|j                  ||      }|j                  }|j                  }t	        j
                  t	        j                  |      dk\        sJ t	        j
                  t	        j                  |      dk\        sJ t        ||||       y rF  rG  rM  s           r   'test_prune_tree_regression_are_subtreesrR  $  s     wG3<qA
"1
5C++Aq1D??LJ66"'','1,---66"''*%*+++"8Q<@r   c                      t        d      } | j                  dgdggddg       t        dd      }|j                  dgdggddg       t        | j                  |j                         y )Nr   r   r9   rD   )rX   	ccp_alpha)r   r   assert_is_subtreer   )r  r   s     r   test_prune_single_node_treerV  5  s`    !q1DHHqcA3Z!Q  "qB?DHHqcA3Z!Q djj$**-r   c                     g }|D ].  } | d|d      j                  ||      }|j                  |       0 t        ||dd        D ]%  \  }}t        |j                  |j                         ' y )Nr[   r   )r   rT  rX   r9   )r   r  ziprU  r   )	estimator_clsr`   ra   rO  
estimatorsrT  r   prev_estnext_ests	            r   rL  rL  A  sz    J! 	2QRSWWq
 	#	 "*jn= :((..(..9:r   c                 >   | j                   |j                   k\  sJ | j                  |j                  k\  sJ | j                  }| j                  }|j                  }|j                  }dg}|r1|j	                         \  }}t        | j                  |   |j                  |          t        | j                  |   |j                  |          t        | j                  |   |j                  |          t        | j                  |   |j                  |          ||   ||   k(  rt        t        |j                  |          nXt        | j                  |   |j                  |          |j                  ||   ||   f       |j                  ||   ||   f       |r0y y )N)r   r   )rp   r   rs   rr   popr'   r{   r&   rz   rx   rI  r   rw   r  )	r	   subtreetree_c_lefttree_c_rightsubtree_c_leftsubtree_c_rightstacktree_node_idxsubtree_node_idxs	            r   rU  rU  P  s   ??g00000>>W.....$$K&&L**N,,OHE
*/))+''!JJ}%w}}5E'F	
 	MM-('*:*:;K*L	
 	.0F0FGW0X	
 	((7++,<=	

 *+?O/PP0A0ABR0ST  }-w/@/@AQ/R LL+m4nEU6VWXLLm,o>N.OP3 r   r  r  r  c                 8   t         d   }|d   j                  t        j                  j                  d      }|t        |      }n ||d         }t        j                  |j                  t        j                  j                        |_        t        |j                  |j                  |j                  f      \  |_        |_	        |_
        t        t        j                  t        t        j                  j                              }t        |    |      }|j                  ||       t        |j                  |      |j                  |             t        |j!                  |      j#                         |j!                  |      j#                                y )Nrf   r`   Fr  r  )r  )r$  r%  r	   r  r  r)   rt   r   r   r   r  r  r7   r   r(   r   r  todense)r   r  r+  r  r  
X_readonly
y_readonlyr   s           r   "test_apply_path_readonly_all_treesrk  x  s7    {#Gcl!!$**"2"2!?G.w7
%gcl3
((:??$**:J:JK

 &__j00*2C2CD
		
O
 +288G4::CSCS+TUJ
D/8
,CGGJ
#s{{:.G0DE*%--/1B1B71K1S1S1Ur   )r3   r5   r6   c                    t         j                  t         j                  }} ||       }|j                  ||       t	        j
                  |j                  |            t        j                  t	        j
                  |            k(  sJ y )Nr   )	rc   r   r   r   rt   ry   r   r   r   )r   r$   r`   ra   r   s        r   test_balance_propertyrm    s\     ==(//qA

#CGGAqM66#++a.!V]]266!9%====r   seedc           	         ddgddgddgddgddgddgddgddgg}g d}t        d|       }|j                  ||       t        j                  |j	                  |            dk(  sJ t        d|       }|j                  ||       t        j
                  |j	                  |      dkD        sJ d	}t        j                  |dz  dz  d
d||dz  dz  |       \  }}d|d|k  |dk  z  <   t        j                  |      }t        d|       }|j                  ||       t        j
                  |j	                  |      dkD        sJ y )Nr   r9   rM   r<   )r   r   r   r   r9   rM   r<   r8   r3   r   r6   rD   r!  r  )effective_ranktail_strengthrY   rZ   r   rX   r?   )	r   r   rt   aminr   r   r   make_regressionr   )rn  r`   ra   r   rZ   s        r   test_poisson_zero_nodesrt    sN    Q!Q!Q!Q!Q!Q!Q!QHA A  /
MCGGAqM773;;q>"a'''
)$
GCGGAqM66#++a.1$%%% J##!A~* 1n)DAq ArAv!a%
q	A
)$
GCGGAqM66#++a.1$%%%r   c            	      0   t         j                  j                  d      } d\  }}}t        j                  ||z   ||       }| j                  dd|      t        j                  |d      z  }| j                  t        j                  ||z        	      }t        |||| 
      \  }}}	}
t        dd|       }t        dd|       }|j                  ||	       |j                  ||	       t        d      j                  ||	      }||	df||
dffD ]  \  }}}t        ||j                  |            }t        |t        j                  |j                  |      dd             }t        ||j                  |            }|dk(  r
|d|z  k  sJ |d|z  k  rJ  y )Nr   )  rv  rD   rY   rZ   rX   rB   rM   )lowhighr]   r   r  )lam)	test_sizerX   r6   rD   )r   r  rX   r3   mean)strategytraintestgV瞯<rK   g      ?)rt   r  r9  r   make_low_rank_matrixuniformr<  r6   r   r   r   r   r
   r   r   clip)r'  n_trainn_testrZ   r`   coefra   X_trainr  r   r   tree_poitree_msedummyval
metric_poi
metric_msemetric_dummys                     r   test_poisson_vs_mser    s   
 ))


#C".GVZ%%F"z	A
 ;;2AJ;7"&&:KKDq4x()A'7	1S($GVWf %rH %!RcH LL'"LL'"F+//AE1FFF3KL 
0	1c*1h.>.>q.AB
*1bggh6F6Fq6I5RV.WX
,Qa0@A &=j 0000D<////
0r   rb  c                 N   d\  }}t        j                  ||||dd      \  }} | dd      j                  ||      } | dd      j                  ||      }t        |j                  |j                  | d	       t        |j                  |      |j                  |             y
)z3Test that criterion=entropy gives same as log_loss.)r  r;   r   r   )rb  rY   rZ   r   r   rX   r2   +   r   entropyz> with criterion 'entropy' and 'log_loss' gave different trees.N)r   r   r   r   r   r   r   )r$   rb  rY   rZ   r`   ra   tree_log_losstree_entropys           r   'test_criterion_entropy_same_as_log_lossr    s     "Iz'' DAq :B?CCAqIM)"=AA!QGL(PQ
 M))!,l.B.B1.EFr   c                  6   t        j                  d      \  } }t        dd      j                  | |       j	                  | |      }d fd}t        j                   |             }|j	                  | |      }t        j                  ||      sJ y )Nr   r   r<   r  c                     | j                         j                  | j                  j                               j	                         S r  )byteswapviewr  newbyteorderr-  )arrs    r   reduce_ndarrayz8test_different_endianness_pickle.<locals>.reduce_ndarray  s/    ||~""399#9#9#;<GGIIr   c                     t        j                         } t        j                  |       }t        j
                  j                         |_        |j
                  t        j                  <   |j                         | j                  d       | S Nr   )ioBytesIOrd  Picklercopyregdispatch_tabler  rt   ndarraydumpseek)fpr   r  s     r    get_pickle_non_native_endiannesszJtest_different_endianness_pickle.<locals>.get_pickle_non_native_endianness  sb    JJLNN1"11668'5$	s	q	r   )	r   r   r   r   r   rd  loadrt   isclose)r`   ra   r   r  new_clf	new_scorer   r  s         @@r    test_different_endianness_pickler    s    ''Q7DAq
 a1
=CGGAqMIIaOEJ kk:<=Ga#I::eY'''r   c                  N   t        j                  d      \  } }t        dd      j                  | |       j	                  | |      } G d dt
              fd}t        j                   |             }|j	                  | |      }t        j                  ||      sJ y )Nr   r   r<   r  c                        e Zd Z fdZ xZS )Ptest_different_endianness_joblib_pickle.<locals>.NonNativeEndiannessNumpyPicklerc                     t        |t        j                        r7|j                         j	                  |j
                  j                               }t        | !  |       y r  )	
isinstancert   r  r  r  r  r  supersave)selfr)  rh  s     r   r  zUtest_different_endianness_joblib_pickle.<locals>.NonNativeEndiannessNumpyPickler.save(  s@    #rzz*lln))#))*@*@*BCGLr   )__name__
__module____qualname__r  __classcell__)rh  s   @r   NonNativeEndiannessNumpyPicklerr  '  s    	 	r   r  c                      t        j                         }  |       }|j                         | j                  d       | S r  )r  r  r  r  )r  r  r  r   s     r   'get_joblib_pickle_non_native_endiannesszXtest_different_endianness_joblib_pickle.<locals>.get_joblib_pickle_non_native_endianness-  s3    JJL+A.	s	q	r   )
r   r   r   r   r   r   joblibr  rt   r  )r`   ra   r   r  r  r  r  r   s         @@r   'test_different_endianness_joblib_pickler     s    ''Q7DAq
 a1
=CGGAqMIIaOE,  kkACDGa#I::eY'''r   c                    t         rt        j                  nt        j                  }g d}| j                  j
                  j                         D ci c]  \  }\  }}|| }}}}|D ]  }|||<   	 t        j                  t        |j                               t        |j                               d      }| j                  |d      S c c}}}w )N)
left_childright_childrv   rx   namesformats	same_kindcasting)r,   rt   int64r  r  fieldsr   listr  valuesr%  )node_ndarraynew_dtype_for_indexing_fieldsindexing_field_namesr   r  r0  new_dtype_dict	new_dtypes           r   "get_different_bitness_node_ndarrayr  :  s    09BHHrxx! V -9,>,>,E,E,K,K,M (juaeN  % =<t= ~**,-$~?T?T?V:WXI y+>>s   Cc                    | j                   j                  j                         D ci c]  \  }\  }}|| }}}}| j                   j                  j                         D cg c]  \  }}|	 }}}|D cg c]  }d|z   	 }}t	        j                   t        |j                               t        |j                               |d      }| j                  |d      S c c}}}w c c}}w c c}w )NrL   )r  r  offsetsr  r  )r  r  r   r  rt   r  r  r%  )	r  r   r  r0  r  r  r  shifted_offsetsr  s	            r   $get_different_alignment_node_ndarrayr  L  s    ,8,>,>,E,E,K,K,M (juaeN  ,8+=+=+D+D+K+K+MN-%vNGN078fq6z8O8.--/0N1134&	
I y+>> O8s   C$C&7C,c                     t         rt        j                  nt        j                  } | j                         \  }\  }}}}|j                  |d      }|j                         }t        |d         |d<   ||||f|fS )Nr  r  nodes)r,   rt   r  r  r-  r%  r  r  )	r	   r  rD  rZ   rb  r.  statenew_n_classes	new_states	            r   "reduce_tree_with_different_bitnessr  ]  sw    %288I:I$//:K7H0z9i%$$Y$DM

I;Ig<NOIgz=)<iHHr   c                  0   t        j                  d      \  } }t        dd      j                  | |       j	                  | |      }fd}t        j                   |             }|j	                  | |      }|t        j                  |      k(  sJ y )Nr   r   r<   r  c                     t        j                         } t        j                  |       }t        j
                  j                         |_        t        |j
                  t        <   |j                         | j                  d       | S r  )r  r  rd  r  r  r  r  r  
CythonTreer  r  r  r  r   s     r   "pickle_dump_with_different_bitnesszItest_different_bitness_pickle.<locals>.pickle_dump_with_different_bitnesso  s^    JJLNN1"11668'I$	s	q	r   )	r   r   r   r   r   rd  r  r   r   )r`   ra   r   r  r  r  r   s         @r   test_different_bitness_pickler  h  s    ''Q7DAq
 a1
=CGGAqMIIaOE kk<>?Ga#IFMM),,,,r   c                  0   t        j                  d      \  } }t        dd      j                  | |       j	                  | |      }fd}t        j                   |             }|j	                  | |      }|t        j                  |      k(  sJ y )Nr   r   r<   r  c                      t        j                         } t        |       }t        j                  j                         |_        t        |j                  t        <   |j                         | j                  d       | S r  )
r  r  r   r  r  r  r  r  r  r  r  s     r   "joblib_dump_with_different_bitnesszPtest_different_bitness_joblib_pickle.<locals>.joblib_dump_with_different_bitness  sY    JJLO"11668'I$	s	q	r   )	r   r   r   r   r   r  r  r   r   )r`   ra   r   r  r  r  r   s         @r   $test_different_bitness_joblib_pickler  ~  s     ''Q7DAq
 a1
=CGGAqMIIaOE kk<>?Ga#IFMM),,,,r   c                  L   t         r#t        j                  t        j                        n"t        j                  t        j                        } t        j                  t        j                        t        j                  t        j                        g}||D cg c]  }|j                          c}z  }t        j                  ddg|       }|D ]  }t        |j                  |      |         t        j                  t        d      5  t        j                  ddgg|       }t        ||        d d d        t        j                  t        d      5  |j                  t        j                        }t        ||        d d d        y c c}w # 1 sw Y   ^xY w# 1 sw Y   y xY w)Nr   r9   r  zWrong dimensions.+n_classesr  zn_classes.+incompatible dtype)r,   rt   r  r  r  r  r   r!   r%  r   r   r   r  )expected_dtypeallowed_dtypesdtrb  wrong_dim_n_classeswrong_dtype_n_classess         r   test_check_n_classesr    s;   +4RXXbhh'"((288:LNhhrxx("((288*<=N>BRr(BBN!Q~6I ?))"-~>? 
z)F	G > hhAx~F,n=> 
z)H	I @ ) 0 0 <.?@ @ C> >@ @s   F	
'F,FFF#c                     t        j                  t         j                        } d}t        j                  ||       }| | j	                         g}|D ]  }t        |||        t        j                  t        d      5  t        || d       d d d        |d d d d d df   t        j                  |      fD ]>  }t        j                  t        d      5  t        || |j                         d d d        @ t        j                  t        d	      5  t        |j                  t         j                        | |       d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   y xY w)
N)r;   r9   rM   r  )r  expected_shapezWrong shape.+value arrayr  )r9   rM   r9   zvalue array.+C-contiguouszvalue array.+incompatible dtype)rt   r  r  rl   r  r#   r   r   r   r  r   r%  r&  )r  r  value_ndarrayr  r  problematic_arrs         r   test_check_value_ndarrayr    sJ   XXbjj)NNHH^>BM$n&A&A&CDN 
"^	


 
z)C	D 
.	


 *!Q(3R5F5F}5UV ]]:-HI 	 -.44	 	 
z)J	K 
  ,))	

 

 
	 	
 
s$   ?E
E,E"
EE	"E+c                     t         } t        j                  d|       }|t        |      t	        |      g}||D cg c]+  }|j                  |j                  j                               - c}z  }|D ]  }t        ||         t        j                  t        d      5  t        j                  d|       }t        ||        d d d        t        j                  t        d      5  |d d d   }t        ||        d d d        |j                  j                  j                         D ci c]  \  }\  }}|| }}}}|j                         }	t        j                  |	d	<   t        j                  t!        |	j#                               t!        |	j%                               d
      }
|j                  |
      }t        j                  t        d      5  t        ||        d d d        |j                         }	t        j&                  |	d<   t        j                  t!        |	j#                               t!        |	j%                               d
      }
|j                  |
      }t        j                  t        d      5  t        ||        d d d        y c c}w # 1 sw Y   xY w# 1 sw Y   xY wc c}}}w # 1 sw Y   xY w# 1 sw Y   y xY w)N)r;   r  )r  zWrong dimensions.+node arrayr  )r;   rM   znode array.+C-contiguousrM   rw   r  znode array.+incompatible dtyper  )r   rt   rl   r  r  r%  r  r  r"   r   r   r   r  r   r  r  r  r  r  r  )r  r  valid_node_ndarraysr  problematic_node_ndarrayr   r  r0  
dtype_dictr  r  s              r   test_check_node_ndarrayr    s   N88D7L 	*<8,\:
 8K14

399))+,  # ILHI 
z)G	H U#%88F.#I 4^TU 
z)C	D U#/!#4 4^TU 7C6H6H6O6O6U6U6WXX"2$
$+XJX  __&N"$((N;~**,-$~?T?T?V:WXI  ,229=	z)I	J U4^TU  __&N#%::N< ~**,-$~?T?T?V:WXI  ,229=	z)I	J U4^TU UMU UU U YU UU Us;   0J%J&J),J6J= K	J&)J3=K	KSplitterc                 d   t         j                  j                  d      }d}dt        j                  ddgt         j                        }}t        d   ||      } | ||dd|d	
      }t        j                  |      }t        j                  |      }|j                  |k(  sJ t        ||       sJ y	)z&Check that splitters are serializable.r   rD   rM   r<   r  r1   r;   rK   N)monotonic_cst)rt   r  r9  r   r+  r   rd  re  rf  r   r  )	r  r'  r   r.  rb  r   r  splitter_serializesplitter_backs	            r   test_splitter_serializabler   	  s    
 ))


#CLbhh1vRWW=yIV$Y	:I	<CDQHh/LL!34M%%555mX...r   c                     t        | j                  d            }t        d      }|j                  t        t
               t        j                  ||       t        j                  |d      }t        |j                  |j                  d       y)zhCheck that Trees can be deserialized with read only buffers.

    Non-regression test for gh-25584.
    z
clf.joblibr   r   r)	mmap_modez?The trees of the original and loaded classifiers are not equal.N)strjoinr   r   r  r  r  r  r  r   r   )tmpdirpickle_pathr   
loaded_clfs       r   /test_tree_deserialization_from_read_only_bufferr  	  sh    
 fkk,/0K
 a
0CGGGW
KK[![C8J		Ir   c                 6   t        j                  ddgddgg      }t        j                  ddg      } | d      j                  ||        | d      }d}t        j                  t
        |      5   |j                  ||       ddd       y# 1 sw Y   yxY w)zhCheck that an error is raised when min_sample_split=1.

    non-regression test for issue gh-25481.
    r   r9   rO   )r  zb'min_samples_split' .* must be an int in the range \[2, inf\) or a float in the range \(0.0, 1.0\]r  N)rt   r   r   r   r   r   )r$   r`   ra   r	   msgs        r   test_min_sample_split_1_errorr  %	  s     	1a&1a&!"A
!QA 	3##Aq) !$D	0  
z	- A  s   2BBc                    t        j                  g dg      j                  }t        j                  g d      }t        dd|       }|j	                  ||       |j                  t         j                  gg      }t        |t        j                  |dd       g       |dd }|dd }t        dd|       }|j	                  ||       |j                  t         j                  gg      }t        |t        j                  |d	d       g       y)
z=Check missing values goes to correct node during predictions.	r   r9   rM   r<   rL   r  rI      r   	r   r>   r"  r>   r$  r$  rN   g?g@r   r9   r  r=   Nr?   r:   )	rt   r   r   r   r   r   nanr   r|  )r   r`   ra   dtcr  X_equaly_equals          r   ;test_missing_values_best_splitter_on_equal_nodes_no_missingr  ;	  s     	01244A
>?A
R1	
RCGGAqM [[266($FFRWWQrsV_-. fGfG
R1	
RCGGGW [[266($FFRWWWRS\234r   c                 p   t        j                  g dg      j                  }t        j                  g d      }t        |d|       }|j	                  ||       |j
                  j                  d   }|j
                  j                  d   }|j
                  j                  |   }|j
                  j                  |   }||kD  }	|j
                  j                  |   d   }
|j
                  j                  |   d   }|j                  t         j                  gg      }|	rt        |
|       yt        ||       y)zCheck missing values go to the correct node during predictions for ExtraTree.

    Since ETC use random splits, we use different seeds to verify that the
    left/right node is chosen correctly when the splits occur.
    r
  r  r9   r  r   N)rt   r   r   r   r   r   rs   rr   rI  r{   r   r  r   )r   rn  r`   ra   etrr  r  left_samplesright_samples	went_lefty_pred_lefty_pred_rightr  s                r   =test_missing_values_random_splitter_on_equal_nodes_no_missingr  U	  s    	01244A
>?A
$!y
QCGGAqM ((+J))**1-K 9944Z@LII55kBM},I ))//*-a0K99??;/2L [[266($FV,f-r   r  r1   c                    d}t        j                  t         j                  gdz  g dz   g      j                  }t        j                  |gdz  dgdz  z   dgdz  z         }t	        dd|       }|j                  ||       t        j                  t         j                  dd	gg      j                  }|j                  |      }t        ||ddg       y
)zITest when missing values are uniquely present in a class among 3 classes.r   r8   )r   r9   rM   r<   rL   r  rI   r  r9   rM   r   r  r<   r  Nrt   r   r  r   r   r   r   r(   )r   missing_values_classr`   ra   r  r  
y_nan_preds          r   /test_missing_values_best_splitter_three_classesr  x	  s     
266(Q,!;;<=??A
&'!+qcAg5a?@A
 bA
SCGGAqMXX2'(**FV$Jz$8!Q#?@r   c                    t        j                  t         j                  gdz  g dz   g      j                  }t        j                  dgdz  dgdz  z         }t	        dd|       }|j                  ||       t        j                  t         j                  d	t         j                  gg      j                  }|j                  |      }t        |g d
       y)zMissing values spanning only one class at fit-time must make missing
    values at predict-time be classified has belonging to this class.r8   r   r9   rM   r<   r8   r;   r   r9   rJ   r   rM   r  r;   )r   r9   r   Nr  r   r`   ra   r  r  r  s         r   )test_missing_values_best_splitter_to_leftr"  	  s     	266(Q,!334577A
!qA37"#A
 bA
SCGGAqMXX266*+,..F[[ Fvy)r   c                    t        j                  t         j                  gdz  g dz   g      j                  }t        j                  dgdz  dgdz  z   dgdz  z         }t	        dd|       }|j                  ||       t        j                  t         j                  dd	gg      j                  }|j                  |      }t        |g d
       y)zMissing values and non-missing values sharing one class at fit-time
    must make missing values at predict-time be classified has belonging
    to this class.r8   r   r9   r   rM   r   r  rP   g333333@r  Nr  r!  s         r   *test_missing_values_best_splitter_to_rightr$  	  s    
 	266(Q,!334577A
!qA37"aS1W,-A
 bA
SCGGAqMXXS)*+--F[[ Fvy)r   c                    t        j                  ddddt         j                  ddddt         j                  g
g      j                  }t        j                  d	gdz  dgdz  z         }t	        d
d|       }|j                  ||       t        j                  t         j                  ddgg      j                  }|j                  |      }t        |g d       y)zNCheck behavior of missing value when there is one missing value in each class.r9   rM   r<   r;   rD   r[   rW   r   r   r   r  gffffff@gA@r  Nr  r!  s         r   >test_missing_values_best_splitter_missing_both_classes_has_nanr&  	  s     	1aArvvr2r2rvv>?@BBA
!qA37"#A
 bA
SCGGAqMXXT*+,..F[[ F vy)r   r	   r   c                 j   t        j                  ddddt         j                  ddddt         j                  g
g      j                  }t        j                  d	gdz  dgdz  z         }|  | |      }t	        j
                  t        d      5   |j                  ||       d
d
d
       y
# 1 sw Y   y
xY w)z4Check unsupported configurations for missing values.r9   rM   r<   r;   rD   r[   rW   r   r   NzInput X contains NaNr  )rt   r   r  r   r   r   r   r   )r+  r	   r`   ra   s       r   test_missing_value_errorsr(  	  s     	1aArvvr2r2rvv>?@BBA
!qA37"#A#Q	z)?	@ A  s   B))B2c                 D   t         j                  j                         t         j                  }}t        j
                  |ddddf<   t        j
                  |ddddf<    | dd      }|j                  ||       |j                  |      }|d	k\  j                         sJ y)
z5Smoke test for poisson regression and missing values.Nr;   r   rJ   r?   r6   r   r   rT   )	rc   r   r  r   rt   r  r   r   r   )r$   r`   ra   r   r  s        r   test_missing_values_poissonr*  	  s     ==qA Acc1fIAcc2gJ

4CGGAqM[[^FcM   r   c                  D    t        j                  | i |\  }}|dkD  }||fS )N   )r   make_friedman1)argskwargsr`   ra   s       r   make_friedman1_classificationr0  	  s-    ""D3F3DAq	BAa4Kr   zmake_data, Tree, tolerancegQ?gQ?gQ?sample_weight_trainr   c                 ~   d\  }} | ||d|      \  }}|j                         }	t        j                  j                  |      }
t        j                  |	|
j                  ddg|j                  ddg      <   t        |	||	      \  }}}}|d
k(  r#t        j                  |j                  d         }nd}d} |||      }|j                  |||       |j                  ||      }t        t                |||            }|j                  ||       |j                  ||      }||z   |kD  sJ d|d| d|        y)zFCheck that trees can deal with missing values have decent performance.)r   rD   rO   )rY   rZ   noiserX   FTrV   r   r]   r  r   r   r   NrD   r   r   zscore_native_tree=z + z! should be strictly greater than )r  rt   r  r9  r  choicer   r   r   r   r   r   r   )	make_datar$   r1  rJ  	tolerancerY   rZ   r`   ra   	X_missingr'  X_missing_trainX_missing_testr   r   r   r   native_treescore_native_treetree_with_imputerscore_tree_with_imputers                        r   !test_missing_values_is_resiliencer?  	  sh   ( &Iz'	DAq I
))

 2
3CGIvvIcjj%QWWc
jCD7G1#584O^Wf f$ 5 5a 89 I9KLKOOOWMOJ#)).&A%	@RS /73/55nfMy(+BB 
c) -#$	&Br   zTree, expected_scoreg333333?g(\?c                 H   t         j                  j                  d      }d}|j                  |df      }t        j                  t        j
                  |dz        t        j                  |dz        g      }|j                  ddg|dd	g
      }|j                         j                  t              }||    ||<   |j                  |      }	t         j                  |	|<   |	|dddf<    | |      }
t        |
||d      j                         }||k\  sJ d| d|        y)z@Check the tree learns when only the missing value is predictive.r   rv  r[   r\   rM   FTgffffff?rQ   r4  Nr;   r   )cvzExpected CV score: z	 but got )rt   r  r9  standard_normalr  rl   r   r5  r  r%  boolr  r   r|  )r$   expected_scorerJ  r'  rY   r`   ra   X_random_masky_maskX_predictiver	   tree_cv_scores               r    test_missing_value_is_predictiverI   
  s!    ))


"CI)R1A
a0"'')q.2IJKA JJt}9tJMMVVX__T"F#M22F=&&I&6L66LAadG/0D $D!Q15::<M'F	^,Im_EF'r   zmake_data, Treec                    t         j                  j                  d      }d\  }} | |||      \  }}t         j                  ||j	                  ddg|j
                  ddg      <   t        j                  |j
                  d         }d	|d
d
d<    |d      }|j                  |||        |d      }	|	j                  |dd
dd
d
f   |dd
d          t        |	j                  |      |j                  |             y
)z=Check sample weight is correctly handled with missing values.r   )r  rD   rw  FTrV   r   r4  rT   NrM   r   r   r9   )
rt   r  r9  r  r5  r   r   r   r   r   )
r6  r$   r'  rY   rZ   r`   ra   r   tree_with_swtree_samples_removeds
             r   test_sample_weight_non_uniformrM  >
  s     ))


"C$IzyZcRDAq @BvvAcjj%QWWc
j;< GGAGGAJ'MM#A#Q'LQ7Q/Qqt!tQwZ14a41(003\5I5I!5LMr   c                  F   t        d      j                  t        j                  t        j                        } t        d      j                  t        j                  t        j                        }t        j                  |       }t        j                  |      }||k(  sJ y r  )r   r   rb   r   r   rd  re  )tree1tree2pickle1pickle2s       r   test_deterministic_picklerS  [
  sl     #266tyy$++NE"266tyy$++NEll5!Gll5!Ggr   r`   r;   rJ   c                    |j                  dd      }t        j                  d      } | |d      j                  ||      }t	        |      j                  |j                  dd      |      }|j
                  j                  }t        |dk\        sJ |j                                t        |j
                  j                  dd |j
                  j                  dd        t        j                  |j
                  j                  dk(  |j
                  j                  dk(  z        }t        |j
                  j                  |   d       y)	a'  Check that we properly handle missing values in regression trees using a toy
    dataset.

    The regression targeted by this test was that we were not reinitializing the
    criterion when it comes to the number of missing values. Therefore, the value
    of the critetion (i.e. MSE) was completely wrong.

    This test check that the MSE is null when there is a single sample in the leaf.

    Non-regression test for:
    https://github.com/scikit-learn/scikit-learn/issues/28254
    https://github.com/scikit-learn/scikit-learn/issues/28316
    r?   r9   rJ   r   r   NrM   rT   )r  rt   r   r   r   r   rz   r   r   r   flatnonzerors   rx   )r$   r`   r   ra   r	   tree_refrz   
leaves_idxs           r   'test_regression_tree_missing_values_toyrX  h
  s   6 	
		"aA
		!A)!488A>DT{qyyQ/3Hzz""Hx1}-x||~- DJJ''+X^^-D-DRa-HI 		!	!R	'DJJ,E,E,JKJ DJJ''
3S9r   c                    t         j                  j                  |       }d}t        j                  |t         j                        j                  dd      }t         j                  |dd d d f<   |j                  |       t        j                  |      }t        | d      j                  ||      }|j                  j                  }t        |dk\        sJ |       y )	NrD  r  r?   r9   ir;   r  r   )rt   r  r9  r   r  r  r  r   r   r   r   rz   r   )rJ  r'  rY   r`   ra   r	   rz   s          r   -test_regression_extra_tree_missing_values_toyrZ  
  s    
))

 2
3CI
		)2::.66r1=AAcdAgJKKN
		)A+=KOOPQSTUDzz""Hx1}'x'r   c                  >   t        j                  d      \  } }t        j                  j	                  d      }| j                         }|j                  t        j                  dt        j                        | dddgf   dz  	      j                  t              }t        j                  ||<   t        ||d
      \  }}}}t        j                  g dt        j                        }t        ddd      }	 |	j                  ||   ||          t!        |	j"                  j$                  dk\        sJ t        j&                  |	j"                  j(                  dk(  |	j"                  j*                  dk(  z        }
t-        |	j"                  j$                  |
   d       y)a  Check that we properly handle missing values in clasification trees using a toy
    dataset.

    The test is more involved because we use a case where we detected a regression
    in a random forest. We therefore define the seed and bootstrap indices to detect
    one of the non-frequent regression.

    Here, we check that the impurity is null or positive in the leaves.

    Non-regression test for:
    https://github.com/scikit-learn/scikit-learn/issues/28254
    T)
return_X_yr   )r9   r8   )r   r  NrM   rL   )nr     r   )prM   Q   '   a   [   &   .      e   r^  Y   R   rD  r   E      r_     I   J   3   /   k      K   n   r[   r   h   9      r   rr  O   #   M   Z   rn  rd  r^  ^   rb     rL   ]   r}  rl  ry  r  r^  rm  m   rs     rD   r|  rt  rj  \   4   r[   r~  rL   rL      rj  rx  r  r  r  r  r   rW   re  N   r  r  i   r  r   rl  r  f   r  r^  re  r9   ri  rI       rr  rz  j   r{  r   8   rx  rq  >   U   r_  r`  P   rk  ?   rJ   r  T   r<   r<   L   r  r  r<   r   iHnr   r   r?   r9   rT   )r   	load_irisrt   r  r9  r  r  r   r  r%  rC  r  r   r   r   r   r   r   rz   rU  rs   rx   r   )r`   ra   r'  r8  maskr  r0  r   r   r	   rW  s              r   +test_classification_tree_missing_values_toyr  
  sW    .DAq
))


#CI<<
''bhh
/1QV9q=  fTl 	 ffIdO-iLGQ hh  XXG "&zD DHHWWww/0tzz""a'(((		!	!R	'DJJ,E,E,JKJ DJJ''
3S9r   c                     t        dd      }  | j                  t        j                  t        j                         t        j                  | j                        }t        | j                  || j                        }t        j                  | j                  j                  t
        j                        }d|d<   t        || j                  |       | j                  j                  dk(  sJ |j                  dk(  sJ t!        j"                  t$              5  t'        | j                  j(                  |j(                         ddd       t'        | j                  j(                  d   |j(                  d          t        | j                  || j                        }t        j                  | j                  j                  t
        j                        }d|dd t        || j                  |       | j                  j                  dk(  sJ |j                  dk(  sJ |j                         t'        | j                  j(                  |j(                         y# 1 sw Y   xY w)zHTest pruning a tree with the Python caller of the Cythonized prune tree.r   r9   r  r  r<   N)r   r   rb   r   r   rt   
atleast_1drw  r  n_features_in_r5  rl   r   rp   uint8r    r   r   AssertionErrorr(   r{   r	   rb  pruned_treeleave_in_subtrees       r   test_build_pruned_tree_pyr  
  s   !qA>DDHHTYY$doo.IT00)T__MK xx

 5 5RXXFQ+tzz3CD::  A%%%!!Q&&&	~	& @4::++[->->?@tzz''*K,=,=a,@A T00)T__MKxx

 5 5RXXFQR +tzz3CD::  A%%%!!Q&>(>(>>&tzz''):):;@ @s   +II c                     t        dd      }  | j                  t        j                  t        j                         t        j                  | j                        }t        | j                  || j                        }t        j                  | j                  j                  t
        j                        }d|d<   t        j                   t"        d      5  t%        || j                  |       ddd       y# 1 sw Y   yxY w)z8Test pruning a tree does not result in an infinite loop.r   r9   r  r  z,Node has reached a leaf in the original treer  N)r   r   rb   r   r   rt   r  rw  r  r  r5  rl   r   rp   r  r   r   r   r    r  s       r   $test_build_pruned_tree_infinite_loopr  
  s     "qA>DDHHTYY$doo.IT00)T__MK xx

 5 5RXXFQ	H
 I 	k4::7GHI I Is   C77D c                  :   t         j                  j                  d      } | j                  ddd      j	                  t         j
                        }t        j                  |gdz        }t        j                  d      }t        ||d       g d}t        ||       y	)
zNon-regression test for gh-30554.

    Using log2 and log in sort correctly sorts feature_values, but the tie breaking is
    different which can results in placing samples in a different order.
    rr  rT   g      $@rD   )locscaler]   r;   r  )2r   (   rW   r[   rD      r`     1   r  -   r   rx  r;      rI   re  )   r9         r  rM   r   r  r|  r^  r  r<   !   rJ   $   rd  rk  rv  r8   r,  r  "   ,   rj  ro  r  %   rq  rL   rc  0   r     N)
rt   r  default_rngnormalr%  r&  r  r   r   r(   )r'  somefeature_valuesr  expected_sampless        r   test_sort_log2_buildr    s}     ))


#C::#T:3::2::FD^^TFQJ/NiimG^Wb) w 01r   r  )__doc__r  r  r  rd  r  r  	itertoolsr   r   r  numpyrt   r   joblib.numpy_pickler   numpy.testingr   sklearnr   r   r	   sklearn.dummyr
   sklearn.exceptionsr   sklearn.imputer   sklearn.metricsr   r   r   sklearn.model_selectionr   r   sklearn.pipeliner   sklearn.random_projectionr   sklearn.treer   r   r   r   sklearn.tree._classesr   r   r   r   sklearn.tree._partitionerr   sklearn.tree._treer   r   r   r    r!   r"   r#   r$   r  sklearn.utilsr%   sklearn.utils._testingr&   r'   r(   r)   r*   r+   sklearn.utils.fixesr,   r-   r.   r/   sklearn.utils.validationr0   r   REG_CRITERIONSr   r   dictr7   __annotations__updateSPARSE_TREESr   r  r  y_small_regr`   ra   r   r   r  rb   r  r9  r'  r  r   r]   permr   load_diabetesrc   load_digitsrd   rX   make_multilabel_classificationr  r  r  X_sparse_posr  y_randomr  X_sparse_mixrl   r$  r   r   r   markparametrizer  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r   r0  r5  r:  r=  r@  rB  r^  rn  ru  rz  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  sortedr;  intersectionr  r  r  r  rX  r  r  r   r  r
  r  r  r  r  r&  r7  rC  r  rP  rR  rV  rL  rU  rk  rm  rH  rt  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r"  r$  r&  r(  r*  r0  r-  r?  rI  rs  r   rM  rS  r  rX  rZ  r  r  r  r  )r	   s   0r   <module>r     s     	  	  $    , ) ) ) ( - ( U U E * ;   /   2 /   8%O 5.	 3,	
 &	4  	    	    "((56<94:@>>@74545?@A84544/8 P6 	"XBx"bAq6Aq6Aq6:"X1v1v xiiA
t{{''(IIdO	kk$ "8!!#
x++,d#//$'				
v}}))*kk$d#!!$DXDDbR l
 ###1$'\S  !151$RTJRRT ))$++.mm(//:KKfmm4W-[1$<8$84%H5$84288G$84$N	X	X !1!1!34n5, 6 5,*F*
$ y'89n5J 6 :J y'89,	"0"5	2126	/4	B-r2	 : 
4W 2L>-K<!7H?+DH>FB8
v +1 ,1 ..9W : /W
 &*:
z +G ,G ..9 : /EP0f9%x=(	E*8Z1h30 +,N ,,N^ +	 ,	+$K$(-?"!*&R l3	6 46
 fS->-K-KI-V&WXZ$=>. ? Y. l3$WX.90: : Y 40:f <E4493D$E~	VW
,D$$)2CDnU $WX.9: : Y:" l3!3~~#FHP 4HPV  +, ,,
 ++dVn-DE$ F ,$$ +G ,G ..9G : /G? +, ,,: +.90 : ,0a?H+8 +dVn-DE  F $ vc(--/*k:-FFG &<>Q%RSA TA HMMO4&;=O%PQA R 5A	.:%P +fh%78+dVn-D~-UV W 9 ,4 &RS!1!1!34	> 5 T	> q*& +&B'0T "8:M!NOq!f-G . PG,(2(4?$?"I-,-6@$
B1Uh ,o,,.0G0@0G0G0IJ//& !1!1!34 5* &GH5 I52 q*&GH. I +.B y&&9:A ;A y&&9:* ;* y&&9:* ;*  y&&9:* ;* +dVn-DE
(89%56
 F
 !1!1!34! 5!   
	 	 "7;		 	 "4d;	&(>E	&(;TB .v?' @ 'Z /Y5E5E5G$PT1VWF XF: 		!	!#89		%	%'=>NN,
 "79K!LM 	"&&!RVVQ1-."&&"&&!Q1-.!Q1bffbff-.!Q2661bff-.
 &GH: I
 N:B(,:^<>I$2s* FDs   	~~6	~ ~