(Poly)Nominal to Numeric: Keep Value

btibertbtibert Member, University Professor Posts: 18  Maven
edited September 7 in Help
I do not want to recode nominal datatypes for coding in machine learning, but simply take the nominal value and convert it to it's numeric equivalent.  I often do this in my teaching to show how if a data type is read incorrectly, we can convert it to a new type.  From what I see, the options are more inline with converting for modeling purposes, which is great, but if Age, for example, comes in as polynominal, I dont want to recode the age of 21 to 0 given the range of values. 

Simply, I want the Age to be converted to numeric 21, an age of 34 to be converted to numeric 34, etc.


Best Answer


  • btibertbtibert Member, University Professor Posts: 18  Maven
    I could use Execute R to do this for mapping for me, but that seems overkill for something as simple as changing text to numeric (a basic option in Excel).  Thanks for your help on this.
  • varunm1varunm1 Member Posts: 719   Unicorn
    edited September 7
    Hello @btibert

    I can think of two ways. One way is to try "Guess Type" operator. It re guesses the type of attribute. If guess types doesn't work, the other way is to use nominal to numerical operator. This doesn't change numerical values in the nominal attribute but changes attribute type to numerical.
  • btibertbtibert Member, University Professor Posts: 18  Maven
    Thanks @varunm1.

    Guess Type kept things as Nominal, and Nominal to Numerical requires a coding type, all of which attempt to transform the data for modeling.  In my case, all I need to do is retain the value but just change the type.  Optionally, if I want the column to be numeric and the value can't be cast to numeric, have the data missing.  In R, this is often done with as.numeric(), and is something easily done in point-and-click tools like Excel.  The ability to cast for modeling is fantastic, but I am looking for something even more elementary.

  • varunm1varunm1 Member Posts: 719   Unicorn
    Thanks for your response. There is one other way to just change the type. If your data is in the repository, you can right-click and click on edit. Then you can see data in Data editor, here you can right-click on attribute name and select "modify attribute", then change the attribute type to "numeric" and save. I am not exactly sure what is happening in backend for this. @mschmitz might suggest.
Sign In or Register to comment.