Thanks to visit codestin.com
Credit goes to github.com

Skip to content

_weighted_percentile NaN handling with array API #31368

@lucyleeow

Description

@lucyleeow

There isn't necessarily anything to fix here, but I thought it would be useful to open this for documentation, at least.


_weighted_percentile added support for NaN in #29034 and support for array APIs in #29431.

Our implementation relys on sort putting NaN values at the end:

largest_value_per_column = array[
sorted_idx[-1, ...], xp.arange(n_features, device=device)
]
# NaN values get sorted to end (largest value)
if xp.any(xp.isnan(largest_value_per_column)):

AFAICT (confirmed by @ev-br) array API specs do not specify how sort should handle NaN, which means it is left to individual packages to determine.

As everything works, I don't think we need to do anything here (especially as we ultimately want to drop maintaining our own quantile function), but just thought it would be useful to document.

cc @StefanieSenger @ogrisel

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions