� K�g� ��"�ddlZddlmZdd�ZdS)�N�)� stable_cumsum�2c�~� � � �|j}|dkr|dS|jdkr|�d��}|j|jkrC|jd|jdkr'tj||jddf��j}tj|d���}tj||d���}t|d���� |dz � dz� � dk}tj � |� |dz��� |<tj � � fd�t� jd��D����}tj |��}|jddz � tj � fd �d|� ��}tj |jd��}|||f} || |f}|dkr|dn|S) a�Compute weighted percentile Computes lower weighted percentile. If `array` is a 2D array, the `percentile` is computed along the axis 0. .. versionchanged:: 0.24 Accepts 2D `array`. 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: int or float, default=50 Percentile to compute. Must be value between 0 and 100. Returns ------- percentile : int if `array` 1D, ndarray if `array` 2D Weighted percentile. r�r)�����r)�axis�drc�Z��g|]'}tj�dd�|f�|����(S)N)�np� searchsorted)�.0�i�adjusted_percentile� weight_cdfs ���c/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/sklearn/utils/stats.py� <listcomp>z(_weighted_percentile.<locals>.<listcomp>9sH��� � � �� �O�J�q�q�q�!�t�,�.A�!�.D� E� E� � � �c�0��tj|d���S)Nr)r �clip)�x�max_idxs �r�<lambda>z&_weighted_percentile.<locals>.<lambda>Bs���"�'�!�Q��(�(�r)r �arr)�ndim�reshape�shaper �tile�T�argsort�take_along_axisr� nextafter�array�range�apply_along_axis�arange) r#� sample_weight� percentile�n_dim� sorted_idx�sorted_weights�mask�percentile_idx� col_index�percentile_in_sortedrrrs @@@r�_weighted_percentiler0 s������4 �J�E� ��z�z��R�y�� �z�Q���� � �g�&�&�� �{�m�)�)�)�e�k�!�n� �@S�TU�@V�.V�.V��� �� �A���/B�C�C�E� ���E��*�*�*�J��'� �z��J�J�J�N��~�A�6�6�6�J�$�s�*�Z��^�;�� �!� #�D� "� ��D�!�#6�t�#<�q�#@�!�!�����X� � � � � ��:�+�A�.�/�/� � � ���N� �X�n�-�-�N���q�!�A�%�G��(�(�(�(�(�q�n����N�� �%�+�a�.�)�)�I�%�n�i�&?�@���+�Y�6�7�J�!�Q�J�J�:�a�=�=�J�6r)r)�numpyr �extmathrr0rrr�<module>r3sC������"�"�"�"�"�"�?7�?7�?7�?7�?7�?7r
Memory