Learn Before
Example

One-Hot Encoding of Categorical Features Example

To prepare discrete categorical features for machine learning models, they are often transformed using one-hot encoding. For instance, consider a categorical feature like 'MSZoning' that assumes the values 'RL' and 'RM'. By dropping the original 'MSZoning' feature, two new indicator features (or dummy variables) are created: 'MSZoning_RL' and 'MSZoning_RM', which take values of either 00 or 11. If an example's original value for 'MSZoning' is 'RL', then its 'MSZoning_RL' feature is set to 11 and its 'MSZoning_RM' feature is set to 00.

0

1

Updated 2026-05-07

Contributors are:

Who are from:

Tags

D2L

Dive into Deep Learning @ D2L