
    ^iT                     t    d 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
ededdfdZd
ededdfdZy)zTests for parsing trees.    N   )DMatrix)XGBRegressor)train   )make_categorical)Devicetree_methoddevicereturnc                     t        dddd      \  }}t        ||d      }t        | |d|d	      }|j                         }|j	                         D ]!  \  }}|d
   dk7  st        |d         dk\  r!J  y)z+Tests tree_to_df with categorical features.d   
      FonehotT)enable_categorical)r
   r   )num_boost_roundFeatureLeafCategoryr   N)r   r   r   trees_to_dataframeiterrowslen)	r
   r   XyXyboosterdf_xs	            [/var/www/html/hubwallet-dev/venv/lib/python3.12/site-packages/xgboost/testing/parse_tree.pyrun_tree_to_df_categoricalr#      s    CR6DAq	A$	/B#v6BG 
	#	#	%B +1Y<6!q}%***+    c                 
   t        dddd      \  }}t        | d|      }|j                  ||       t        j                  t
        d	      5  |j                         j                  d
d       ddd       y# 1 sw Y   yxY w)z7Tests split_value_histograms with categorical features.i  r      Fr   T)r
   r   r   zdoesn't)match3   )binsN)r   r   fitpytestraises
ValueErrorget_boosterget_split_value_histogram)r
   r   r   r   regs        r"   run_split_value_histogramsr2      ss    D"b7DAq
;4PV
WCGGAqM	z	3 A33Ca3@A A As   "A99B)__doc__r,   corer   sklearnr   trainingr   datar   utilsr	   strr#   r2    r$   r"   <module>r;      sR       "  " 
+C 
+ 
+D 
+AC A AD Ar$   