image

🎉 🎉 RAPIDMINER 9.10 IS OUT!!! 🎉🎉

Download the latest version helping analytics teams accelerate time-to-value for streaming and IIOT use cases.

CLICK HERE TO DOWNLOAD

changing attribute data types using if/then logic

Telcontar120Telcontar120 Moderator, RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 1,625   Unicorn
edited December 2018 in Help

I have a collection that has different data type versions of the same attribute.  The attribute is present as a numeric in some elements in the collection and as a nominal in other elements.  But it is really the same attribute (which should be a nominal data type).  I want to Append the collection together (since it is the same set of attributes in all cases) but of course it won't let me until all the data types are the same.

 

The question is how can I use Loop Collection and change all the data types for this attribute to nominal?  Using Numerical to Nominal fails because it won't work when the attribute is already nominal.  Likewise, I tried Generate Attributes using the str() and/or eval() functions but it also fails when it encounters a version of the attribute which is the wrong data type.  

 

I'm thinking I should be able to do something like this with Branch but I can't seem to find a condition based on data type.  Or maybe there's another way to do this that I haven't thought of?  Any help is appreciated!  

Brian T.
Lindon Ventures 
Data Science Consulting from Certified RapidMiner Experts

Best Answers

  • FBTFBT Member Posts: 106   Unicorn
    Solution Accepted

    Hi Brian,

     

    if you have only two possible attribute types, you could try solving it with the "Handle Exception" operator within the loop. E.g. putting in the "Numerical to Polynomial" operator on the "Try" side and just making the connection on the "Catch" side. If you have more than two possible attribute types, I think it should be possible to add yet another "Handle Exception" on the "Catch" side. I have never tried that though. 

    Telcontar120sgenzer
  • BalazsBaranyBalazsBarany Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert Posts: 674   Unicorn
    Solution Accepted

    Hi Brian,

     

    you do a Loop Attributes with the Numerical filter type and convert the actual numericals based on their name (for example) inside that loop.

     

    It wouldn't act on the nominals if they already have the correct type.

     

    Regards,

    Balázs

    JEdwardTelcontar120
  • sgenzersgenzer 12Administrator, Moderator, Employee, RapidMiner Certified Analyst, Community Manager, Member, University Professor, PM Moderator Posts: 2,959  Community Manager
    Solution Accepted

    exactly what I was going to suggest, @FBT.  Loop Examples or Loop Values with Handle Exception and then append.  If the append is causing you grief, you can use the always-very-handy Union Append building block that was posted a while ago.  :)

     

    Scott

     

    Telcontar120
  • Telcontar120Telcontar120 Moderator, RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 1,625   Unicorn
    Solution Accepted

    Thanks for all the ideas!  As usual, there are multiple solutions with RapidMiner and your thoughts were all helpful.  I ended up with a simpler workflow by using a single Numerical to Nominal filtered by value type inside a Loop Collections operator---it solved my problem by turning all numerics into nominals, which I could undo after the Append by using Parse Numbers on ones that I wanted to turn back into numerics.

     

    Brian T.
    Lindon Ventures 
    Data Science Consulting from Certified RapidMiner Experts
    sgenzer
Sign In or Register to comment.