Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 2 additions & 4 deletions python/cuml/cuml/dask/neighbors/kneighbors_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,8 @@ def fit(self, X, y):
uniq_labels.append(_y.iloc[:, i].unique())

uniq_labels = da.compute(uniq_labels)[0]
if hasattr(uniq_labels[0], "values_host"): # for cuDF Series
uniq_labels = list(map(lambda x: x.values_host, uniq_labels))
elif hasattr(uniq_labels[0], "values"): # for pandas Series
uniq_labels = list(map(lambda x: x.values, uniq_labels))
if hasattr(uniq_labels[0], "to_numpy"): # for pandas and cuDF Series
uniq_labels = list(map(lambda x: x.to_numpy(), uniq_labels))
elif isinstance(uniq_labels[0], cp.ndarray): # for CuPy arrays
uniq_labels = list(map(lambda x: cp.asnumpy(x), uniq_labels))
self.uniq_labels = np.sort(np.array(uniq_labels))
Expand Down
2 changes: 1 addition & 1 deletion python/cuml/cuml/preprocessing/LabelEncoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def inverse_transform(self, y: "cudf.Series"):
category_num = len(self.classes_)
if self.handle_unknown == "error":
if not isinstance(ord_label, (cp.ndarray, np.ndarray)):
ord_label = ord_label.values_host
ord_label = ord_label.to_numpy()
for ordi in ord_label:
if ordi < 0 or ordi >= category_num:
raise ValueError(
Expand Down
2 changes: 1 addition & 1 deletion python/cuml/cuml/preprocessing/TargetEncoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ def _rename_col(df, col):
res = []
unq_vals = train[self.fold_col].unique()
if not isinstance(unq_vals, (cp.ndarray, np.ndarray)):
unq_vals = unq_vals.values_host
unq_vals = unq_vals.to_numpy()
for f in unq_vals:
mask = train[self.fold_col].values == f
dg = train.loc[~mask].groupby(x_cols).agg({self.y_col: self.stat})
Expand Down
2 changes: 1 addition & 1 deletion python/cuml/cuml/preprocessing/encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ def get_feature_names(self, input_features=None):
feature_names = []
for i in range(len(cats)):
names = [
input_features[i] + "_" + str(t) for t in cats[i].values_host
input_features[i] + "_" + str(t) for t in cats[i].to_numpy()
]
if self.drop_idx_ is not None and self.drop_idx_[i] is not None:
names.pop(self.drop_idx_[i])
Expand Down
2 changes: 1 addition & 1 deletion python/cuml/cuml/testing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ def from_df_to_numpy(df):
if isinstance(df, pd.DataFrame):
return list(zip(*[df[feature] for feature in df.columns]))
else:
return list(zip(*[df[feature].values_host for feature in df.columns]))
return list(zip(*[df[feature].to_numpy() for feature in df.columns]))


def compare_svm(
Expand Down
4 changes: 2 additions & 2 deletions python/cuml/tests/test_one_hot_encoder.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright (c) 2020-2025, NVIDIA CORPORATION.
# SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION.
# SPDX-License-Identifier: Apache-2.0
import math

Expand Down Expand Up @@ -26,7 +26,7 @@ def _from_df_to_cupy(df):
df[col] = [ord(c) for c in df[col]]
else:
df[col] = [
ord(c) if c is not None else c for c in df[col].values_host
ord(c) if c is not None else c for c in df[col].to_numpy()
]
return cp.array(from_df_to_numpy(df))

Expand Down
2 changes: 1 addition & 1 deletion python/cuml/tests/test_train_test_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_split_dataframe(train_size, shuffle):
y_reconstructed = cudf.concat([y_train, y_test]).sort_values()

assert all(X_reconstructed.reset_index(drop=True) == X)
out = y_reconstructed.reset_index(drop=True).values_host == y.values_host
out = y_reconstructed.reset_index(drop=True).to_numpy() == y.to_numpy()
assert all(out)


Expand Down