I have a column which has 5 unique categories. There's a hierarchy between these categories (Best > good > OK/Not Sure > Bad > Worst)

In this case, should I label them based on hierarchy like:

Best: 4

good: 3

OK/Not Sure: 2

Bad: 1

Worst: 0

Or should I perform one-hot encoding/Dummy encoding? What's the intuition behind how the model perceives the two things?

Note: I should also mention that this is for predictive modeling using Logistic Regression.


1 Answer 1


One hot encoding should be performed between independent values like flowers type etc. Values that you have mentioned are relative rank where bad is better than worst and so on. So it should not be one hot encoding except converting it into numerical values.

  • 1
    $\begingroup$ Good answer, but it might help to clarify: recording the observations as numerals is not one-hot encoding (it's just regular encoding), and the values should still be fed into the model as categorical (this type of hierarchy is not a continuous value but is ordinal, and it is not necessarily scale invariant). $\endgroup$
    – Upper_Case
    Commented Jun 3, 2019 at 15:32
  • $\begingroup$ @Upper_Case Right. If ordinal type isn't scale invariant, what can be done to get around that? $\endgroup$ Commented Jun 3, 2019 at 15:53
  • 2
    $\begingroup$ @AakashDusane The most direct thing you can do is interpret it as a single categorical variable having 5 possible values. Since such a variable is rarely scale-invariant, you simply cannot treat them as continuous-- trying to do so will cause the model to assume the variable behaves in ways which it does not. More broadly you can try to develop a better description of the variable which is scale-invariant or somehow correctly captures the difference between values, but this tends to be complicated and expensive to do. $\endgroup$
    – Upper_Case
    Commented Jun 3, 2019 at 16:00

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.