
    Ugq                        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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  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-m.Z. ddl/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5 ddl/m6Z7 ddl8m9Z9 ddl:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@ ddlAmBZB ddlCmDZDmEZEmFZFmGZG ddlHmIZI dZJdZKe&e(dZLe'e)dZM eN            ZOeNePd<   eOQ                    eL           eOQ                    eM           g dZR ejS        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          ZTg d3ZUg d4ZVd5d6gd6d6gd6d5gd7d7gd7d8gd8d7ggZWg d9ZXd6d6gd8d8gd:d8ggZYg d;ZZ ej[                    Z\ej]        ^                    d7          Z_e_`                    e\ja        jb                  Zce\jd        ec         e\_d        e\ja        ec         e\_a         eje                    Zfe_`                    efja        jb                  Zcefjd        ec         ef_d        efja        ec         ef_a         ejg                    Zhe_`                    ehja        jb                  Zcehjd        ec         eh_d        ehja        ec         eh_a         eId          Zi ejj        dd<d=>          \  ZkZleim                    d?@          ZndAenendBk    <   eio                    ddCdD@          Zp e$dEd=dFdG          q                                Zre\jd        e\ja        dHefjd        efja        dHehjd        ehja        dHeWeXdHeTeUdHeTeVdHekeldHenepdHen epdHerepdH ejs        dI          epdHdJZtdK ZudL ZvdM Zwejx        y                    dNeMz                                          ejx        y                    dOeK          dP                         Z{dQ Z|dR Z}ejx        y                    dSeM~                                          ejx        y                    dOeK          dT                         Ze@ejx        y                    dSeM~                                          ejx        y                    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jx        y                    dieO          dj             Zejx        y                    dieR          ejx        y                    dkeF          dl                         Z	 ddmZejx        y                    dieO          dn             Zejx        y                    dieR          ejx        y                    dkeF          do                         Zdp Zdq Zdr Zds Zdt Zdu Zdv Zdw Zejx        y                    dieL          dx             Zejx        y                    dieL          dy             Zdz Zd{ Zd| Zd} Zd~ Zd Zd Zd Zd ZddZejx        y                    deR          ejx        y                    dd          d                         Zejx        y                    d e eeR                              eM                              ejx        y                    dddg          d                         Zejx        y                    deR          ejx        y                    dg d          ejx        y                    dkeF          d                                     Zejx        y                    d e ed eRD             eK                     e ed eRD             eJ                    z             ejx        y                    dg d          ejx        y                    dkeF          d                                     Zejx        y                    deR          ejx        y                    d eeFeG                    d                         Ze?d             Zejx        y                    dieO          d             Zejx        y                    dieO          ejx        y                    ddgeFz             d                         Zejx        y                    dieO          d             Zejx        y                    dieR          ejx        y                    deG          d                         Zd Zejx        y                    dieO          d             Zejx        y                    dieO          ejx        y                    deG          d                         Zd Zd Zejx        y                    ddgeFz             d             Zejx        y                    d e eet                                          ddhz
                      ejx        y                    de&e(g          d                         Zejx        y                    det                                          ejx        y                    de'e)g          d                         Zd Zd Zd Zejx        y                    dieO          ejx        y                    dddg          ejx        y                    ddgeFz   eGz             d                                     Zejx        y                    dOg d          ejx        y                    dNeMz                                          d                         Zejx        y                    d ed:                    d             Zd Zejx        y                    dOeK          d             Zejx        y                    dNe&e(g          ejx        y                    dd8dCg          d                         Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zejx        y                    d e e-jz                     e.jz                                        d             Zd Zejx        y                    dNeOz                                          d             Zejx        y                    dOdVdZg          d             Zejx        y                    dOddg          dÄ             Zejx        y                    dOddg          dĄ             Zejx        y                    dOddg          dń             Zejx        y                    dOddg          dƄ             Zejx        y                    ddgeGz             ejx        y                    d e&dȦ           e'dYɦ          g          dʄ                         Zd˄ Zd̄ Zejx        y                    dej        e'fee&fg          ejx        y                    dddg          dЄ                         Zdф Zejx        y                    dej        e'fej        e&fg          dӄ             ZdԄ Zejx        y                    d ejS        ej        d8ej        dCddg           ejS        ej        ej        d:dCddg           ejS        d7d8d:dCej        ej        g           ejS        d7d8d:ej        dej        g          g          ejx        y                    dOdVdZg          d؄                         Zdل ZdS )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)train_test_split)make_pipeline)_sparse_random_matrix)DecisionTreeClassifierDecisionTreeRegressorExtraTreeClassifierExtraTreeRegressor)CRITERIA_CLFCRITERIA_REGDENSE_SPLITTERSSPARSE_SPLITTERS)
NODE_DTYPE	TREE_LEAFTREE_UNDEFINED_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)check_sample_weights_invariance)	_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   r8   r   r   r7   皙?r   r6   r7   )r=   r   r         r   r    @r7   r   r   r>   r   r7   )r=   r=   r   g333333r   r   r   r   r   r   r<   r   r   r7   )r=   r=   r   r   r   r   r   r:   r   r   r   r   r   r7   )r=   r   r6   
   r6   r   皙	r   r6   r:   r8   r7   )zG @r         r      r   r   rC            ?r   rA   r7   )rD   r   rE   rF   r   rG   r   r   rC   rH   r   r   r@   r7   )rD      rE   rF   r   rG   r   r   rC   rH   r   r   r@   r7   )rD   rJ   rE   rF   r   rG   r   r   rC   rH   rI   r   r=   r   )   rJ   r9   r7   rI   r8   rB   r   r7   r;   r:   r   rK   r   )rK   r   r7   r7   r7   r=   r7   r   r   r@   r:   r   r7   r   )rK   r   r7   rK   r:   r=   rB   rK   r   r=   r7   rK   rK   r   )r7   r7   r   rK   rK   r=   r7   rK   r   r;   r7   rK   r:   r   )r:   r7   r   r:   r   r8   rB   r   r7   r;   r:   r   r:   r7   )rD   rJ   rE   rF   r   r7   r   r   rC   rH   rI   r   rA   r7   )rD   rJ   rE   rF   r   r7   r   r   rC   rH         ?r7   r=   r=   )rD   rJ   rE   rF   r   rB   r   r   rC   rH   rI   r   r=   r=   )rK   r   r9   r7   rI   r@   rB   r   r7   r;   r:   r7   r   r=   )rK   r   r7   r7   r7   r@   r7   r   r   r@   r   r   r   r7   )rK   r7   r7   r7   rK   r=   rB   rK   r   r=   r   rK   r7   r7   )r7   r7   r   r   r7   rA   r7   rK   r   r;   r7   rK   r7   r7   )r:   r7   r   r7   r   r8   r7   r   r7   r@   r   r   r7   r   )r7   r7   r   r   r   r   r7   r7   r7   r7   r7   r7   r   r   r   r7   r   r   r7   r   r   r   r   )      ?r?   333333?皙?rB   g333333@@g)\(?{Gz?gףp=
@rP   g?        rN   rK   rG   r   r         @g|?5^?g(\??r   r@   r=   r7   rK   )r=   r=   r=   r7   r7   r7   r:   )r=   r7   r7      rB   )random_state	n_samples
n_features)   r9   sizerR   g?r6   )rY   rY   g      ?)densityrV   Xy)rY   r:   )irisdiabetesdigitstoy	clf_small	reg_small
multilabel
sparse-pos
sparse-neg
sparse-mixzerosc                 4   |j         | j         k    s)J d                    ||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
                                        |dz              t          | j
        |j
        |dz              t          | j        |j        |dz   	           t          | j        |         |j        |         |d
z   	           d S )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        [/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/sklearn/tree/tests/test_tree.pyassert_tree_equalr      s   	$$$188q|  	%$$
 	!*G6P,P   	'4M*M   9,H~h''H		(QYx0'<P2P   	Hq{84g@U6U   		11  
 	!*G6P,P   
AJBV8VWWWW	178,g@Q6Q         c                     t                                           D ]\  } } |d          }|                    t          t                     t          |                    t                    t          d	                    |                       |dd          }|                    t          t                     t          |                    t                    t          d	                    |                      d S )Nr   rV   Failed with {0}r7   )max_featuresrV   )
	CLF_TREESitemsfitr^   r_   r%   predictTtrue_resultro   namer!   clfs      r   test_classification_toyr      s    oo'' X X
dd"""13;;q>>;8I8P8PQU8V8VWWWd22213;;q>>;8I8P8PQU8V8VWWWWX Xr   c            
      ~   t                                           D ]!\  } } |d          }|                    t          t          t          j        t          t                                         t          |	                    t                    t          d                    |                      |                    t          t          t          j        t          t                    d                     t          |	                    t                    t          d                    |                      #d S )Nr   r   sample_weightr   rI   )r   r   r   r^   r_   rr   oneslenr%   r   r   r   ro   fullr   s      r    test_weighted_classification_toyr      s    oo'' X X
dd"""1BGCFFOO4443;;q>>;8I8P8PQU8V8VWWW1BGCFFC$8$89993;;q>>;8I8P8PQU8V8VWWWWX Xr   r!   	criterionc                 >   |dk    rgt          j        t          j        t                              dz   }t          j        t                    |z   }t          j        t
                    |z   }nt          }t
          } | |d          }|                    t          |           t          |	                    t                    |            | |dd          }|                    t          |           t          |	                    t                    |           d S )Nr4   r7   r   rV   r   r   rV   )rr   absminr_   arrayr   r   r^   r   r   r   )r!   r   ay_trainy_testregr   s          r   test_regression_toyr     s     I F26!99!(1++/+&&*
$
3
3
3CGGAwCKKNNF+++
$
C
C
CCGGAwCKKNNF+++++r   c                     t          j        d          } d| d dd df<   d| dd dd f<   t          j        | j                  \  }}t          j        |                                |                                g          j        }|                                 } t                                          D ]\  }} |d          }|	                    ||            |
                    ||           dk    sJ d                    |                       |dd          }|	                    ||            |
                    ||           dk    sJ d                    |                      d S )	N)rB   rB   r7   r9   r   r   rM   r   rV   r   )rr   rj   indicesshapevstackravelr   r   r   r   scorero   )r_   gridxgridyr^   r   r!   r   s          r   test_xorr     sb   
AAbqb"1"fIAabb!""fI:ag&&LE5
	5;;==%++--0113A			Aoo'' F F
