# In datasets, why don't we represent nominal values that are part of a scale with numbers?

I am trying to pre-process a small dataset. I don't understand why I am not supposed to do the thing I explained below:

For example, say we have an attribute that describes the temperature of the weather in a set of 3 nominal values: Hot, mild and cold. I understand these definitions may have derived from numerical values while summarising.

But why would we summarise such values that are on a scale, and lose the scale in the process?

Would it not help to have the algorithm(any classification algorithm) realise that the difference between hot and cold is twofold of the difference between hot and mild by representing hot, mild and cold as integers 1, 2 and 3 respectively?

Nice and necessary question to be clear when doing machine learning preprocessing, there are two points here to take into account:

1. depending on the learning algorithm, you may need to convert your categorical data into a numeric format; e.g. decission trees do not need it and can handle categorical data, whereas another regression algos do need numbers as input

2. in case you have to convert data into numbers, you have two possibilities:

• integer encoding: this is the case you are correctly describing; with this, you have no problem with just changing the labels by integers keeping the ordinal order (in fact it is better so the algo can learn the natural distance between cold and hot as bigger than cold and mild. Nevertheless, for a decision tree algo, it should not matter as these keep being as labels

• one-hot-encoding: when the algorithm type requires numbers and there is NOT an ordinal nature among the data, this is the option required to prevent not ordinal data to be understood as being ordinal. More info here

• typo in the "one-hot-encoding" section fixed about the no ordinal nature Commented Dec 26, 2019 at 20:29

thats exactly what label encoding does. and thats the difference between label and one hot encoding (atleast one of) in other words when you want to represent such information i.e. that cold is a different/stronger/weaker effect than hot you can explicitly tell your algorithm with labelencoding.