# Dummy Variables

I am not able to understand the part at 1 hour 22 minutes of lecture 3. As Jeremy said that we don’t need a third dummy variable for 3 categorical variables as it can be done without that. But my question is how??

I mean as I have read till now for 3 categorical variables we do create 3 dummy variables as we do in encoding.

Hello,

`Pclass` can take on three values, namely, 1, 2, or 3. `Pclass_1` is 1 if `Pclass` is 1 and 0 otherwise. Similarly, `Pclass_2` is 1 if `Pclass` is 2 and 0 otherwise. Therefore, by definition, when `Pclass_1` and `Pclass_2` are both zero, it immediately follows that `Pclass` is neither 1 nor 2 and is thus 3. In other words, a hypothetical `Pclass_3` would be superfluous since it is 1 if and only if `Pclass_1` and `Pclass_2` are 0 and 0 otherwise.

Below is a table of the possible combinations of `Pclass`, `Pclass_1`, and `Pclass_2`. Note that `Pclass_1` and `Pclass_2` cannot both be 1 because that would imply `Pclass` is 1 and 2 simultaneously.

``````--------------------------------
| Pclass | Pclass_1 | Pclass_2 |
--------------------------------
|      1 |        1 |        0 |
|      2 |        0 |        1 |
|      3 |        0 |        0 |
--------------------------------
``````

Does that clarify the matter?

Hello
This may help or totally confuse. We normally count in 10 so 57 is really 510+7 but we could count in 2 so 57 = 32 + 16 + 8 + 1 or 22222 + 2222 + 222 + 1. We could write this as 1 1 1 0 0 1. This is called binary. Now consider the number 3 as in 3 classes. We could write class 1 as 20+1, class 2 as 12+0 and class 3 as 1*2 +1. Hence C1 = 01, C2 = 10 and C3 = 11. Whether C3 = 11 or 00 is just a personal choice a more pragmatic approach would be to use class -1 to be 00 01 10 respectively. This would be consistent if you had a larger number of classes.
Regards Conwyn