My question is about a multi-variate linear regression model. I am experimenting with Python's sklearn library with the Ames Housing data set: http://jse.amstat.org/v19n3/decock/DataDocumentation.txt.

Do I need to dummy-encode a binary categorical variable? The variable is similar to a yes/no question. Most variables actually imply the absence of a characteristic. For example, "Wood Deck SF" and the porch type columns "[type] Porch SF" would only be either a positive value or 0. I already manually changed the column to have the values 1 and 0. Also, I read in "Dummy Coding: The How and Why" that:

we do not use all three categories in a regression. Doing so would give the regression redundant information, result in multicollinearity, and break the model. This means we have to leave one category out, and we call this missing category the reference category.

I am aware that "categroical" varaibles/features need to be dummy coded. Dummy coding avoids idiotic or chance-based coefficients being assigned to Lickert scale answers or choices between items like 1, 2, and 3. However, given that article and the fact that I have already manually transformed the column into 1's and 0's, do I need to use pd.get_dummies on those binary categorical columns? I am confident I do not, but is there some detail I am missing, maybe a dataset- or python-specific detail that changes the proper procedure?

  • 1
    $\begingroup$ NO, a binary variable is already identical to the result of dummy-coding it! $\endgroup$ Aug 29, 2020 at 6:22
  • $\begingroup$ @kjetilbhalvorsen OK, thanks. Are the links I posted enough third-party evidence to confirm your answer? I assume they are. I'll use your comment as my own answer to the question later. $\endgroup$ Aug 30, 2020 at 4:22

1 Answer 1


BlockquoteNO, a binary variable is already identical to the result of dummy-coding it! – Kjetil B. Halvorsen

This comment can be proven if you actually revert the binary categorical variable and then apply pd.get_dummies to it. It will have the same effect as manually encoding the variables as ones and zeroes.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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