
    =[g0
                         d Z ddlZddlZddlmZ ddlmZ	 ddl
mZ ddlZddlmZ deded	dfd
Zdeded	dfdZdeded	dfdZdededed	dfdZy)z0Tests for dask shared by different test modules.    N)array)	dataframe)Client)get_basescoretree_methodclientreturnc                    ddl m}  |ddd      \  }}t        j                  dd|       }|j	                  ||       t        |      }t        j                  |      j                  d	
      }t        j                  |      j                  d
      }t        j                  j                  dd|       }	||	_        |	j	                  ||       t        |	      }
t        j                  j                  ||
       y)z%Test init estimation for classsifier.r   )make_classification          	n_samples
n_featuresrandom_state   n_estimators	max_depthr   r   Nchunksr   N)sklearn.datasetsr   xgbXGBClassifierfitr   da
from_arrayrechunkdaskDaskXGBClassifierr   nptestingassert_allclose)r   r   r   Xyclf
base_scoredxdydclfdbase_scores              O/var/www/html/bid-api/venv/lib/python3.12/site-packages/xgboost/testing/dask.pycheck_init_estimation_clfr0      s    4btTDAq


a[
QCGGAqMs#J	q		!	!	!	4B	q		!	!	!	/B88%%! & D DKHHR%KJJz;7    c                    ddl m}  |ddd      \  }}t        j                  dd|       }|j	                  ||       t        |      }t        j                  |      j                  d	
      }t        j                  |      j                  d
      }t        j                  j                  dd|       }	||	_        |	j	                  ||       t        |	      }
t        j                  j                  ||
       y)z#Test init estimation for regressor.r   )make_regressionr   r   r   r   r   r   r   r   r   N)r   r3   r   XGBRegressorr   r   r   r    r!   r"   DaskXGBRegressorr   r$   r%   r&   )r   r   r3   r'   r(   regr*   r+   r,   dregr.   s              r/   check_init_estimation_regr8   !   s    0 X"4PDAq


QK
PCGGAqMs#J	q		!	!	!	4B	q		!	!	!	/B88$$! % D DKHHR%KJJz;7r1   c                 4    t        | |       t        | |       y)zTest init estimation.N)r8   r0   )r   r   s     r/   check_init_estimationr:   6   s    k62k62r1   	n_workersc           	         |dk\  sJ | j                         5  t        j                  j                  |      }t	        j
                  t        d      t        ddd      d      }t	        j                  g dgdz  dgdz        }t        j                  |d	   d
dd<   | j                  |       |j                  t        j                  ||      t        j                  ||             d
d
d
       y
# 1 sw Y   y
xY w)z0Issue #9271, not every worker has missing value.   )r   i'  r   )abi  r   r?   Ni  i  )r;   )npartitions)
as_currentr   r"   r#   pd	DataFramerangeSeriesr$   nanwait_for_workersr   ddfrom_pandas)r   r   r;   r)   r'   r(   s         r/   check_uneven_nanrK   <   s    >>				hh(([(ALLuU|%q"2EFGII0d
0aS4Z01VV#zTz)4NN1)4NN1)4	
 
		s   CC66C?)__doc__numpyr$   pandasrC   r"   r   r   r   rI   distributedr   xgboostr   xgboost.testing.updaterr   strr0   r8   r:   intrK    r1   r/   <module>rU      s    6        183 8 84 8(83 8 84 8*3s 3F 3t 3
V 
# 
# 
$ 
r1   