1
$\begingroup$

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?

$\endgroup$

2 Answers 2

0
$\begingroup$

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

$\endgroup$
1
  • $\begingroup$ typo in the "one-hot-encoding" section fixed about the no ordinal nature $\endgroup$
    – German C M
    Dec 26, 2019 at 20:29
0
$\begingroup$

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.

$\endgroup$

Your Answer

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

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