o
    Ú­jW  ã                   @   s  d Z ddlmZ ddlZddlmZ ddlmZm	Z	 dej
defd	d
„Zdej
defdd„Z	ddedee defdd„ZdZejjed�Zejjed�Ze eef¡Zejjdded�Zde e dej e ¡ de  e dej e ¡ e Ze	eed�ZdS )z)Helpers for testing monotone constraints.é    )ÚOptionalNé   )ÚFeatureNames)ÚBoosterÚDMatrixÚvÚreturnc                 C   s   t  t  | ¡dk ¡dkS )zWhether is v increasing.ç        r   ©ÚnpÚcount_nonzeroÚdiff©r   © r   úa/var/www/html/CropPilot/venv/lib/python3.10/site-packages/xgboost/testing/monotone_constraints.pyÚis_increasing   ó   r   c                 C   s   t  t  | ¡dk¡dkS )zWhether is v decreasing.r	   r   r
   r   r   r   r   Úis_decreasing   r   r   ÚlearnerÚfeature_namesc                 C   s°   d}t  dd|¡ |df¡}t  dd|¡}t|ƒD ]<}|| t  |df¡ }t  ||f¡}t||d�}|  |¡}	t  ||f¡}
t|
|d�}|  |¡}t|	ƒrRt	|ƒsU dS qdS )z5Whether the monotone constraint is correctly applied.éd   r   é   )r   FT)
r   ÚlinspaceÚreshapeÚrangeÚonesÚcolumn_stackr   Úpredictr   r   )r   r   ÚnÚ
variable_xÚfixed_xs_valuesÚiÚfixed_xÚmonotonically_increasing_xÚmonotonically_increasing_dsetÚmonotonically_increasing_yÚmonotonically_decreasing_xÚmonotonically_decreasing_dsetÚmonotonically_decreasing_yr   r   r   Úis_correctly_constrained   s,   ÿ
ÿ
ÿþür)   iè  )Úsizer	   g{®Gáz„?)ÚlocÚscaler*   é   é
   )Úlabel)N)Ú__doc__Útypingr   Únumpyr   Ú_typingr   Úcorer   r   ÚndarrayÚboolr   r   r)   ÚNUMBER_OF_DPOINTSÚrandomÚx1_positively_correlated_with_yÚx2_negatively_correlated_with_yr   ÚxÚnormalÚzsÚsinÚpiÚcosÚyÚtraining_dsetr   r   r   r   Ú<module>   s>    ÿÿÿ
þÿþýüÿ