The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

how to generate an attribute with abs(col1 - col2)

blatooblatoo Member Posts: 32 Contributor II
edited November 2018 in Help
Hello,

how can I generate an new attribute, which function expression is: |attr1 - attr2| ?

At moment, i just find the way with if( attr1 - attr2 > 0, attr1 - attr2, attr2-attr1)

Thanks very much for the attention!

Answers

  • Marco_BoeckMarco_Boeck Administrator, Moderator, Employee-RapidMiner, Member, University Professor Posts: 1,996 RM Engineering
    Hi,

    because there is no explicit function to get absolute values at the moment, I'd suggest the following:

    sqrt(pow((attr1-attr2), 2))
    Edit: I concede! See Marius' answer below ;)

    Regards,
    Marco
  • MartinLiebigMartinLiebig Administrator, Moderator, Employee-RapidMiner, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 3,533 RM Data Scientist
    you can use the sign function

    sgn(a-b)*(a-b)
    for some reason that one is not in the list of Generate Attributes.
    - Sr. Director Data Solutions, Altair RapidMiner -
    Dortmund, Germany
  • MariusHelfMariusHelf RapidMiner Certified Expert, Member Posts: 1,869 Unicorn
    blatoo,

    why not simply use your subject line?
    abs(attr1-attr2) will also work perfectly in Generate Attributes :)

    ~Marius
  • blatooblatoo Member Posts: 32 Contributor II
    Hi all,

    Thanks very much for the answers! :-) I got now more solutions. But I think, if rapidminer can put the abs() also in the function list, will be better. Because abs() will be often used. ;)
Sign In or Register to comment.