dd"""1yyA#%%%'8'?'?'E'E%%%d2221yyA#%%%'8'?'?'E'E%%%%F Fr   c                     t          t                                          t                    D ]0\  \  } }} ||d          }|                    t
          j        t
          j                   t          |	                    t
          j                  t
          j                  }|dk    sJ d
                    | ||                       ||dd          }|                    t
          j        t
          j                   t          |	                    t
          j                  t
          j                  }|dk    sJ d
                    | ||                      2d S )Nr   r   rT   z0Failed with {0}, criterion = {1} and score = {2}rK   r   rI   )r   r   r   CLF_CRITERIONSr   r`   datatargetr   r   ro   )r   r!   r   r   r   s        r   	test_irisr   1  s*   #*9??+<+<n#M#M 
 
tidYQ777	4;'''s{{4955t{CCs{{{NUU)U
 
{{{ dYQQGGG	4;'''s{{4955t{CCs{{{NUU)U
 
{{{{
 
r   z
name, Treec                 8    ||d          }|                     t          j        t          j                   t	          t          j        |                    t          j                            }|t          j        d          k    sJ d|  d| d|             d S )Nr   r   zFailed with z, criterion = z and score = )r   ra   r   r   r   r   pytestapprox)r   r!   r   r   r   s        r   test_diabetes_overfitr   C  s    
 $
3
3
3CGGHM8?+++xHM0J0JKKEFM	    IdII)II%II    r   z&criterion, max_depth, metric, max_lossr1      <   r2   r3   r4   c                      |||dd          }|                     t          j        t          j                    |t          j        |                    t          j                            }d|cxk     r|k     sn J d S )NrH   r   )r   	max_depthr   rV   )r   ra   r   r   r   )r   r!   r   r   metricmax_lossr   losss           r   test_diabetes_underfitr   P  s     $iaVW
X
X
XCGGHM8?+++6(/3;;x}#=#=>>Dthr   c            	      B   t                                           D ]\  } } |ddd          }|                    t          j        t          j                   |                    t          j                  }t          t          j	        |d          t          j
        t          j        j        d                   d                    |                      t          t          j        |d          |                    t          j                  d                    |                      t!          |                    t          j                  t          j        |                    t          j                            dd                    |                      d S )Nr7   *   r   r   rV   r   r   rl   rJ   )r   r   r   r`   r   r   predict_probar$   rr   rw   r   r   ro   r%   argmaxr   r#   exppredict_log_proba)r   r!   r   prob_predicts       r   test_probabilityr   e  sg     oo'' 
 

ddQQR@@@	4;'''((33!F<##GDIOA&''%,,T22	
 	
 	
 	

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

 	di((F3((3344%,,T22		
 	
 	
 	
 	

 
r   c                     t          j        d          d d t           j        f         } t          j        d          }t                                          D ](\  }} |d d          }|                    | |           )d S )Ni'  r   r   rV   )rr   arangenewaxis	REG_TREESr   r   r^   r_   r   r!   r   s        r   test_arrayreprr     s     		%BJ'A
	%Aoo''  
ddT22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                                           D ]_\  }} |d          }|                    | |           t          |                    |           |d                    |          	           `t                                          D ]_\  }} |d          }|                    | |           t          |                    |           |d                    |          	           `d S )
Nr@   r=   r7   rK   )r7   r7   r7   r7   r7   r7   r   r   r   rl   )r   r   r   r%   r   ro   r   r#   )r^   r_   r   TreeClassifierr   TreeRegressorr   s          r   test_pure_setr     s,   
bB8b"X1v1v1v>AA ) 1 1 V Vnn!,,,13;;q>>16G6N6Nt6T6TUUUUU(00 W Wmm+++1CKKNNA7H7O7OPT7U7UVVVVVW 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                                          D ]m\  }} |d          }|                    | |           |                    | |            |                    |  |           |                    |  |            n	 d d d            d S # 1 swxY w Y   d S )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   )rM   gAw?gtQ?5??rR   g7G?gۺ?gb'?raise)allr   r   )rr   r   errstater   r   r   r   s        r   test_numerical_stabilityr     sh   
DDDDDDDDDDDDDDDDDDDDD	

	 
	A 	WWWXXA		!	!	!  #//++ 	 	JD$$A&&&CGGAqMMMGGArNNNGGQBNNNGGQBOOOO	                 s   BC++C/2C/c            	         t          j        ddddddd          \  } }t                                          D ]\  }} |d          }|                    | |           |j        }t          j        |dk              }|j        d         dk    sJ d		                    |                      |dk    sJ d		                    |                      t          d          }|                    t          j        t          j                   t          dt          t          j                  
          }|                    t          j        t          j                   t          |j        |j                   d S )N  rB   r:   r   FrW   rX   n_informativen_redundant
n_repeatedshufflerV   r   皙?r   rV   max_leaf_nodes)r   make_classificationr   r   r   feature_importances_rr   rw   r   ro   r   r`   r   r   r   r%   )r^   r_   r   r!   r   importancesn_importantclf2s           r   test_importancesr     se   '  DAq  oo'' @ @
dd"""1.f[3.// #r)))+<+C+CD+I+I)))a!2!9!9$!?!? !a
0
0
0CGGDIt{###!qTYPPPDHHTY$$$s/1JKKKKKr   c                      t                      } t          j        t                    5  t	          | d           d d d            d S # 1 swxY w Y   d S )Nr   )r   r   raises
ValueErrorgetattr)r   s    r   test_importances_raisesr     s    
 
"
"C	z	"	" - -+,,,- - - - - - - - - - - - - - - - - -s   AA
A
c            	      .   t          j        ddddddd          \  } }t          ddd	                              | |          }t	          d
dd	                              | |          }t          |j        |j                   t          |j        j	        |j        j	                   t          |j        j
        |j        j
                   t          |j        j        |j        j                   t          |j        j        |j        j                   d S )Ni  rB   r:   r   Fr   r/   r9   )r   r   rV   r1   )r   r   r   r   r   r#   r   r%   tree_rt   rq   rp   rv   )r^   r_   r   r   s       r   )test_importances_gini_equal_squared_errorr     s    '  DAq !6QQ
O
O
O
S
S	1 C  !QQ  	c!Qii  0#2JKKKsy(#)*;<<<sy.	0GHHHsy/1IJJJsy/1IJJJJJr   c                     t                                           D ]\  } } |d          }|                    t          j        t          j                   |j        t          t          j	        t          j        j
        d                             k    sJ  |d          }|                    t          j        t          j                   |j        t          t          j        t          j        j
        d                             k    sJ  |d          }|                    t          j        t          j                   |j        dk    sJ  |d          }|                    t          j        t          j                   |j        dk    sJ  |d          }|                    t          j        t          j                   |j        dk    sJ  |d          }|                    t          j        t          j                   |j        t          dt          j        j
        d         z            k    sJ  |d          }|                    t          j        t          j                   |j        t          j        j
        d         k    sJ  |d           }|                    t          j        t          j                   |j        t          j        j
        d         k    sJ d S )	Nsqrt)r   r7   log2r:   rQ   rI   rM   )r5   r   r   r`   r   r   max_features_intrr   r   r   r   )r   TreeEstimatorests      r   test_max_featuresr     s{   (00 7 7mm000	4;''' C	0B(C(C$D$DDDDDm000	4;''' C	0B(C(C$D$DDDDDm+++	4;''' A%%%%m+++	4;''' A%%%%m...	4;''' A%%%%m---	4;''' Cdioa.@(@$A$AAAAAm---	4;''' DIOA$66666m...	4;''' DIOA$666666?7 7r   c                  z
   t                                           D ]r\  } } |            }t          j        t                    5  |                    t                     d d d            n# 1 swxY w Y   |                    t          t                     g dg}t          j        t                    5  |                    |           d d d            n# 1 swxY w Y    |            }t          d d         }t          j        t                    5  |                    t          |           d d d            n# 1 swxY w Y   t          j        t                    } |            }|                    |t                     t          |                    t                    t                      |            }t          j        t                    5  |                    t                     d d d            n# 1 swxY w Y   |                    t          t                     t          j        t                    }t          j        t                    5  |                    |d d dd f                    d d d            n# 1 swxY w Y   t          j        t                    j        } |            }|                    t          j        t          |          t                     t          j        t                    5  |                    t                     d d d            n# 1 swxY w Y   t          j        t                    5  |                    t                     d d d            n# 1 swxY w Y    |            }|                    t          t                     t          j        t                    5  |                    |           d d d            n# 1 swxY w Y   t          j        t                    5  |                    |           d d d            n# 1 swxY w Y    |            }t          j        t                    5  |                    t                     d d d            n# 1 swxY w Y   tt)          d          }t          j        t          d          5  |                    g dgg d	           d d d            n# 1 swxY w Y   t          j        t          d
          5  |                    g dgg d           d d d            d S # 1 swxY w Y   d S )N)r@   r=   r7   r=   r7   r4   r   zy is not positive.*Poissonmatchr   r7   rK   )r   r   r   zSome.*y are negative.*Poisson)r9   grK   )r   r   r   r   r   r   r^   r   r_   r   rr   asfortranarrayr#   r   r   r   asarrayr   dotapplyr   )	r   r   r   X2y2XftXtr   s	            r   
test_errorr    s   (00 6 6mmoo]>** 	! 	!a   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	1kk]]:&& 	" 	"b!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" moossV]:&& 	 	GGArNNN	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 q!!mooACKKNNK888 moo]>** 	 	KKNNN	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	1JqMM]:&& 	" 	"KK!!!QRR%!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" Xa[[]mooq"q!!!]:&& 	 	KKNNN	 	 	 	 	 	 	 	 	 	 	 	 	 	 	]:&& 	 	IIaLLL	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 moo1]:&& 	 	KKOOO	 	 	 	 	 	 	 	 	 	 	 	 	 	 	]:&& 	 	IIbMMM	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 moo]>** 	 	IIaLLL	 	 	 	 	 	 	 	 	 	 	 	 	 	 	  )
4
4
4C	z)E	F	F	F ( (YYY'''( ( ( ( ( ( ( ( ( ( ( ( ( ( (	z)H	I	I	I + +\\\***+ + + + + + + + + + + + + + + + + +s   A**A.	1A.	3CC	C	D::D>	D>	G::G>	G>	"JJ		J		L++L/	2L/	M66M:	=M:	O&&O*	-O*	
P,,P0	3P0	RR	R	9S!!S%(S%T00T47T4c                     t          j        t          j        t          j        j                  } t          j        }t          dt          
                                          D ]\  }}t          |         } |d|d          }|                    | |           |j        j        |j        j        dk             }t          j        |          dk    sJ d                    |                       |d	|d          }|                    | |           |j        j        |j        j        dk             }t          j        |          dk    sJ d                    |                      d
S )z Test min_samples_split parameterdtypeN  rB   r   )min_samples_splitr   rV   r=   	   r   r<   N)rr   r  r`   r   r	   _treeDTYPEr   r   r5   keysr   r   rv   rq   r   ro   )r^   r_   r   r   r   r   node_sampless          r   test_min_samples_splitr  ]  sc   
$)4:+;<<<AA !(inn6F6F G G H H!$ m a
 
 
 	1y/	0G20MNvl##a'''):)A)A$)G)G''' m!.q
 
 
 	1y/	0G20MNvl##a'''):)A)A$)G)G''''+H Hr   c                  @   t          j        t          j        t          j        j                  } t          j        }t          dt          
                                          D ]9\  }}t          |         } |d|d          }|                    | |           |j                            |           }t          j        |          }||dk             }t          j        |          dk    sJ d                    |                       |d|d          }|                    | |           |j                            |           }t          j        |          }||dk             }t          j        |          dk    sJ d                    |                      ;d S )	Nr  r  r9   r   )min_samples_leafr   rV   r6   r   r   )rr   r  r`   r   r	   r  r  r   r   r5   r  r   r   r  bincountr   ro   )	r^   r_   r   r   r   r   outnode_counts
leaf_counts	            r   test_min_samples_leafr  |  s   
$)4:+;<<<AA !(inn6F6F G G F F!$ m~A
 
 
 	1iooa  k#&& !12
vj!!A%%%'8'?'?'E'E%%% m a
 
 
 	1iooa  k#&& !12
vj!!A%%%'8'?'?'E'E%%%%/F Fr   c                 <   t           |         d                             t          j                  }| ||          }t           |         d         }t                              |j        d                   }t          j        |          }t          |          }t          dt          j
        ddd                    D ]\  }}	 ||	|d          }
|
                    |||	           |-|
j                            |                                          }n|
j                            |          }t          j        ||
          }||dk             }t          j        |          ||
j        z  k    s#J d                    | |
j                              |j        d         }t          dt          j
        ddd                    D ]\  }}	 ||	|d          }
|
                    ||           |-|
j                            |                                          }n|
j                            |          }t          j        |          }||dk             }t          j        |          ||
j        z  k    s#J d                    | |
j                              dS )zPTest if leaves contain at least min_weight_fraction_leaf of the
    training setr^   Nr_   r   r  rI   rH   )min_weight_fraction_leafr   rV   r   )weightsz,Failed with {0} min_weight_fraction_leaf={1})DATASETSastyperr   float32rngrandr   rw   r5   r   linspacer   r   r  tocsrr  r   r   ro   )r   r   sparse_containerr^   r_   r!  total_weightr   r   fracr   r  node_weightsleaf_weightss                 r   check_min_weight_fraction_leafr.    s    	3&&rz22A#Q3Ahhqwqz""G6'??LdOM !(bk!S!6L6L M M 
 
m%).WX
 
 
 	1G,,,')//!'')),,CC)//!$$C{3888#LA$56F<  L33O$OOOO9@@#.
 
 POOO 71:L 'bk!S!6L6L M M 
 
m%).WX
 
 
 	1')//!'')),,CC)//!$$C{3''#LA$56F<  L33O$OOOO9@@#.
 
 POOO
 
r   r   c                 &    t          | d           d S Nr`   r.  r   s    r   ,test_min_weight_fraction_leaf_on_dense_inputr3    s    "400000r   csc_containerc                 *    t          | d|           d S Nrf   )r)  r1  r   r4  s     r   -test_min_weight_fraction_leaf_on_sparse_inputr8    s     #4VVVVVVr   c                 &   t           |         d                             t          j                  }| ||          }t           |         d         }|j        d         }t
          |          }t          dt          j        ddd                    D ]\  }} |||dd	          }	|	                    ||           |-|	j	        
                    |                                          }
n|	j	        
                    |          }
t          j        |
          }||dk             }t          j        |          t          ||	j        z  d          k    s)J d
                    | |	j        |	j                              t          dt          j        ddd                    D ]\  }} |||dd	          }	|	                    ||           |-|	j	        
                    |                                          }
n|	j	        
                    |          }
t          j        |
          }||dk             }t          j        |          t          ||	j        z  ||	j        z            k    s)J d
                    | |	j        |	j                              dS )zzTest the interaction between min_weight_fraction_leaf and
    min_samples_leaf when sample_weights is not provided in fit.r^   Nr_   r   r  rI   r:   r9   )r   r   r  rV   zBFailed with {0} min_weight_fraction_leaf={1}, min_samples_leaf={2}r   )r"  r#  rr   r$  r   r5   r   r'  r   r   r  r(  r  r   maxr   ro   r  )r   r   r)  r^   r_   r*  r   r   r+  r   r  r,  r-  s                r   4check_min_weight_fraction_leaf_with_min_samples_leafr;    s   
 	3&&rz22A#Q3A71:LdOM 'bk!S!6L6L M M 
 
m%))	
 
 
 	1')//!'')),,CC)//!$$C{3''#LA$56vl##sC881(
 (
 
 
 
OVV#.0D
 

 
 
 

 !(bk!S!6L6L M M 
 
m%)) 	
 
 
 	1')//!'')),,CC)//!$$C{3''#LA$56vl##sC88C00(
 (
 
 
 
 PVV#.0D
 

 
 
 
%
 
r   c                 &    t          | d           d S r0  r;  r2  s    r   Btest_min_weight_fraction_leaf_with_min_samples_leaf_on_dense_inputr>     s    8vFFFFFr   c                 *    t          | d|           d S r6  r=  r7  s     r   Ctest_min_weight_fraction_leaf_with_min_samples_leaf_on_sparse_inputr@  %  s,    
 9l]     r   c                 $   t          j        d|           \  }}t          dt                                                    D ]\  }}t          |         } ||d          } ||dd          } ||dd          } ||d	d          }	|d
f|df|df|	d	ffD ]s\  }
}|
j        |k    s#J d                    |
j        |                      |
                    ||           t          |
j	        j
                  D ]}|
j	        j        |         t          k    r|
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    sJ d                    ||                      ud S )Nd   rW   rV   r  r   r   rV   rO   )r   min_impurity_decreaserV   g-C6?r   gHz>z)Failed, min_impurity_decrease = {0} > {1}z2Failed with {0} expected min_impurity_decrease={1})r   r   r   r5   r  rE  ro   r   ranger   rn   rq   r   rx   weighted_n_node_samplesrp   r   )global_random_seedr^   r_   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\  /  s    '#DVWWWDAq !(inn6F6F G G > >!$ }NKKK})TU
 
 
 })VW
 
 
 })ST
 
 

 4L4L6N3K	'
 ,	 ,	"C" )->>>>:AA)+<  ?>> GGAqMMMci233     9*40I==!$!3D!9J!$!B4!HJ9248D!$!B4!HJ"y1$7H#-#8LI4T:E"%)"CE"JK #	 25 9I$/)$;M-:\-I**j8* 	9$?!'!*L + '="%;;'O
 (+<<<<KRR'):  =<<; ,	%> >r   c            
         t                                           D ]6\  } }d| v rt          j        t          j        }}nt
          j        t
          j        }} |d                              ||                               ||          }g d}fd|D             }t          j	                  }t          j
        |          }t          |          j        k    sJ |                    ||          }	||	k    sJ d                    |                       |D ]3}
t          t          |j        |
          ||
         d|
 d|  	           48d
S )z8Test pickling preserves Tree properties and performance.
Classifierr   r   )r   rn   capacity	n_classesrq   rp   n_leavesrt   ru   rx   rv   rG  ry   c                 <    i | ]}|t          j        |          S  )r   r   ).0	attributer   s     r   
<dictcomp>ztest_pickle.<locals>.<dictcomp>  s4     
 
 
9BIwsy)44
 
 
r   z6Failed to generate same score  after pickling with {0}z"Failed to generate same attribute z after pickling with rl   N)r5   r   r`   r   r   ra   r   r   pickledumpsloadstype	__class__ro   r%   r   r   )r   r   r^   r_   r   
attributesfitted_attributeserialized_objectrJ  score2re  r   s              @r   test_picklerp  w  s   (00 . .m49dkqAA=(/qAm+++1		!Q
 
 


 
 
 
FP
 
 
 #L--|-..DzzS]****Aq!!VOOOCJJ4PP OO) 	 	I
I.. +   	    	M. .r   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                                           D ]\  }} |d          }|                    | |                              |          }t	          ||           |j        dk    sJ |                    |          }t          |          dk    sJ |d         j        dk    sJ |d         j        d	k    sJ |                    |          }	t          |	          dk    sJ |	d         j        dk    sJ |	d         j        d	k    sJ t                                          D ]W\  }}
 |
d          }|                    | |                              |          }t          ||           |j        dk    sJ Xd S )
Nr@   r=   r7   rK   r   r:   r   r6   rK   )r6   r6   )r   r   r   r   r%   r   r   r   r   r   r#   )r^   r_   r   y_truer   r   r   y_hatproba	log_probar   r   s               r   test_multioutputrw    s    
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 1 , ,nn!,,,1%%a((5&))){f$$$$!!!$$5zzQQx~''''Qx~''''))!,,	9~~""""|!V++++|!V+++++  )00 % %mm+++1%%a((E6***{f$$$$$	% %r   c                  v   t                                           D ]\  } } |d          }|                    t          t                     |j        dk    sJ t          |j        ddg           t          j	        t          t          j
        t                    dz  f          j        } |d          }|                    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           d S )Nr   r   rK   r=   r7   r@   )r   r   r   r^   r_   
