
    siiA                         d Z ddlmZ ddlZddlmZ ddlmZ ddl	m
Z
 dd	lmZ dd
lmZ ddlmZ dedee         dej        fdZdeddfdZdS )zTests for inference.    )TypeN)logit   )DMatrix)train   )validate_leaf_output)get_basescore)DevicedeviceDMatrixTreturnc                    d}d}d}d}d}t           j                            d          }|                    ||          }|                    d||          }	 |||	          }
t          ||dd	|
|
          }|                    d| i            |t          j        d|f                    }|                    |d          }|j	        d         dk    sJ |                    |
dd          }|j	        d         |k    sJ |j	        d         |k    sJ |j	        d         |k    sJ |j	        d         |k    sJ t          ||           t          j        d          }|                    |
dd|fd          }|d         }t          j        |j	                  ||z  |z  k    sJ t          ddid|
          }|                    d| i           |                    |
d          j	        |fk    sJ |S )z$Run tests for leaf index prediction.d         
   i  r   )lowhighsizehist)num_parallel_tree	num_classtree_method)num_boost_roundr   )shapeT)	pred_leaf)r   strict_shaper   r      )r   iteration_ranger   )r   .r   )r   dtrain)nprandomRandomStaterandnrandintr   	set_paramonespredictr   r	   int32prod)r   r   rowscolsclassesr   r   rngXymboosterempty
empty_leafleafn_itersslicedfirsts                     ]/var/www/html/bet.cuttalo.com/ml/venv/lib/python3.11/site-packages/xgboost/testing/predict.pyrun_predict_leafr;      sN   DDGO
)


%
%C		$Ad33AAA!2 !	
 	

 	
'  G x()))HRWAt9---..E$77JA!####??14?@@D:a=D    :a=O++++:a=G####:a=-----0111hqkkG__	G	   F 6NE75;7->#>#HHHHH ]F+QqIIIGx()))??1?--3w>>>>K    c                    ddl m} d} |d          \  }}t          |d| dt          ||          d	          }t          j                            t          |          |           |                    t          ||                    }t	          j	        |j
        t          |          t          j        
          }t          |||          }t          dd| d|d	          }t          j                            t          |          d           |                    |          }	t          j                            ||	           dS )z/Test for the relation between score and margin.r   )make_classificationg      ?i  )random_statezbinary:logistic)
base_score	objectiver   r   )r!   r   )
fill_valuedtype)base_marging?N)sklearn.datasetsr>   r   r   r"   testingassert_allcloser
   r)   fullr   r   float32)
r   r>   	interceptr0   r1   r3   predt_0marginXypredt_1s
             r:   run_base_margin_vs_base_scorerO   F   sJ   444444ID111DAq /@FSSq!}}  G
 J}W55yAAAoogamm,,GWQWy)9)9LLLF	A6	*	*	*B):fMM  G
 J}W55s;;;oob!!GJw00000r<   )__doc__typingr   numpyr"   scipy.specialr   corer   trainingr   sharedr	   updaterr
   utilsr   ndarrayr;   rO    r<   r:   <module>r[      s                                  ( ( ( ( ( ( " " " " " "      3V 3tG} 3 3 3 3 3l1& 1T 1 1 1 1 1 1r<   