Skip to content
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

Fixed Large memory requirements for SimpleImputer strategy median #4794 #4817

Merged
merged 10 commits into from
Aug 11, 2022
12 changes: 9 additions & 3 deletions python/cuml/thirdparty_adapters/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,16 +295,22 @@ def _masked_column_median(arr, masked_value):
mask = _get_mask(arr, masked_value)
if arr.size == 0:
return cp.full(arr.shape[1], cp.nan)
arr_sorted = arr.copy()
if not cp.isnan(masked_value):
arr_sorted = arr.copy()
# If nan is not the missing value, any column with nans should
# have a median of nan
nan_cols = cp.any(cp.isnan(arr), axis=0)
arr_sorted[mask] = cp.nan
arr_sorted.sort(axis=0)
else:
nan_cols = cp.full(arr.shape[1], False)
# nans are always sorted to end of array
arr_sorted = cp.sort(arr_sorted, axis=0)
<<<<<<< HEAD
wphicks marked this conversation as resolved.
Show resolved Hide resolved
# nans are always sorted to end of array and the sort call
# copies the data
=======
# nans are always sorted to end of array and the sort call copies the data
>>>>>>> febd55587f1aed5b9728210412472c5cd94d4f6c
arr_sorted = cp.sort(arr_sorted, axis=0)
erikrene marked this conversation as resolved.
Show resolved Hide resolved

count_missing_values = mask.sum(axis=0)
# Ignore missing values in determining "halfway" index of sorted
Expand Down