n_classes_r%   classes_rr   r   r   r   r   )r   r   r   _ys       r   test_classes_shaper|    s,    ) 1 1 = =nn!,,,1~""""3<"a111 Y28A;;?+,,.n!,,,23>""a''''3<  A%%%%3>Aq62223<2q'B7);<<<<= =r   c                  B   t           j        d d         } t           j        d d         }t          d|          }t                                          D ]L\  }} |d          }|                    | ||           t          |                    |           |           Md S )N}   balancedr   r   r   )	r`   r   r   r"   r   r   r   r#   r   )unbalanced_Xunbalanced_yr   r   r   r   s         r   test_unbalanced_irisr    s    9TcT?L;tt$L)*lCCM ) 1 1 E Enn!,,,l-HHHCKK55|DDDDE Er   c                  D   t          t                                          t          j        t          j        g          D ]\  \  } }} |d          }t          j        t          j        |          }t          j	        }t          |                    ||                              |          |           t          j        t          j        d|          }t          j	        }t          |                    ||                              |          |           t          j        t          j        d|          }t          j	        }t          |                    ||                              |          |           t          j        t          j        |          }t          j	        }t          |                    ||                              |          |           t          D ]\} |t          j        |          }t          j	        }t          |                    ||                              |          |           ]t          D ]\} |t          j        |          }t          j	        }t          |                    ||                              |          |           ]t          j        t          j        d d d         |          }t          j	        d d d         }t          |                    ||                              |          |           d S )Nr   r   r  C)orderr  Fr:   )r   r5   r   rr   float64r$  r  r`   r   r   r%   r   r   ascontiguousarrayr-   r,   )r   r   r  r   r^   r_   csr_containerr4  s           r   test_memory_layoutr    s   (/BJ
3) ) (8 (8$}u m+++ Jty...K3771a==0033Q777 Jty5999K3771a==0033Q777 Jty5999K3771a==0033Q777  %888K3771a==0033Q777 , 	< 	<Mdiu555AAswwq!}}44Q77;;;; , 	< 	<Mdiu555AAswwq!}}44Q77;;;; Jty1~U333K!3771a==0033Q7777Q(8 (8r   c                     t          j        d          d d t           j        f         } t          j        d          }d|d d<   t          j        d          }d||dk    <   t	          d          }|                    | ||           t          |                    |           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
        d         dk    sJ d||d	k    <   t	          dd          }|                    | ||           |j	        j
        d         dk    sJ t          j        } t          j        }t                              d| j        d         d          }t	          d          }|                    | |         ||                    t          j        || j        d                   }t	          d          }|                    | ||           |j	        j        t&          j        j        k    }t-          |j	        j
        |         |j	        j
        |                    d S )NrB  rR   2   r   r   r      r7   rK   gRQ?r   g     b@rI   g     H@)	minlength)rr   r   r   r   r   r   r%   r   rj   r   ru   r`   r   r   r%  randintr   r  rq   r	   r  r   r$   )r^   r_   r   r   
duplicatesr   r~   s          r   test_sample_weightr  3  s    		#qqq"*}%A
AAcrcFGCLLMM!q&
 a
0
0
0CGGAqG...s{{1~~rws||444 		#qqq"*}%A
AAbfIAc#gJAc#gqjMGCLLM M!q&
 11
=
=
=CGGAqG...9q!U****M!q&
 11
=
=
=CGGAqG...9q!T)))) 		AAQ
C00J
 a
0
0
0CGGAjM1Z=)))K
agajAAAM!q111DHHQH///y&$**>>H	H%tz';H'E    r   c                  B   t          j        d          d d t           j        f         } t          j        d          }d|d d<   t	          d          }t           j                            dd          }t          j        t                    5  |
                    | ||           d d d            n# 1 swxY w Y   t          j        d          }d}t          j        t          |	          5  |
                    | ||           d d d            d S # 1 swxY w Y   d S )
NrB  rR   r  r   r   r7   r   z3Singleton.* cannot be considered a valid collectionr   )rr   r   r   r   r   randomr&  r   r   r   r   r   	TypeError)r^   r_   r   r   expected_errs        r   test_sample_weight_invalidr  g  s   
	#qqq"*}%A
AAcrcF
 a
0
0
0CINN3**M	z	"	" 3 31M2223 3 3 3 3 3 3 3 3 3 3 3 3 3 3 HQKKMIL	y	5	5	5 3 31M2223 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3s$   B22B69B6.DDDc                    t           |          } |d          }|                    t          j        t          j                    |dd          }|                    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          }|                    t          j        |           t          |j        |j                    |dd          }|                    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          }|                    t          j        t          j        |            ||d          }|                    t          j        t          j                   t          |j        |j                    |d          }|                    t          j        t          j        |dz              ||d          }|                    t          j        t          j        |           t          |j        |j                   d S )Nr   r   r  class_weightrV   g       @rM   r  r7   rB  g      Y@rK   )r   r   r`   r   r   r#   r   rr   r   r   r   r   )	r   r   clf1r   
iris_multiclf3clf4r   r  s	            r   test_class_weightsr  y  s    t_N >q)))DHHTY$$$>zBBBDHHTY$$$143LMMM DKdkBCCEJ>$$$$$$

   D 	HHTY
###143LMMM>zBBBDHHTY
###143LMMM GDK-..M$+"###s*###u--L>q)))DHHTY]333>|!DDDDHHTY$$$143LMMM >q)))DHHTY]A%5666>|!DDDDHHTY]333143LMMMMMr   c                 X   t           |          }t          j        t          t          j        t                    dz  f          j        } |dddgd          }d}t          j        t          |          5  |	                    t          |           d d d            d S # 1 swxY w Y   d S )	NrK   rI   rM   r=   r7   r   r  zBnumber of elements in class_weight should match number of outputs.r   )r   rr   r   r_   r   r   r   r   r   r   r^   )r   r   r{  r   rm   s        r   test_class_weight_errorsr    s     t_N	Arx{{Q'	(	(	*B .CC'8'8&9
J
J
JCRG	z	1	1	1  2                 s   6BB#&B#c                      t          j        dd          \  } }d}t                                          D ]F\  }} |d |dz                                 | |          }|                                |dz   k    sJ Gd S NrB  r7   rC  r6   )r   r   )r   make_hastie_10_2r5   r   r   get_n_leavesr^   r_   kr   r   r   s         r   test_max_leaf_nodesr    s    $sCCCDAq	A(00 + +mmd1q5AAAEEaKK!!QU*****+ +r   c                      t          j        dd          \  } }d}t                                          D ]@\  }} |d|                              | |          }|                                dk    sJ Ad S r  )r   r  r5   r   r   	get_depthr  s         r   test_max_leaf_nodes_max_depthr    s    $sCCCDAq	A(00 $ $mma:::>>q!DD}}!#####$ $r   c                      dD ]a} t          t                                          dgdggddg          j        |           }d|j        d         cxk    rdk     sn J d            bd S )N)r`  ry   rq   rp   ru   rx   rt   rv   r   r7   rA   r:   z Array points to arbitrary memory)r   r   r   r   flat)attrry   s     r   test_arrays_persistr    s    	 K K .0044qcA3Z!QHHNPTUUUZ]&&&&Q&&&&&(J&&&&K Kr   c                      t          d          } t          j        d          }|                     ddd          }t                                          D ]9\  }} |d          }|                    ||           |j        j        dk    sJ :d S )Nr   )rB   rY   rK   )rB   r   )	r.   rr   rj   r  r5   r   r   r   r   )rV   r^   r_   r   r   r   s         r   test_only_constant_featuresr    s    %a((L
AQ5))A(00 ( (mm+++1y"a'''''( (r   c                  \   t          j        t          j        g dgt          j        d          f                    } g d}t                                          D ]P\  }}d|vrG |dd          }|                    | |           |j        j        dk    sJ |j        j	        d	k    sJ Qd S )
N)r   r   r   r   r   r7   rK   r6   r9   rH      )r6   rG   )r   r   r   r7   r7   rK   rK   rK   r:   r:   r:   	ExtraTreer   r7   r   rK   r9   )
rr   	transposer   rj   r5   r   r   r   r   rn   r^   r_   r   r   r   s        r   ,test_behaviour_constant_feature_after_splitsr    s    

	55568I8IJKK	 	A 	*))A(00 - -md""-QQ???CGGAqMMM9&!++++9'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                                          D ]p\  }} |dd          }|                    | |           |j        j        dk    sJ t          |
                    |           t          j        dd	                     qt                                          D ]p\  }} |dd          }|                    | |           |j        j        dk    sJ t          |                    |           t          j        d
d	                     qd S )NrM   rR   )r6   r  )rR   rM   rR   rM   r   r7   r   rr  rI   )r6   )rr   hstackr   rj   r   r   r   r   r   r%   r   r   r   r   r  s        r   (test_with_only_one_non_constant_featuresr    se   
	28cUSEC53%89928I;N;NOPPA
%%%&&A(00 G Gmm;;;1y"a''''3,,Q//1E1EFFFF(00 ? ?mm;;;1y"a''''3;;q>>274+=+=>>>>	? ?r   c                  F   t          j        dd                              t           j                                      dd          } t                      }t          j        t          d          5  |	                    | g d           d d d            d S # 1 swxY w Y   d S )Ng\)c=Hr6   r=   r7   r$  r   )r   r7   r   r7   )
rr   repeatr#  r  reshaper   r   r   r   r   )r^   r   s     r   test_big_inputr    s    
	(A%%bj1199"a@@A
 
"
"C	z	3	3	3 ! !<<<   ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !s   0BBBc                      ddl m}  t          j        t                    5   |              d d d            d S # 1 swxY w Y   d S )Nr   _realloc_test)sklearn.tree._utilsr  r   r   MemoryErrorr  s    r   test_reallocr    s    111111	{	#	#                   s   8<<c                  >   dt          j        d          z  } t          j                            dd          }t          j                            ddd          }d| dz   z  }t          d|          }t          j        t                    5  |
                    ||           d d d            n# 1 swxY w Y   d| dz
  z  dz
  }t          d|          }t          j        t                    5  |
                    ||           d d d            d S # 1 swxY w Y   d S )	NrJ   PrB   rK   r   r7   best)splitterr   )structcalcsizerr   r  randnr  r   r   r   	Exceptionr   r  )n_bitsr^   r_   huger   s        r   test_huge_allocationsr    s   %%%F
	AA
	!Q##A !D
 &
F
F
FC	y	!	!  1              
 !q D
 &
F
F
FC	{	#	#  1                 s$   B..B25B2.DDDc                    t           |          }t          |         d         }t          |         d         }|dv r$|j        d         dz  }|d |         }|d |         }t          t          z   t
          z   D ]i} ||          } |d|                              ||          }	 |d|                              ||          }
t          |	j        |
j        d	                    |                      |	
                    |          }| t          v r*|	                    |          }|	                    |          }t          t
          z   t          z   D ]} ||t          j                  }t!          |

                    |          |           | t          v rFt!          |
                    |          |           t!          |
                    |          |           kd S )	Nr^   r_   )rb   ra   r   r9   rV   r   5{0} with dense and sparse format gave different treesr  )r5   r"  r   r+   r,   r-   r   r   r   ro   r   r   r   r   rr   r$  r$   )r	   datasetr   r   r^   r_   rW   r)  X_sparserz   r{   y_predy_probay_log_probasparse_container_testX_sparse_tests                   r   check_sparse_inputr  '  s   dOM#A#A (((GAJ!O	jyjMjyjM*^;nL  ##A&& MqI>>>BB1aHHMqI>>>BB8QOOGGCJJ4PP	
 	
 	
 19ooa((G--a00K%3n%D~%U 		 		!11("*MMMM%aii&>&>GGGy  )!//-*H*H'RRR)''66  		% r   	tree_typer  )rd   rc   rb   rf   rg   rh   ri   rj   c                 <    |dk    rdnd }t          | ||           d S )Nrb   r:   r  )r  r  r   s      r   test_sparse_inputr  P  s/     ((dIy'955555r   ra   re   c                 (    t          | |d           d S )NrK   r  )r  r  s     r   test_sparse_input_reg_treesr  c  s    
 y'1-----r   )rg   rh   ri   rj   c                    t           |          }t          |         d         } ||          }t          |         d         } |ddd                              ||          } |ddd                              ||          }t          |j        |j        d                    |                      t          |                    |          |                    |                      |ddd	                              ||          } |ddd	                              ||          }t          |j        |j        d                    |                      t          |                    |          |                    |                      |d|j        d         dz  
                              ||          } |d|j        d         dz  
                              ||          }t          |j        |j        d                    |                      t          |                    |          |                    |                      |dd                              ||          } |dd                              ||          }t          |j        |j        d                    |                      t          |                    |          |                    |                     d S )Nr^   r_   r   r7   rK   )rV   r   r   r  rB   )rV   r   r  )rV   r  r:   r   )	r5   r"  r   r   r   ro   r$   r   r   )	r  r  r4  r   r^   r  r_   rz   r{   s	            r   test_sparse_parametersr  k  s    i(M#A}QH#A 	11BBBFFq!LLA11BBBFFxQRSSA		?FFyQQ  
 aiillAIIaLL999 	11KKKOOPQSTUUA11KKKOO!	 	A 		?FFyQQ  
 aiillAIIaLL999 	1x~a7HA7MNNNRRSTVWXXA1x~a7HA7MNNNRR!	 	A 		?FFyQQ  
 aiillAIIaLL999 	1Q777;;AqAAA1Q777;;HaHHA		?FFyQQ  
 aiillAIIaLL99999r   ztree_type, criterionc                 $    g | ]}|t           v |S rc  )r   rd  r	   s     r   
<listcomp>r    s"    EEE4493D3D$3D3D3Dr   c                 $    g | ]}|t           v |S rc  )r   r  s     r   r  r    s"    DDD$$)2C2C2C2C2Cr   c                    t           |          }t          |         d         } ||          }t          |         d         } |dd|                              ||          } |dd|                              ||          }	t          |j        |	j        d                    |                      t          |	                    |          |                    |                     d S )Nr^   r_   r   r:   rV   r   r   r  )r5   r"  r   r   r   ro   r$   r   )
r  r  r4  r   r   r^   r  r_   rz   r{   s
             r   test_sparse_criteriar    s     i(M#A}QH#A1YGGGKKAqQQA1YGGGKKHVWXXA		?FFyQQ  
 aiillAIIaLL99999r   zcsc_container,csr_containerc                 
   t           |          }d}d}|}t          j        |          }t          d          }g }	g }
d}|g}t	          |          D ]}|                    |d          }|                    |          d |         }|	                    |           |                    dd|f          dz
  }|
                    |           ||z  }|                    |           t          j        |	          	                    t          j
                  }	t          j        |t          j
                  }t          j        t          j        |
          t          j                  }
 ||
|	|f||f          }|                                } ||
|	|f||f          }|                                }|                    dd|f          }|                                }|j        d	k                                    dk    sJ |j        d	k                                    dk    sJ  |d|
                              ||          } |d|
                              ||          }t'          |j        |j        d                    t,                               ||f}t/          ||          D ]N\  }}t1          |j                            |          |j                            |                     t1          |                    |          |                    |                     t1          |                    |          |j                            |                     t1          |j                            |                                          |j                            |                                                     t1          |                    |                                          |                    |                                                     t1          |                    |                                          |j                            |                                                     t1          |                    |          |                    |                     t,          t8          v r6t1          |                    |          |                    |                     Pd S )Nr:   rB   r   rI   rZ   r7   r  r   rR   r  r  )r5   rr   r   r.   rF  binomialpermutationappendconcatenater#  int32r   r$  toarrayr  copyr   rw   r   r   r   ro   r	   r   r$   r  decision_pathr   r   r   )r  r4  r  r   r   rX   rW   samplesrV   r   r   offsetindptrin_nonzero_i	indices_idata_ir  r^   r  X_testr_   rz   r{   XsX1r  s                              r   test_explicit_sparse_zerosr    s   
 i(MIJ Ii	""G &a((LGDFXF:  "++Is;; ,,W55l{lC	y!!!&&q#[N&CCaGF+fnW%%,,RX66GXfBH---F8BN4((
;;;D}dGV4Y
<STTTHA!M	w	:'>  M ""$$FQ55A "&&((M MS %%''!++++#%**,,q0000 	1	:::>>q!DDA1	:::>>xKKA		?FFtLL   -	 B"b// P PB!!'--"3"3QW]]25F5FGGG!!''"++qwwr{{;;;!!''"++qw}}R/@/@AAA!G!!"%%--//1F1Fr1J1J1R1R1T1T	
 	
 	
 	"OOB''))1??2+>+>+F+F+H+H	
 	
 	
 	"OOB''))17+@+@+D+D+L+L+N+N	
 	
 	
 	"!))B--2???9%aoob&9&91??2;N;NOOO%P Pr   c                 P   t           |          }t          j        d d df                                         }t          j        d d df                             d          }t          j        }t          j        t                    5   |d          	                    ||           d d d            n# 1 swxY w Y    |d          }|	                    ||           t          j        t                    5  |
                    |g           d d d            d S # 1 swxY w Y   d S )Nr   r  r   )r5   r`   r   r   r  r   r   r   r   r   r   )r   r   r^   X_2dr_   r   s         r   check_raise_error_on_1d_inputr  
  s   dOM	!!!Q$A9QQQT?""7++DA	z	"	" 0 01%%%))!Q///0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -Q
'
'
'CGGD!	z	"	"  QC                 s$   !B11B58B57DD"Dc                 r    t                      5  t          |            d d d            d S # 1 swxY w Y   d S N)r'   r  r2  s    r   test_1d_inputr    s    			 , ,%d+++, , , , , , , , , , , , , , , , , ,s   ,00r)  c                 `   t           |          }t          j        dgdgdgdgdgg          }g d}g d}| ||          } |d          }|                    |||           |j        j        dk    sJ  |dd          }|                    |||           |j        j        dk    sJ d S )	Nr   r7   )r   r   r   r   r7   )r<   r<   r<   r<   r<   r   r   g?)rV   r   )r5   rr   r   r   r   r   )r   r)  r   r^   r_   r   r   s          r    test_min_weight_leaf_split_levelr  !  s     dOM
1#sQC!qc*++AA---M#Q
-Q
'
'
'CGGAqG...9!####
-Q
E
E
ECGGAqG...9!######r   c                 D   t                               t          j        j        d          }t          |                      }|                    t           t                     t          |	                    t                     |j
        	                    |                     d S NFr  X_smallr#  r	   r  r  r5   r   y_smallr%   r  r   )r   	X_small32r   s      r   test_public_apply_all_treesr  5  so    tz/e<<I
D/

CGGGWsyy))39??9+E+EFFFFFr   r  c                 V    |t                               t          j        j        d                    }t          |                      }|                    t           t                     t          |	                    t                     |j
        	                    |                     d S r  r
  )r   r  r  r   s       r   test_public_apply_sparse_treesr  >  s{     gnnTZ-=EnJJKKI
D/

CGGGWsyy))39??9+E+EFFFFFr   c                  
   t           j        } t           j        }t          dd                              | |          }|                    | d d                                                   }t          |g dg dg           d S )Nr   r7   r  rK   )r7   r7   r   r7   r   r7   )r`   r   r   r   r   r  r  r%   )r^   r_   r   node_indicators       r   test_decision_path_hardcodedr  H  s|    	AA
 a1
=
=
=
A
A!Q
G
GC&&q!u--5577N~			999'=>>>>>r   c                    t           j        }t           j        }|j        d         }t          |          } |dd          }|                    ||           |                    |          }|                                j        ||j        j	        fk    sJ |
                    |          }fdt          |          D             }t          |t          j        |                     |j        j        t           k    }	t          t          j        |	          t          j        |                                         d                                          }
|j        j        |
k    sJ d S )Nr   rK   r  c                 *    g | ]\  }}||f         S rc  rc  )rd  r  jr  s      r   r  z&test_decision_path.<locals>.<listcomp>`  s&    JJJ1~ad+JJJr   r  r7   axis)r`   r   r   r   r5   r   r  r  r   rn   r  	enumerater$   rr   r   rq   r   r  rw   r:  r   )r   r^   r_   rW   r   r   node_indicator_csrleavesleave_indicator
all_leavesr   r  s              @r   test_decision_pathr  P  s]   	AA
IdOM
-Q!
4
4
4CGGAqMMM**1--'//11NIsy/C#DDDDD YYq\\FJJJJ	&8I8IJJJOorwY/G/G/GHHH (I5J
~z**BG),D,D,D  
 """**..00I9)++++++r   c                     t            |t                    }}t          |          }t          j        t
                    5   |d                              ||           d d d            d S # 1 swxY w Y   d S Nr   r   )X_multilabely_multilabelr5   r   r   r  r   )r   r  r^   r_   r   s        r   test_no_sparse_y_supportr$  n  s     |44qAdOM	y	!	! 0 01%%%))!Q///0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0s   !A,,A03A0c                     t          ddd          } |                     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           |                     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           |                     dgdgdgdgdggg d           t          | j        j        g d           t          | j        j        j        g d           dS )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   r2   rK   )rV   r   r   r:   r9   rJ   )rH   r  r:   r6   r:   )333333?333333?r   rM   r'  )r^   r_   r   )g,d?gܶm۶m?g?)      @g      @r(  )ffffff?rL   gUUUUUU?)r6   rS   r(  r]   N)
