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

Skip to content

FIX Fix ranking for scipy >= 1.10. #24483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions sklearn/model_selection/_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -965,11 +965,12 @@ def _store(key_name, array, weights=None, splits=False, rank=False):
results["std_%s" % key_name] = array_stds

if rank:
rank_result = rankdata(-array_means, method="min")
# when input is nan, scipy >= 1.10 rankdata returns nan. To
# keep previous behaviour nans are set to the
# maximum possible rank
rank_result[np.isnan(rank_result)] = len(rank_result)
# keep previous behaviour nans are set to be smaller than the
# minimum value in the array before ranking
min_array_means = min(array_means) - 1
array_means = np.nan_to_num(array_means, copy=True, nan=min_array_means)
rank_result = rankdata(-array_means, method="min")
rank_result = np.asarray(rank_result, dtype=np.int32)
results["rank_%s" % key_name] = rank_result

Expand Down