100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Data Analysis & Feature Engineering
30 minintermediate

Encoding Categorical Variables

Most machine-learning algorithms require numeric input, yet real data is full of categorical variables — player roles, team names, pitch types — so encoding categories into numbers is an unavoidable and consequential step. Encoding exists because the way categories are converted to numbers directly shapes what a model can learn: a clumsy encoding can invent false orderings, explode the feature space, or leak the target, while a good encoding preserves the category's information without introducing artefacts. The challenge is that different categorical variables demand different encodings — nominal categories with no order need one approach, ordinal categories with a natural order another, and high-cardinality categories a third — and applying the wrong one degrades models in subtle ways. Mastering the main encoding schemes and when each applies is foundational to turning categorical data into model-ready features without distortion.

Analogy🏏Cricket
🏏 Think of it like cricket: Reducing twenty batting statistics to two dimensions with PCA produces a flat projection that may look like one undifferentiated cloud, while t-SNE or UMAP finds that the data actually organises into distinct clusters — aggressive pinch-hitters, steady anchors, explosive finishers — whose separation PCA's flat projection smeared together. Just as the non-linear reduction reveals the natural groupings that flat projection could not, t-SNE and UMAP reveal structure that PCA misses because it can only flatten, not curve to follow the data's natural shape. The insight is that non-linear reduction methods follow the data's true curved geometry rather than forcing a flat projection, revealing the cluster structure and local neighbourhoods that linear methods like PCA cannot preserve.
Lesson 8 of 35
0% complete