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 detect attribute type
CharlieFirpo
Member Posts: 48 Contributor II
Dear all!
How can I detect the type of an attribute? I have a Branch operator. If the type of an attribute is numerical then the IF should be run, if the attribute is nominal then the ELSE.
Thank you!!!
How can I detect the type of an attribute? I have a Branch operator. If the type of an attribute is numerical then the IF should be run, if the attribute is nominal then the ELSE.
Thank you!!!
0
Answers
After the Numerical to Nominal operator one should use a Generate Attribute operator that generates eg. the isNum attribute with this function:
finds(%{macro_of_attribute_name},"^[0-9]+$") It returns true only if the value of the given attribute consists of only numbers.
And at the Branch operator the condition type should be 'attribute_value_filter', and the condition value 'isNum=true'.
It is not difficult but maybe there is a simliest way to do this. Is there?
Nice day!
I used the "Set Macro"-operator to define a Macro with the name "number" and value "0".
I used the "Handle Exception"-operator. In the "Catch"-branch I put the "Set Macros"-operatur and give my macro "number" the value "1". In the "Try"-branch I did a "Loop attributes"-operator und used at the option "attribute filter type" the value "value_type" and the option "value type" I gave the value "numeric".
In the "Loop attributes"-operator I put a "Set macros"-operator and gave my macro "number" the value "2".
So if my dataset have numeric attributes, the macro "number" have the value "2", if not the macro "number" have the value "1".