1
$\begingroup$

I've heard sum encoding mentioned as a method of encoding categorical variables, but I haven't been able to find a clear explanation of what it actually is.

I found the following explanation on Towards DataScience:

Just like OneHot except one value is held constant and encoded as -1 across all columns.

But this confused me as it doesn't involve any summing.

Is it really just?:

Value      Variable 1. Variable 2. 
Red            1            0
Blue           0            1
Green         -1           -1
$\endgroup$
1
$\begingroup$

Sum encoding is similar to one-hot encoding but the difference is that in sum encoding we take one value as '-1' and it is not compared to other value. Whereas in one-hot encoding we create one column for each value to compare against all other values.

It is referred as sum encoding because the intercept represents the grand mean and the contrast estimate is the mean for level 1 minus the grand mean.

In one-hot encoding intercept represents the mean for the baseline condition and contrast estimate represents simple the difference between one particular condition and the baseline.

$\endgroup$
2
  • $\begingroup$ "And it is not compared to other value" - what do you mean by this? $\endgroup$
    – Casebash
    Jul 19 '20 at 10:11
  • $\begingroup$ As the example you had mentioned we had three variable but only two comparison in sum encoding but in one-hot encoding we would have three comparison. That's why Green was not used as reference in sum encoding. $\endgroup$ Jul 19 '20 at 10:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.