Skip to content

Commit

Permalink
Simplify some logic in LabelEncoder (#5648)
Browse files Browse the repository at this point in the history
I accidentally committed but forgot to push some changes requested by @csadorf in #5639.

Authors:
  - Vyas Ramasubramani (https://github.com/vyasr)
  - Simon Adorf (https://github.com/csadorf)

Approvers:
  - Simon Adorf (https://github.com/csadorf)

URL: #5648
  • Loading branch information
vyasr authored Nov 14, 2023
1 parent 325a7e6 commit a5b839f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions python/cuml/preprocessing/LabelEncoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,19 +171,19 @@ def fit(self, y, _classes=None):
A fitted instance of itself to allow method chaining
"""
if _classes is None:
y = self._to_cudf_series(y)

self._validate_keywords()

self.dtype = y.dtype if y.dtype != cp.dtype("O") else str
if _classes is not None:
self.classes_ = _classes
else:
self.classes_ = y.drop_duplicates().sort_values(
ignore_index=True
if _classes is None:
y = (
self._to_cudf_series(y)
.drop_duplicates()
.sort_values(ignore_index=True)
) # dedupe and sort
self.classes_ = y
else:
self.classes_ = _classes

self.dtype = y.dtype if y.dtype != cp.dtype("O") else str
self._fitted = True
return self

Expand Down

0 comments on commit a5b839f

Please sign in to comment.