alteryx / alteryx/evalml

Allow OrdinalEncoder to have unsorted numeric categories

Offen
#3,838 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
new feature
Vorherrschende Sprache
Python
Sterne
850
Forks
96
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

- As a user, I wish I could use the Ordinal Encoder to encode Ordinal columns whose categories' orders are not in strictly increasing numeric order.

The following code raises the error `ValueError: Unsorted categories are not supported for numerical categories`

```python
X = pd.DataFrame(
{
"col_1": [2, 0, 1, 0, 0],
"col_2": ["a", "b", "a", "c", "d"],
"col_3": ["x", "x", "x", "y", "y"],
"col_4": [1, 2, 2, 3, 1],
},
)
# The order is 3, 2, 1 instead of 1, 2, 3
X.ww.init(logical_types={"col_2": Ordinal(order=["a", "b", "c", "d"]), "col_4": Ordinal(order=[3, 2, 1])})

encoder = OrdinalEncoder()
encoder.fit(X)
```

This isn't a super uncommon situation where numbers have been assigned to ordered categories in the reverse order of the relative sizes of the categories. We should be able to handle that case.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.