r   r   r   r   rx   r%   ry   r  rr   r   )dt_maes    r   test_maer+  x  s   T #"21  F
 JJ3aS1#s
#
/////    
 FL)+L+L+LMMMv|).@@@ JJ1#sQC!qc*oooRWUVZZJXXXv|,.C.C.CDDDv|).>>>
 JJ1#sQC!qc*oooJ>>>v|,.C.C.CDDDv|).>>>>>r   c                  (   d} t          j        dt           j                  }d}d }t          j        t          j        |fD ]}t          j                    D ]W\  }} || |          } ||                                          }|\  }	\  }
}}||	k    sJ | |
k    sJ t          ||           Xt          j                    D ]O\  }} || |          } ||                                          }|\  }	\  }
}}||	k    sJ | |
k    sJ ||k    sJ Pd S )Nr:   r  rB  c                 N    t          j        t          j        |                     S r  )rg  ri  rh  )objs    r   _pickle_copyz)test_criterion_copy.<locals>._pickle_copy  s    |FL--...r   )
rr   r   intpr  deepcopyr   r   
__reduce__r%   r   )	n_outputsr`  rW   r/  	copy_func_typenamecriteriaresult	typename_
n_outputs_ry  
n_samples_s                r   test_criterion_copyr<    s{    I	!27+++II/ / / i= + +	'-// 	6 	6KAxx	955HYx((3355F5;2I/
Jy((((
****y*5555'-// 	+ 	+KAxx	955HYx((3355F5;2I/
Jy((((
****
*****	++ +r   c                    t           j                            d                              dd          dz  }t          j        |                    d                    }|d d d df         }|  | |          }|d d df         }t          d                              ||          } |j        |          }t          t          j
        |j        j        t          k              d                   }|                    |          }t          j
        t          j        |j        j                             d         }t#          |          dk    sJ t#          |          dk    sJ d S )Nr   rB  rG   g*Gr$  r=   r   )rr   r  RandomStater  
nan_to_numr#  r   r   r  setwherer   rq   r   
differenceisfiniteru   r   )	r)  r   r^   r_   r	   terminal_regions	left_leaf
empty_leafinfinite_thresholds	            r   "test_empty_leaf_infinite_thresholdrH    sM    9  ##))#r22T9D=Y//00DQQQVA#QQQQUA a00044Q::D!tz!}}BHTZ5BCCAFGGI%%&677J2;tz/C#D#D"DEEaH!""a''''z??ar   tree_clsc                 v   t           |          } | d         | d         }} |dd          }|                    ||          }|j        }|j        }t	          j        t	          j        |          dk              sJ t	          j        t	          j        |          dk              sJ t          ||||           d S Nr^   r_   rY   r   rD  r"  cost_complexity_pruning_path
ccp_alphas
impuritiesrr   r   diffassert_pruning_creates_subtreer  rI  r^   r_   r   infopruning_pathrO  s           r   'test_prune_tree_classifier_are_subtreesrU    s    
 wG3<qA
("1
5
5
5C++Aq11D?LJ6"',''1,-----6"'*%%*+++++"8Q<@@@@@r   c                 v   t           |          } | d         | d         }} |dd          }|                    ||          }|j        }|j        }t	          j        t	          j        |          dk              sJ t	          j        t	          j        |          dk              sJ t          ||||           d S rK  rL  rR  s           r   'test_prune_tree_regression_are_subtreesrW    s     wG3<qA
("1
5
5
5C++Aq11D?LJ6"',''1,-----6"'*%%*+++++"8Q<@@@@@r   c                      t          d          } |                     dgdggddg           t          dd          }|                    dgdggddg           t          | j        |j                   d S )Nr   r   r7   rB   )rV   	ccp_alpha)r   r   assert_is_subtreer   )r  r   s     r   test_prune_single_node_treer[  .  s    !q111DHHqcA3Z!Q    "qB???DHHqcA3Z!Q   dj$*-----r   c                     g }|D ]9} | d|d                               ||          }|                    |           :t          ||dd                    D ]\  }}t          |j        |j                    d S )NrY   r   )r   rY  rV   r7   )r   r  ziprZ  r   )	estimator_clsr^   r_   rT  
estimatorsrY  r   prev_estnext_ests	            r   rQ  rQ  :  s    J!  	m2QRSSSWWq
 
 	# "*jn== : :((.(.9999: :r   c                 8   | j         |j         k    sJ | j        |j        k    sJ | j        }| j        }|j        }|j        }dg}|rS|                                \  }}t          | j        |         |j        |                    t          | j        |         |j        |                    t          | j	        |         |j	        |                    t          | j
        |         |j
        |                    ||         ||         k    r!t          t          |j        |                    nlt          | j        |         |j        |                    |                    ||         ||         f           |                    ||         ||         f           |Qd S d S )N)r   r   )rn   r   rq   rp   popr$   ry   r#   rx   rv   rG  r   ru   r  )	r	   subtreetree_c_lefttree_c_rightsubtree_c_leftsubtree_c_rightstacktree_node_idxsubtree_node_idxs	            r   rZ  rZ  I  s   ?g00000>W.....$K&L*N,OHE
 */))++''!J}%w}5E'F	
 	
 	
 	M-('*:;K*L	
 	
 	
 	.0FGW0X	
 	
 	
 	(7+,<=	
 	
 	

 *+?O/PPP0ABR0STTTT  }-w/@AQ/R   LL+m4nEU6VWXXXLLm,o>N.OP  3      r   r  r  r  c                 j   t           d         }|d                             t          j        j        d          }|t          |          }nt ||d                   }t          j        |j        t          j        j                  |_        t          |j        |j	        |j
        f          \  |_        |_	        |_
        t          t          j        t          t          j        j                            }t          |          |          }|                    ||           t          |                    |          |                    |                     t          |                    |                                          |                    |                                                     d S )Nrd   r^   Fr	  r  r  )r"  r#  r	   r  r  r&   rr   r   r   r   r  r  r5   r   r%   r   r  todense)r   r  r)  r  r  
X_readonly
y_readonlyr   s           r   "test_apply_path_readonly_all_treesrq  q  st    {#Gcl!!$*"2!??G.w77

%%gcl33
(:?$*:JKKK

 &_j0*2CD
 
		
O
 +28G4:CS+T+T+TUUJ
D/8
,
,
,CGGJ
###s{{:..G0D0DEEE*%%--//1B1B71K1K1S1S1U1U    r   )r1   r3   r4   c                    t           j        t           j        }} ||           }|                    ||           t	          j        |                    |                    t          j        t	          j        |                    k    sJ d S )Nr   )	ra   r   r   r   rr   rw   r   r   r   )r   r!   r^   r_   r   s        r   test_balance_propertyrs    sq     =(/qA
$
#
#
#CGGAqMMM6#++a..!!V]26!99%=%=======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|           }|                    ||           t          j        |                    |                    dk    sJ t          d|           }|                    ||           t          j        |                    |          dk              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|           }|                    ||           t          j        |                    |          dk              sJ d S )Nr   r7   rK   r:   )r   r   r   r   r7   rK   r:   r6   r1   r   r4   rB   r&  r  )effective_ranktail_strengthrW   rX   r   rV   r=   )	r   r   rr   aminr   r   r   make_regressionr   )rt  r^   r_   r   rX   s        r   test_poisson_zero_nodesrz    s    Q!Q!Q!Q!Q!Q!Q!QHA   A  /
M
M
MCGGAqMMM73;;q>>""a''''
)$
G
G
GCGGAqMMM6#++a..1$%%%%% J#!A~* 1n)  DAq ArAv!a%
q		A
)$
G
G
GCGGAqMMM6#++a..1$%%%%%%%r   c            	         t           j                            d          } d\  }}}t          j        ||z   ||           }|                     dd|          t          j        |d          z  }|                     t          j        ||z            	          }t          |||| 
          \  }}}	}
t          dd|           }t          dd|           }|                    ||	           |                    ||	           t          d                              ||	          }||	df||
dffD ]\  }}}t          ||                    |                    }t          |t          j        |                    |          dd                     }t          ||                    |                    }|dk    r|d|z  k     sJ |d|z  k     sJ d S )Nr   )  r|  rB   rW   rX   rV   r@   rK   )lowhighr[   r   r  )lam)	test_sizerV   r4   rB   )r   r  rV   r1   mean)strategytraintestgV瞯<rI   g      ?)rr   r  r>  r   make_low_rank_matrixuniformr:  r4   r   r   r   r   r
   r   r   clip)r%  n_trainn_testrX   r^   coefr_   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7"&:K:K:KKDq4x(())A'7	1S( ( ($GVWf %r  H %!Rc  H LL'"""LL'"""F+++//AAE1FFF3KL 
0 
0	1c*1h.>.>q.A.ABB
*1bgh6F6Fq6I6I5RV.W.WXX
,Qa0@0@AA &==j 00000D<//////
0 
0r   c                    t          |           }t          di |ddi}dD ]}t          d| z   |d           t          j                            d          }d	\  }}|                    ||          }t          j        |d
          |                    |          z   }|t          j        |          dz   z  }t          j	        ||d|dz           gd          }	t          j	        ||d|dz           g          }
t          j
        t          |                    }d|d|dz  <   t          di |                    |||          }t          di |                    |	|
d          }|j        j        |j        j        k    sJ t          |                    |          |                    |                     dS )z4Test that the impact of sample_weight is consistent.r   rV   r   )rj   r   DecisionTreeRegressor_rj   )kindr   )rB   r9   r7   r  r   NrK   r   rc  )dictr   r)   rr   r  r>  r&  r  r   r  r   r   r   r   rn   r   r   )r   tree_paramsr	   r  r%  rW   rX   r^   r_   r  r  sample_weight_1tree1tree2s                 r   6test_decision_tree_regressor_sample_weight_consistencyr    s    +++K @@;@@R@@@D! 
 
'$y0$W	
 	
 	
 	
 	
 )


"
"C!IzJ''A
SXXi000ASA 
A.	Q./0q	9	9	9B	A.	Q./0	1	1Bgc!ffooO()O$i1n$%!00K0044	1O 5  E "00K0044R44PPE;!U[%;;;;; EMM!$$emmA&6&677777r   r`  c                 v   d\  }}t          j        ||||dd          \  }} | dd                              ||          } | dd                              ||          }t          |j        |j        | d	           t          |                    |          |                    |                     d
S )z3Test that criterion=entropy gives same as log_loss.)r  r9   r   r   )r`  rW   rX   r   r   rV   r0   +   r   entropyz> with criterion 'entropy' and 'log_loss' gave different trees.N)r   r   r   r   r   r   r   )r!   r`  rW   rX   r^   r_   tree_log_losstree_entropys           r   'test_criterion_entropy_same_as_log_lossr    s     "Iz'   DAq D:B???CCAqIIM4)"===AA!QGGLQQQ  
 M))!,,l.B.B1.E.EFFFFFr   c                  X   t          j        d          \  } }t          dd                              | |                               | |          }d fd}t          j         |                      }|                    | |          }t          j        ||          sJ d S )Nr   r   r:   r  c                     |                                                      | j                                                                                  S r  )byteswapviewr  newbyteorderr2  )arrs    r   reduce_ndarrayz8test_different_endianness_pickle.<locals>.reduce_ndarray-  s8    ||~~""39#9#9#;#;<<GGIIIr   c                     t          j                    } t          j        |           }t          j                                        |_        |j        t          j        <   |	                               | 
                    d           | S Nr   )ioBytesIOrg  Picklercopyregdispatch_tabler  rr   ndarraydumpseek)fpr   r  s     r    get_pickle_non_native_endiannesszJtest_different_endianness_pickle.<locals>.get_pickle_non_native_endianness0  sf    JLLN1"16688'5$	s	q			r   )	r   r   r   r   r   rg  loadrr   isclose)r^   r_   r   r  new_clf	new_scorer   r  s         @@r    test_different_endianness_pickler  &  s    'Q777DAq
 a1
