CoolFace
Apppublic

Aluode/PerceptionLabPortable

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
stats.cpython-310.pyc55 linesDownload Raw Back to __pycache__
1o

2�Yi%�@s(ddlmZmZddd�Zddd�ZdS)	�)�_find_matching_floating_dtype�get_namespace_and_device�2Ncs�t|�\�}}t|�d�}�j|||d�}�j|||d�}|j}|dkr&|S|jdkr1��|d�}|j|jkrM|jd|jdkrM��||jddf�j}�j|dd�}�j	||dd�}	|jd}3||d�j4|5|d�f}����|��r��j	��|�|dd�}d|	|<�j
|	jdd��|d	�d6��dk}
���|
�|
d��|
<�����fdd�t�jd�D��}|jdd}��|d|�}�j7|jd|d�}|||f}|||f}|dkr�|dS|S)
a3Compute the weighted percentile with method 'inverted_cdf'.8 9    When the percentile lies between two data points of `array`, the function returns10    the lower value.11 12    If `array` is a 2D array, the `values` are selected along axis 0.13 14    `NaN` values are ignored by setting their weights to 0. If `array` is 2D, this15    is done in a column-isolated manner: a `NaN` in the second column, does not impact16    the percentile computed for the first column even if `sample_weight` is 1D.17 18        .. versionchanged:: 0.2419            Accepts 2D `array`.20 21        .. versionchanged:: 1.722            Supports handling of `NaN` values.23 24    Parameters25    ----------26    array : 1D or 2D array27        Values to take the weighted percentile of.28 29    sample_weight: 1D or 2D array30        Weights for each value in `array`. Must be same shape as `array` or of shape31        `(array.shape[0],)`.32 33    percentile_rank: int or float, default=5034        The probability level of the percentile to compute, in percent. Must be between35        0 and 100.36 37    xp : array_namespace, default=None38        The standard-compatible namespace for `array`. Default: infer.39 40    Returns41    -------42    percentile : scalar or 0D array if `array` 1D (or 0D), array if `array` 2D43        Weighted percentile at the requested probability level.44    ��xp)Zdtype�device��)�����r	)Zaxis)r45.)r�d).r46cs$g|]}���|df�|��qS).)Zsearchsorted)�.0Zfeature_idx�Zadjusted_percentile_rankZ47weight_cdfr��}E:\DocsHouse\542 percep lab latest\PerceptionLab\PerceptionLab_Portable\python_embed\Lib\site-packages\sklearn/utils/stats.py�48<listcomp>as���z(_weighted_percentile.<locals>.<listcomp>)rrZasarray�ndimZreshape�shapeZtile�TZargsortZtake_along_axisZarange�any�isnanZcumulative_sum�	nextafter�stack�rangeZclip)�array�
sample_weight�percentile_rankr�_rZfloating_dtypeZn_dimZ49sorted_idxZsorted_weightsZ50n_featuresZlargest_value_per_columnZsorted_nan_mask�maskZpercentile_indicesZmax_idxZcol_indicesZpercentile_in_sorted�resultrr
r�_weighted_percentile51sJ'52 53�	���	rcCs*t||||d�t||d||d�dS)Nrrr)r)rrrrrrr�_averaged_weighted_percentilevs54��r )rN)Zutils._array_apirrrr rrrr�<module>s55l