What should be the correct type of a nominal attribute coded 0 and 1?

Curious
Curious New Altair Community Member
edited November 5 in Community Q&A
If an attribute has two possible values (their 'meaning' is nominal) but they are already coded as 0 and 1, then is it OK to just set the type as integer or should I set it as binominal and then transform it back to numeric in the process?

Best Answer

  • rfuentealba
    rfuentealba New Altair Community Member
    Answer ✓
    Sure, it's just Addition, substraction, multiplication, division.

    Let's see if I can explain it better with a series of examples where numbers aren't about mathematics

    My passport number is P-2312005. Would it make sense to do something with the "2312005" as a number? Nope.

    My car plate is BE-7994. Would it make sense to do something with the number "7994"? Nope.

    When I push a key on my keyboard, that key contains a code which is subsequently translated into a character map. Let's suppose I press the key "A". It produces the decimal 65. Am I meant to use that decimal 65 to do something like making a sum? Nope.

    Those numbers don't fall in the category of "numeric", as aren't meant to be used in even basic mathematical operations such as addition, substraction, multiplication or division. It wouldn't make sense to know who has passport 2312006, for example. It's meaningless and you cannot extract value from the numeric form of these variables. In that case, this number should be used as a nominal, binominal or something similar (like an ID).

    On the other hand, I was born on February 22, 1983. Would you make calculations on those numbers? Sure! Calculate how old was I when I went to the school, discretize me into the "Millennials" bin, compare my age with the age of my peers as if it means anything, etc. You don't want a date to be a nominal, you want it to be a date, an amount of days, or something. That data cannot fall under the category of nominal, because they make sense as values and you can generate features out of these by applying mathematical operations or comparisons.

    Is it clearer?

    All the best,

    Rodrigo.

Answers

  • rfuentealba
    rfuentealba New Altair Community Member

    If their meaning is nominal and you can indistinctly set 0/1, on/off, in/out, yes/no, then these are binominals, not proper numbers (e.g. these aren't meant to be used in mathematical operations), so you might safely set these as binominals. On the other hand, if you will make use of these numbers in math operations, you would prefer to make these integers.

    Be careful, because while changing numerical to binominal converts 0's to false and 1's to true, changing binominal to numerical creates something like this instead of your original data:

    I always forget to use Parse Numbers instead, which does provide me numbers from nominal attributes. Just make sure your data does not include characters other than numeric ones.

    Hope this helps.

    Rodrigo.


  • Curious
    Curious New Altair Community Member
    Hi Rodrigo,

    Thank you so much for your answer! Just one more thing: can you specify what you exactly mean by 'mathematical operations'?

    Thank you!
  • rfuentealba
    rfuentealba New Altair Community Member
    Answer ✓
    Sure, it's just Addition, substraction, multiplication, division.

    Let's see if I can explain it better with a series of examples where numbers aren't about mathematics

    My passport number is P-2312005. Would it make sense to do something with the "2312005" as a number? Nope.

    My car plate is BE-7994. Would it make sense to do something with the number "7994"? Nope.

    When I push a key on my keyboard, that key contains a code which is subsequently translated into a character map. Let's suppose I press the key "A". It produces the decimal 65. Am I meant to use that decimal 65 to do something like making a sum? Nope.

    Those numbers don't fall in the category of "numeric", as aren't meant to be used in even basic mathematical operations such as addition, substraction, multiplication or division. It wouldn't make sense to know who has passport 2312006, for example. It's meaningless and you cannot extract value from the numeric form of these variables. In that case, this number should be used as a nominal, binominal or something similar (like an ID).

    On the other hand, I was born on February 22, 1983. Would you make calculations on those numbers? Sure! Calculate how old was I when I went to the school, discretize me into the "Millennials" bin, compare my age with the age of my peers as if it means anything, etc. You don't want a date to be a nominal, you want it to be a date, an amount of days, or something. That data cannot fall under the category of nominal, because they make sense as values and you can generate features out of these by applying mathematical operations or comparisons.

    Is it clearer?

    All the best,

    Rodrigo.
  • Telcontar120
    Telcontar120 New Altair Community Member
    Don't forget you can use "Numerical to Binominal" and turn ANY numerical data into a simple binominal by setting a threshold value.  This works for attributes that are already coded as 0/1 or continuous numbers as well. It will give you a single column with values of "true" and "false" based on the threshold you define.  See the tutorial process using the Sonar data for an example.