=
=
=CGGAqMMMIIaOOEJ J J      k::<<==Ga##I:eY'''''''r   c                  x   t          j        d          \  } }t          dd                              | |                               | |          } G d dt
                    fd}t          j         |                      }|                    | |          }t          j	        ||          sJ d S )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                  r>|                                                    |j                                                  }t                                          |           d S r  )	
isinstancerr   r  r  r  r  r  supersave)selfr.  rk  s     r   r  zUtest_different_endianness_joblib_pickle.<locals>.NonNativeEndiannessNumpyPickler.saveG  s]    #rz** Dllnn))#)*@*@*B*BCCGGLLr   )__name__
__module____qualname__r  __classcell__)rk  s   @r   NonNativeEndiannessNumpyPicklerr  F  s8        	 	 	 	 	 	 	 	 	r   r  c                      t          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_endiannessL  sA    JLL++A..	s	q			r   )
r   r   r   r   r   r   joblibr  rr   r  )r^   r_   r   r  r  r  r  r   s         @@r   'test_different_endianness_joblib_pickler  ?  s    'Q777DAq
 a1
=
=
=CGGAqMMMIIaOOE    ,         kAACCDDGa##I:eY'''''''r   c                    t           rt          j        nt          j        }g d}d | j        j                                        D             }|D ]}|||<   t          j        t          |                                          t          |	                                          d          }| 
                    |d          S )N)
left_childright_childrt   rv   c                      i | ]\  }\  }}||S rc  rc  rd  r   r  r5  s       r   rf  z6get_different_bitness_node_ndarray.<locals>.<dictcomp>_  /       (juae  r   namesformats	same_kindcasting)r*   rr   int64r  r  fieldsr   listr  valuesr#  )node_ndarraynew_dtype_for_indexing_fieldsindexing_field_namesnew_dtype_dictr   	new_dtypes         r   "get_different_bitness_node_ndarrayr  Y  s    09$GBHHrx! VUU ,8,>,E,K,K,M,M  N % = =<t~**,,--$~?T?T?V?V:W:WXX I y+>>>r   c                    d | j         j                                        D             }d | j         j                                        D             }d |D             }t	          j         t          |                                          t          |                                          |d          }|                     |d          S )Nc                      i | ]\  }\  }}||S rc  rc  r  s       r   rf  z8get_different_alignment_node_ndarray.<locals>.<dictcomp>l  r  r   c                     g | ]\  }}|S rc  rc  )rd  r  r  s      r   r  z8get_different_alignment_node_ndarray.<locals>.<listcomp>o  s    NNN-%vNNNr   c                     g | ]}d |z   S )rJ   rc  )rd  r  s     r   r  z8get_different_alignment_node_ndarray.<locals>.<listcomp>p  s    888fq6z888r   )r  r  offsetsr  r  )r  r  r   r  rr   r  r  r#  )r  r  r  shifted_offsetsr  s        r   $get_different_alignment_node_ndarrayr  k  s     ,8,>,E,K,K,M,M  N ON<+=+D+K+K+M+MNNNG88888O.--//00N113344&	
 	
 I y+>>>r   c                    t           rt          j        nt          j        } | j                    \  }\  }}}}|                    |d          }|                                }t          |d                   |d<   ||||f|fS )Nr  r  nodes)r*   rr   r  r  r2  r#  r  r  )	r	   r  rI  rX   r`  r3  statenew_n_classes	new_states	            r   "reduce_tree_with_different_bitnessr  |  s    %328I:I$/:K:K7H0z9i%$$Y$DDM

