Pages: [1]
  Print  
Author Topic: how to generate an attribute with abs(col1 - col2)  (Read 120 times)
blatoo
Newbie
*
Posts: 26


« on: April 29, 2015, 04:43:03 PM »

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!
« Last Edit: April 29, 2015, 06:00:23 PM by blatoo » Logged
Marco Boeck
Administrator
Hero Member
*****
Posts: 1258


WWW
« Reply #1 on: April 30, 2015, 07:40:03 AM »

Hi,

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

Code:
sqrt(pow((attr1-attr2), 2))

Edit: I concede! See Marius' answer below Wink

Regards,
Marco
« Last Edit: May 07, 2015, 07:30:01 AM by Marco Boeck » Logged

Are you from a scientific background and want to use RapidMiner Studio 6? Check out our new RapidMiner Academia program!
Martin Schmitz
Global Moderator
Sr. Member
*****
Posts: 288


« Reply #2 on: April 30, 2015, 07:55:39 AM »

you can use the sign function

Code:
sgn(a-b)*(a-b)

for some reason that one is not in the list of Generate Attributes.
« Last Edit: April 30, 2015, 07:58:21 AM by Martin Schmitz » Logged

- Consultant at Rapidminer (Germany) -
Marius
Administrator
Hero Member
*****
Posts: 1796



WWW
« Reply #3 on: April 30, 2015, 08:55:54 AM »

blatoo,

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

~Marius
Logged

Please add [SOLVED] to the topic title when your problem has been solved! (do so by editing the first post in the thread and modifying the title)
Please click here before posting.
blatoo
Newbie
*
Posts: 26


« Reply #4 on: May 06, 2015, 07:20:45 PM »

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. Wink
Logged
Pages: [1]
  Print  
 
Jump to: