alteryx / alteryx/evalml

Allow OrdinalEncoder to have unsorted numeric categories

Aperta
#3,838 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
new feature
Lingua principale
Python
Stelle
850
Fork
96
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

- 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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.