I;Ig<NOOIgz=)<iHHr   c                  T   t          j        d          \  } }t          dd                              | |                               | |          }fd}t          j         |                      }|                    | |          }|t          j        |          k    sJ d S )Nr   r   r:   r  c                     t          j                    } t          j        |           }t          j                                        |_        t          |j        t          <   |	                               | 
                    d           | S r  )r  r  rg  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_bitness  sd    JLLN1"16688'I$	s	q			r   )	r   r   r   r   r   rg  r  r   r   )r^   r_   r   r  r  r  r   s         @r   test_different_bitness_pickler    s    'Q777DAq
 a1
=
=
=CGGAqMMMIIaOOE     k<<>>??Ga##IFM),,,,,,,,r   c                  T   t          j        d          \  } }t          dd                              | |                               | |          }fd}t          j         |                      }|                    | |          }|t          j        |          k    sJ d S )Nr   r   r:   r  c                     t          j                    } t          |           }t          j                                        |_        t          |j        t          <   |                               | 	                    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  s`    JLLOO"16688'I$	s	q			r   )	r   r   r   r   r   r  r  r   r   )r^   r_   r   r  r  r  r   s         @r   $test_different_bitness_joblib_pickler    s     'Q777DAq
 a1
=
=
=CGGAqMMMIIaOOE     k<<>>??Ga##IFM),,,,,,,,r   c                      t           rt          j        t          j                  nt          j        t          j                  } t          j        t          j                  t          j        t          j                  g}|d |D             z  }t          j        ddg|           }|D ]%}t          |                    |          |            &t          j	        t          d          5  t          j        ddgg|           }t          ||            d d d            n# 1 swxY w Y   t          j	        t          d          5  |                    t          j                  }t          ||            d d d            d S # 1 swxY w Y   d S )Nc                 6    g | ]}|                                 S rc  )r  )rd  dts     r   r  z(test_check_n_classes.<locals>.<listcomp>  s"    BBBRr((BBBr   r   r7   r  zWrong dimensions.+n_classesr   zn_classes.+incompatible dtype)r*   rr   r  r  r  r   r   r#  r   r   r   r  )expected_dtypeallowed_dtypesr`  r  wrong_dim_n_classeswrong_dtype_n_classess         r   test_check_n_classesr    s   +4LRXbh'''"(28:L:LNhrx(("(28*<*<=NBB>BBBBN!Q~666I ? ?))"--~>>>>	z)F	G	G	G > > hAx~FFF,n===> > > > > > > > > > > > > > > 
z)H	I	I	I @ @ ) 0 0 < <.???@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @s$   **D  D$'D$0FF
Fc                      t          j        t           j                  } d}t          j        ||           }| |                                 g}|D ]}t          |||           t          j        t          d          5  t          || d           d d d            n# 1 swxY w Y   |d d d d d df         t          j	        |          fD ]L}t          j        t          d          5  t          || |j
                   d d d            n# 1 swxY w Y   Mt          j        t          d	          5  t          |                    t           j                  | |           d d d            d S # 1 swxY w Y   d S )
N)r9   r7   rK   r  )r  expected_shapezWrong shape.+value arrayr   )r7   rK   r7   zvalue array.+C-contiguouszvalue array.+incompatible dtype)rr   r  r  rj   r  r    r   r   r   r  r   r#  r$  )r  r  value_ndarrayr  r  problematic_arrs         r   test_check_value_ndarrayr    sr   Xbj))NNH^>BBBM$n&A&A&C&CDN 
 
"^	
 	
 	
 	
 	
 
z)C	D	D	D 
 
.	
 	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 

 *!!!QQQ(3R5F}5U5UV  ]:-HIII 	 	 -.4   	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 
z)J	K	K	K 
 
  ,,))	
 	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
s6   ?BB"%B"+DD	D	60E33E7:E7c                     t           } t          j        d|           }|t          |          t	          |          g}|d |D             z  }|D ]}t          ||            t          j        t          d          5  t          j        d|           }t          ||            d d d            n# 1 swxY w Y   t          j        t          d          5  |d d d	         }t          ||            d d d            n# 1 swxY w Y   d
 |j	        j
                                        D             }|                                }t          j        |d<   t          j	        t          |                                          t          |                                          d          }|                    |          }t          j        t          d          5  t          ||            d d d            n# 1 swxY w Y   |                                }t          j        |d<   t          j	        t          |                                          t          |                                          d          }|                    |          }t          j        t          d          5  t          ||            d d d            d S # 1 swxY w Y   d S )N)r9   r  c                 f    g | ].}|                     |j                                                  /S rc  )r#  r  r  )rd  r  s     r   r  z+test_check_node_ndarray.<locals>.<listcomp>  s?       14

39))++,,  r   )r  zWrong dimensions.+node arrayr   )r9   rK   znode array.+C-contiguousrK   c                      i | ]\  }\  }}||S rc  rc  r  s       r   rf  z+test_check_node_ndarray.<locals>.<dictcomp>	  s#    XXX"2$
$XXXr   ru   r  znode array.+incompatible dtyper  )r   rr   rj   r  r  r   r   r   r   r  r  r   r  r  r  r  r  r#  r  )r  r  valid_node_ndarraysr  problematic_node_ndarray
dtype_dictr  r  s           r   test_check_node_ndarrayr    s    N8D777L 	*<88,\::
   8K    # I ILHHHHH	z)G	H	H	H U U#%8F.#I#I#I 4^TTTTU U U U U U U U U U U U U U U 
z)C	D	D	D U U#/!#4 4^TTTTU U U U U U U U U U U U U U U YXl6H6O6U6U6W6WXXXJ  __&&N"$(N;~**,,--$~?T?T?V?V:W:WXX I  ,229==	z)I	J	J	J U U4^TTTTU U U U U U U U U U U U U U U  __&&N#%:N< ~**,,--$~?T?T?V?V:W:WXX I  ,229==	z)I	J	J	J U U4^TTTTU U U U U U U U U U U U U U U U U UsH   =(B11B58B5D  DDG99G= G=,KKKSplitterc                 l   t           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 d	S )z&Check that splitters are serializable.r   rB   rK   r:   r  r/   r9   rI   N)monotonic_cst)rr   r  r>  r   r0  r   rg  rh  ri  r   r  )	r  r%  r   r3  r`  r   r  splitter_serializesplitter_backs	            r   test_splitter_serializabler  	  s    
 )


#
#CLbh1vRW===yIV$Y	::Ix	<CDQQQHh//L!344M%5555mX.......r   c                 6   t          |                     d                    }t          d          }|                    t          t
                     t          j        ||           t          j        |d          }t          |j
        |j
        d           dS )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  1	  s    
 fkk,//00K
 a
0
0
0CGGGW
K[!!![C888J	I    r   c                 L   t          j        ddgddgg          }t          j        ddg          } | d                              ||            | d          }d}t          j        t
          |          5   |j        ||           ddd           dS # 1 swxY w Y   dS )zhCheck that an error is raised when min_sample_split=1.

    non-regression test for issue gh-25481.
    r   r7   rM   )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)rr   r   r   r   r   r   )r!   r^   r_   r	   msgs        r   test_min_sample_split_1_errorr   D	  s    	1a&1a&!""A
!QA 	D3##Aq))) 4!$$$D	0  
z	-	-	-  A                 s   :BB Bc                 b   t          j        g dg          j        }t          j        g d          }t          dd|           }|                    ||           |                    t           j        gg          }t          |t          j        |dd                   g           |dd         }|dd         }t          dd|           }|                    ||           |                    t           j        gg          }t          |t          j        |d	d                   g           dS )
z<Check missing values goes to correct node during predictions)	r   r7   rK   r:   rJ   r  rG      r   )	r   r<   r'  r<   r)  r)  rL   g?g@r   r7   r  r;   Nr=   r8   )	rr   r   r   r   r   r   nanr   r  )r   r^   r_   dtcr  X_equaly_equals          r   -test_missing_values_on_equal_nodes_no_missingr'  Z	  s    	0001224A
>>>??A
R1	
R
R
RCGGAqMMM [[26($$FFRWQrssV__-... fGfG
R1	
R
R
RCGGGW [[26($$FFRWWRSS\22344444r   r  r/   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|           }|                    ||           t          j        t           j        dd	gg          j        }|                    |          }t          ||ddg           d
S )zITest when missing values are uniquely present in a class among 3 classes.r   r6   )r   r7   rK   r:   rJ   r  rG   r"  r7   rK   r   r  r:   r"  Nrr   r   r#  r   r   r   r   r%   )r   missing_values_classr^   r_   r$  r  
y_nan_preds          r   /test_missing_values_best_splitter_three_classesr,  t	  s     
26(Q,!;!;!;;<==?A
&'!+qcAg5a?@@A
 bA
S
S
SCGGAqMMMX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|           }|                    ||           t          j        t           j        d	t           j        gg          j        }|                    |          }t          |g d
           dS )zMissing values spanning only one class at fit-time must make missing
    values at predict-time be classified has belonging to this class.r6   r   r7   rK   r:   r6   r9   r   r7   rH   r   rK   r  r9   )r   r7   r   Nr)  r   r^   r_   r$  r  r  s         r   )test_missing_values_best_splitter_to_leftr0  	  s     	26(Q,!3!3!334557A
!qA37"##A
 bA
S
S
SCGGAqMMMX26*+,,.F[[  Fvyyy)))))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|           }|                    ||           t          j        t           j        dd	gg          j        }|                    |          }t          |g d
           dS )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.r6   r.  r7   r   rK   r   r  rN   g333333@r  Nr)  r/  s         r   *test_missing_values_best_splitter_to_rightr2  	  s    
 	26(Q,!3!3!334557A
!qA37"aS1W,--A
 bA
S
S
SCGGAqMMMXS)*++-F[[  Fvyyy)))))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|           }|                    ||           t          j        t           j        ddgg          j        }|                    |          }t          |g d           dS )zNCheck behavior of missing value when there is one missing value in each class.r7   rK   r:   r9   rB   rY   rU   r   r   r   r  gffffff@gA@r  Nr)  r/  s         r   0test_missing_values_missing_both_classes_has_nanr4  	  s     	1aArvr2r2rv>?@@BA
!qA37"##A
 bA
S
S
SCGGAqMMMXT*+,,.F[[  F vyyy)))))r   r	   rm  r   c                 X   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
           d
