
    Ki%                          S SK JrJr   SS jrg)    )_find_matching_floating_dtypeget_namespace_and_deviceNc                 >   [        U 5      u  pEn[        XS9nUR                  XUS9n UR                  XUS9nUR                  X'US9nU R                  nUS:X  a  U $ U R                  S:X  a  UR	                  U S5      n U R
                  UR
                  :w  aJ  U R
                  S   UR
                  S   :X  a*  UR                  XR
                  S   S45      R                  nUR                  n	U	S:X  a  UR	                  US5      nUR                  U SSS9n
UR                  XSS	9nU R
                  S   nU U
S
   UR                  XS94   nUR                  UR                  U5      5      (       a$  UR                  UR                  U 5      U
SS	9nSX'   UR                  UR                  SS	9nUR
                  S   nUR                  UU4XvS9n[        U5       GH  u  nnUS-  US   -  nUS:H  nUR!                  UU   UU   S-   5      UU'   UR#                  [%        UR
                  S   5       Vs/ s H  nUR'                  UUS4   UU   5      PM     sn5      nU
R
                  S   S-
  nUR)                  USU5      nUR                  U R
                  S   US9nU
UU4   nU(       a  UUU4   U-
  nUUR+                  U5      R,                  :  nUR)                  US-   SU5      nU
UU4   nUUUU4   S:H     nU H8  n UU UU    4   n!UR'                  UU S4   U!SS9n"U"U:  a  UU    n"U
U"U 4   UU '   M:     UR/                  UU UU4   U UU4   U UU4   -   S-  5      USU4'   GM  U UU4   USU4'   GM     U	S:X  a  US   nUS:X  a  US   $ U$ s  snf )a  Compute the weighted percentile.

Implement an array API compatible (weighted version) of NumPy's 'inverted_cdf'
method when `average=False` (default) and 'averaged_inverted_cdf' when
`average=True`.

For an array ordered by increasing values, when the percentile lies exactly on a
data point:

* 'inverted_cdf' takes the exact data point.
* 'averaged_inverted_cdf' takes the average of the exact data point and the one
  above it (this means it gives the same result as `median` for unit weights).

E.g., for the array [1, 2, 3, 4] the percentile rank at each data point would
be [25, 50, 75, 100]. Percentile rank 50 lies on '2'. 'average_inverted_cdf'
computes the average of '2' and '3', making it 'symmetrical' because if you
reverse the array, rank 50 would fall on '3'. It also matches 'median'.
On the other hand, 'inverted_cdf', which does not satisfy the symmetry property,
would give '2'.

When the requested percentile lies between two data points, both methods return
the higher data point.
E.g., for the array [1, 2, 3, 4, 5] the percentile rank at each data point would
be [20, 40, 60, 80, 100]. Percentile rank 50, lies between '2' and '3'. Taking the
higher data point is symmetrical because if you reverse the array, 50 would lie
between '4' and '3'. Both methods match median in this case.

If `array` is a 2D array, the `values` are selected along axis 0.

`NaN` values are ignored by setting their weights to 0. If `array` is 2D, this
is done in a column-isolated manner: a `NaN` in the second column, does not impact
the percentile computed for the first column even if `sample_weight` is 1D.

    .. versionchanged:: 0.24
        Accepts 2D `array`.

    .. versionchanged:: 1.7
        Supports handling of `NaN` values.

    .. versionchanged:: 1.8
        Supports `average`, which calculates percentile using the
        "averaged_inverted_cdf" method.

Parameters
----------
array : 1D or 2D array
    Values to take the weighted percentile of.

sample_weight: 1D or 2D array
    Weights for each value in `array`. Must be same shape as `array` or of shape
    `(array.shape[0],)`.

percentile_rank: scalar or 1D array, default=50
    The probability level(s) of the percentile(s) to compute, in percent. Must be
    between 0 and 100. If a 1D array, computes all percentiles (along each
    axis 0 if `array` is 2D).

average : bool, default=False
    If `True`, uses the "averaged_inverted_cdf" quantile method, otherwise
    defaults to "inverted_cdf". "averaged_inverted_cdf" is symmetrical with
    unit `sample_weight`, such that the total of `sample_weight` below or equal to
    `_weighted_percentile(percentile_rank)` is the same as the total of
    `sample_weight` above or equal to `_weighted_percentile(100-percentile_rank)`.
    This symmetry is not guaranteed with non-unit weights.

xp : array_namespace, default=None
    The standard-compatible namespace for `array`. Default: infer.

Returns
-------
percentile : scalar, 1D array, or 2D array
    Weighted percentile at the requested probability level(s).
    If `array` is 1D and `percentile_rank` is scalar, returns a scalar.
    If `array` is 2D and `percentile_rank` is scalar, returns a 1D array
        of shape `(array.shape[1],)`
    If `array` is 1D and `percentile_rank` is 1D, returns a 1D array
        of shape `(percentile_rank.shape[0],)`
    If `array` is 2D and `percentile_rank` is 1D, returns a 2D array
        of shape `(array.shape[1], percentile_rank.shape[0])`
)xp)dtypedevicer      )r	   )r	   F)axisstable)r   )r
   .)r   d   ).r
   .right)side   ).r   )r   .)r   r   asarrayndimreshapeshapetileTargsorttake_along_axisarangeanyisnancumulative_sumempty	enumerate	nextafterstackrangesearchsortedclipfinfoepswhere)#arraysample_weightpercentile_rankaverager   _r   floating_dtypen_dimn_dim_percentile
sorted_idxsorted_weights
n_featureslargest_value_per_columnsorted_nan_mask
weight_cdfn_percentilesresultp_idxp_rankadjusted_percentile_rankmaskfeature_idxpercentile_indicesmax_idxcol_indicespercentile_in_sortedfraction_aboveis_fraction_abovepercentile_plus_one_indicespercentile_plus_one_in_sortedzero_weight_colscol_idxcdf_val
next_indexs#                                      U/var/www/html/dynamic-report/venv/lib/python3.13/site-packages/sklearn/utils/stats.py_weighted_percentilerI   
   s   f -U3MB625@NJJu6JBEJJ}6JRMjjvjVOJJEzzzQ

5'*{{m)))ekk!n@S@STU@V.VA/BCEE&++1**_d; E%8J'''JN QJ$7RYYzYAA  
vvbhh/011,,RXXe_jq,Q*+' "">#3#3!"<J#))!,MXXz=1XWF"?3v#)C<*W2E#E  (1,)+$T*,DT,JQ,N*
 &  XX
 $))9)9!)<#=	 $>K {C/02J;2W $>	
 ""1%)WW%7GDiiAvi>)*<k*IJ ;(::;>VV  !/.1I1M1M M*,''2Dq2H!W*U',6+[8-)  +;[HIQN  ,$W.@.I%IJ__w|,gG - 

 (!3G!<J9CJPWDW9X-g6 , "$!*K78.;<9;FGH 	"F3: "'';['H!IF3:I 4L 1"aZ6&>3V3us   6$N
)2   FN)sklearn.utils._array_apir   r   rI        rH   <module>rN      s    AEK4rM   