
    siiW                        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	Zdej
        defd
Z	 ddedee         defdZdZej                            e          Zej                            e          Z ej        eef          Zej                            dde          Zdez   ej        dej        z  ez            z   dez  z
   ej        dej        z  ez            z
  ez   Z e	ee          ZdS )z)Helpers for testing monotone constraints.    )OptionalN   )FeatureNames)BoosterDMatrixvreturnc                 ^    t          j        t          j        |           dk               dk    S )zWhether is v increasing.        r   npcount_nonzerodiffr   s    j/var/www/html/bet.cuttalo.com/ml/venv/lib/python3.11/site-packages/xgboost/testing/monotone_constraints.pyis_increasingr      %    BGAJJ,--22    c                 ^    t          j        t          j        |           dk              dk    S )zWhether is v decreasing.r   r   r   r   s    r   is_decreasingr      r   r   learnerfeature_namesc                     d}t          j        dd|                              |df          }t          j        dd|          }t          |          D ]}||         t          j        |df          z  }t          j        ||f          }t          ||          }|                     |          }	t          j        ||f          }
t          |
|          }|                     |          }t          |	          rt          |          s dS 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_ys                r   is_correctly_constrainedr-      s2    	AQ1%%--q!f55Jk!Q**O1XX  !!$rw1v6%'_j'5J%K%K"(/&m)
 )
 )
% &-__5R%S%S"%'_gz5J%K%K"(/&m)
 )
 )
% &-__5R%S%S" 455	899	 55		 4r   i  )sizer   g{Gz?)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_dset r   r   <module>rH      s   / /           " " " " " " # # # # # # # #3RZ 3D 3 3 3 3
3RZ 3D 3 3 3 3 ?C %-l%;	   >  "$)"2"28I"2"J"J "$)"2"28I"2"J"J BO46UVWWY#T0ABB''bfR"%Z99::;
))* bfR"%Z99::; 			  ###r   