S # 1 swxY w Y   d
S )z4Check unsupported configurations for missing values.r7   rK   r:   r9   rB   rY   rU   r   r   NzInput X contains NaNr   )rr   r   r#  r   r   r   r   r   )r)  r	   r^   r_   s       r   test_missing_value_errorsr6  	  s     	1aArvr2r2rv>?@@BA
!qA37"##A#Q	z)?	@	@	@  A                 s    BB#&B#c                  V   t           j                                        t           j        }} t          j        | ddddf<   t          j        | ddddf<   t          dd          }|                    | |           |                    |           }|d	k    	                                sJ dS )
z5Smoke test for poisson regression and missing values.Nr9   r   rH   r=   r4   r   r   rR   )
ra   r   r  r   rr   r#  r   r   r   r   )r^   r_   r   r  s       r   test_missing_values_poissonr8  	  s    =qA Accc1fIAccc2gJ
)"
E
E
ECGGAqMMM[[^^FcM       r   c                  >    t          j        | i |\  }}|dk    }||fS )N   )r   make_friedman1)argskwargsr^   r_   s       r   make_friedman1_classificationr>  	  s-    "D3F33DAq	BAa4Kr   zmake_data,Treesample_weight_trainr   c                    d\  }} | |||          \  }}|                                 }t          j                            |          }	t          j        ||	                    ddg|j        ddg          <   t          |||          \  }
}}}|d	k    r t          j        |
j        d
                   }nd} |d|          }|	                    |
||           |
                    ||          }t          t                       |d|                    }|	                    |
|           |
                    ||          }||k    sJ d|d|             dS )zFCheck that trees can deal with missing values have decent performance.)r   rB   r}  FTrT   r   r[   r  r   r   r   NrB   r   r   zscore_native_tree=z! should be strictly greater than )r  rr   r  r>  r#  choicer   r   r   r   r   r   r   )	make_datar!   r?  rH  rW   rX   r^   r_   	X_missingr%  X_missing_trainX_missing_testr   r   r   native_treescore_native_treetree_with_imputerscore_tree_with_imputers                      r   !test_missing_values_is_resiliencerK  	  s    &Iz9
AS  DAq I
)

 2
3
3CGIvIcjj%QWc
jCCD7G1#58 8 84O^Wf f$$ 5a 899$2DEEEKOOOWMOJJJ#)).&AA%9KLLL  /7333/55nfMM 	3333X
XX?VXX 	43333r   c                  ~   t           j                            d          } d}|                     |df          }|                     dd|          }|                     ddg|d	d
g          }|                                                    t                    }||          ||<   |                     |          }t           j	        ||<   ||dddf<   t          |||           \  }}}	}
t          |                               ||	          } |j        ||	          dk    sJ  |j        ||
          dk    sJ dS )z@Check the tree learns when only the missing value is predictive.r   r  rB   rZ   rK   )r  r[   FTgffffff?rO   rA  Nr9   r   g333333?)rr   r  r>  standard_normalr  rB  r  r#  boolr#  r   r   r   r   )r%  rW   r^   r_   X_random_masky_maskX_predictiver  r  r   r   r	   s               r    test_missing_value_is_predictiverR  	
  sM   
)


"
"CI)R11AAAI..A JJt}9tJMMMVVXX__T""F#M22F=&&I&66L6LAaaadG'713'O'O'O$GVWf!s33377IID4:gw''4////4:ff%%------r   zmake_data, Treec                 >   t           j                            d          }d\  }} | |||          \  }}t           j        ||                    ddg|j        ddg          <   t          j        |j        d                   }d	|d
d
d<    |d          }|                    |||            |d          }	|	                    |dd
dd
d
f         |dd
d                    t          |		                    |          |	                    |                     d
S )z=Check sample weight is correctly handled with missing values.r   )r  rB   r}  FTrT   r   rA  rR   NrK   r   r   r7   )
rr   r  r>  r#  rB  r   r   r   r   r   )
rC  r!   r%  rW   rX   r^   r_   r   tree_with_swtree_samples_removeds
             r   test_sample_weight_non_uniformrV  "
  s5    )


"
"C$Iz9yZcRRRDAq @BvAcjj%QWc
j;;< GAGAJ''MM##A#4Q'''LQ7774Q///Qqt!tQQQwZ14a4111(0033\5I5I!5L5LMMMMMr   c                  F   t          d                              t          j        t          j                  } t          d                              t          j        t          j                  }t          j        |           }t          j        |          }||k    sJ d S r!  )r   r   r`   r   r   rg  rh  )r  r  pickle1pickle2s       r   test_deterministic_picklerZ  ?
  s     #22266ty$+NNE"22266ty$+NNEl5!!Gl5!!Ggr   r^   r9   rH   c                 ^   |                      dd          } t          j        d          }t          |d                              | |          }t          |                              |                     dd          |          }t          |j        j        dk              s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           dS )	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=   r7   rH   r   r   NrK   rR   )r  rr   r   r   r   r   r   r   rx   r   flatnonzerorq   rv   )r^   r   r_   r	   tree_ref
leaves_idxs         r   'test_regression_tree_missing_values_toyr_  L
  s   4 	
		"aA
	!A 91EEEII!QOODT{{qyyQ//33Htz"a'(((((DJ'+X^-DRaR-HIII 		!R	'DJ,E,JK J DJ'
3S99999r   c                  $   t          j        d          \  } }t          j                            d          }|                                 }|                    t          j        dt          j                  | dddgf         dz  	          	                    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           dS )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   )r7   r6   )r   r  NrK   rJ   )nr     r   )prK   Q   '   a   [   &   .      e   rc  Y   R   rB  r   E      rd     I   J   3   /   k      K   n   rY   r   h   9      r   rw  O   #   M   Z   rs  ri  rc  ^   rg     rJ   ]   r  rq  r~  r"  rc  rr  m   rx     rB   r  ry  ro  \   4   rY   r  rJ   rJ      ro  r}  r"  r"  r  r  r   rU   rj  N   r"  r  i   r  r   rq  r"  f   r  rc  rj  r7   rn  rG       rw  r  j   r  r   8   r}  rv  >   U   rd  re  P   rp  ?   rH   r  T   r:   r:   L   r  r  r:   r   iHnr   r   r=   r7   rR   )r   	load_irisrr   r  r>  r  r  r   r  r#  rN  r#  r   r   r   r   r   r   rx   r\  rq   rv   r   )r^   r_   r%  rD  maskr  r5  r   r   r	   r^  s              r   +test_classification_tree_missing_values_toyr  v
  s    ...DAq
)


#
#CI<<
'bh
/
/
/1QQQV9q=   fTll 	 fIdO-iLLLGQ h    X  G "&z  D DHWWww/000tz"a'(((((		!R	'DJ,E,JK J DJ'
3S99999r   r  )__doc__r  r  r  rg  r  	itertoolsr   r   r  numpyrr   r   joblib.numpy_pickler   numpy.testingr   sklearnr   r   r	   sklearn.dummyr
   sklearn.exceptionsr   sklearn.imputer   sklearn.metricsr   r   r   sklearn.model_selectionr   sklearn.pipeliner   sklearn.random_projectionr   sklearn.treer   r   r   r   sklearn.tree._classesr   r   r   r   sklearn.tree._treer   r   r   r   r   r    r!   r  sklearn.utilsr"   sklearn.utils._testingr#   r$   r%   r&   r'   r(   sklearn.utils.estimator_checksr)   sklearn.utils.fixesr*   r+   r,   r-   sklearn.utils.validationr.   r   REG_CRITERIONSr   r   r  r5   __annotations__updateSPARSE_TREESr   r  r  y_small_regr^   r_   r   r   r  r`   r  r>  r%  r  r   r[   permr   load_diabetesra   load_digitsrb   rV   make_multilabel_classificationr"  r#  r  X_sparse_posr  y_randomr  X_sparse_mixrj   r"  r   r   r   markparametrizer  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r.  r3  r8  r;  r>  r@  r\  rp  rw  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  sortedr@  intersectionr  r  r  r  r]  r  r  r  r  r  r  r  r  r$  r+  r<  rH  r  rU  rW  r[  rQ  rZ  rq  rs  rF  rz  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r'  r,  r0  r2  r4  r6  r8  r>  r;  rK  rR  ry  r   rV  rZ  r#  r_  r  rc  r   r   <module>r     s       				   $ $ $ $ $ $ $ $       , , , , , , ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ( ( ( ( ( ( - - - - - - ( ( ( ( ( ( U U U U U U U U U U 4 4 4 4 4 4 * * * * * * ; ; ; ; ; ;                                      2 1 1 1 1 1 / / / / / /                K J J J J J            8 7 7 7 7 7%O 5. 	 3, 	
 $&&	4    	      	        "(555666<<<999444:::@@@>>>>>>@@@777444555444555???@@@AAA888444555444444/ 8 P
O
O  6 	"XBx"bAq6Aq6Aq6:"X1v1vjj xiA
t{'((IdO	k$ "8!##
x+,,d#/$'				
v})**k$d#!!!$$DXDbR   l
 ###11$'\S  !1511$$RTJJJRRTT )$+..m(/::Kfm44W--[11$<88$844%H55$84428G$$844 $ $ $N	X 	X 	X	X 	X 	X !1!1!3!344n55, , 65 54,*F F F*
 
 
$ y'8'899n55J J 65 :9J y'8'899,	"0"5	2126	/4	B-r2	    :9 
 
 
4  W W W   2L L L>- - -K K K<!7 !7 !7H?+ ?+ ?+DH H H>F F FB8
 8
 8
 8
v ++1 1 ,+1 ...99W W :9 /.W
 &*:
 :
 :
 :
z ++G G ,+G ...99  :9 /.E E EP0 0 0f9% 9% 9%x= = =(	E 	E 	E*8 *8 *8Z1 1 1h3 3 3$ ++,N ,N ,+,N^ ++	 	 ,+	+ + +$ $ $K K K$( ( (- - -? ? ?"! ! !    *& & & &R l33	 6 6  436
 ffSS->->-K-KI-V-V&W&WXXZ$=>>. . ?> YX. l33$W$W$WXX.990: 0: :9 YX 430:f DEE<EEE~	V	VWW
dDD,DDDnUU   $W$W$WXX.99: : :9 YX :" l33!33~~#F#F HP HP  43HPV     ++, , ,+,
 +++dVn-DEE$ $ FE ,+$$ ++G G ,+G ...99G G :9 /.G? ? ? ++, , ,+,: ++.990 0 :9 ,+0a? a? a?H+ + +8 +dVn-DEE    FE $ vvcc(--//**k:-FFGG  &<>Q%RSSA A TS A HMMOO44&;=O%PQQA A RQ 54A	. 	. 	.: : :% % %P ++fh%788+dVn-D~-UVV  WV 98 ,+4 &R&R&RSS!1!1!3!344	> 	> 54 TS	> q**& & +*&B'0 '0 '0T n55"8 "8 65"8J "8:M!NOOq!f--G G .- POG,( ( (2( ( (4? ? ?$? ? ?"I I I- - -,- - -6@ @ @$
 
 
B1U 1U 1Uh ,o,..0G0@0G0I0IJJ / / /  & !1!1!3!344  54* &GHH5 5 IH52 y&&9::A A ;:A y&&9::* * ;:* y&&9::* * ;:*  y&&9::* * ;:* +dVn-DEE
111(8999 
 
  FE
! ! !   		 "78	&(>?  .v?? Y  Y @?  YF. . .2 		!#89		%'=> N N N,
 
 
  	"&!RVQ1-.."&"&!Q1-..!Q1bfbf-..!Q261bf-..
 
 &GHH: : IH
 
:<,: ,: ,: ,: ,:r   