DEV Community

Mohammed Galalen
Mohammed Galalen

Posted on

1 1

Categorical Variables and Cardinality

One approach to deal with categorical variables is One-Hot Encoding.
But there is an important thing to keep in mind when using it.
Cardinality and it means the number of unique values in a column.

It's always better to create a one-hot encoding for columns with lower cardinality because in a large dataset one-hot encoding can expand the size of the dataset.

High cardinality columns can either be dropped from the dataset, or we can use label encoding.

Alt Text

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay