🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

Generate a Function & apply it to all/some attributes automatically

1705410GUser: "1705410G"
New Altair Community Member
Updated by Jocelyn
I've created a new attribute using the Generate Attribute operator. 
Attribute name N_speed, with 'N' representing the location. 
E.g. 2_speed represents speed at location 2. 

(New) Attribute Name:             2speed 
Function Expressions:             if([2_speed]>=70,"DANGER","SAFE").

However, I have nearly 300 attributes. I've tried adding new entries and replacing each with the name of the next attribute, but its just too much work. 

Hence, Is there any way to apply the same function to all attributes automatically? 

if([2_speed]>=70,"DANGER","SAFE")
if([3_speed]>=70,"DANGER","SAFE")
if([4_speed]>=70,"DANGER","SAFE")
if([5_speed]>=70,"DANGER","SAFE")
if([6_speed]>=70,"DANGER","SAFE")
if([7_speed]>=70,"DANGER","SAFE") and so on... 


Thanks.

Regards,
AY

Find more posts tagged with

Sort by:
1 - 4 of 41
    Hi,
    Loop attributes is your friend :).

    BR,
    Martin


    Hi @1705410G,

    You have to put the Generate Attributes operator inside the Loop Attributes operator : 
    Here a process to show you how to proceed : 
    <?xml version="1.0" encoding="UTF-8"?><process version="9.2.000-SNAPSHOT">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="9.2.000-SNAPSHOT" expanded="true" name="Process">
        <parameter key="logverbosity" value="init"/>
        <parameter key="random_seed" value="2001"/>
        <parameter key="send_mail" value="never"/>
        <parameter key="notification_email" value=""/>
        <parameter key="process_duration_for_mail" value="30"/>
        <parameter key="encoding" value="SYSTEM"/>
        <process expanded="true">
          <operator activated="true" class="operator_toolbox:create_exampleset" compatibility="1.7.000" expanded="true" height="68" name="Create ExampleSet" width="90" x="112" y="136">
            <parameter key="generator_type" value="numeric_series"/>
            <parameter key="number_of_examples" value="10"/>
            <parameter key="use_stepsize" value="false"/>
            <list key="function_descriptions"/>
            <parameter key="add_id_attribute" value="false"/>
            <list key="numeric_series_configuration">
              <parameter key="att_1" value="linear.0\.0.10\.0"/>
              <parameter key="att_2" value="linear.10\.0.20\.0"/>
            </list>
            <list key="date_series_configuration"/>
            <list key="date_series_configuration (interval)"/>
            <parameter key="date_format" value="yyyy-MM-dd HH:mm:ss"/>
            <parameter key="column_separator" value=","/>
            <parameter key="parse_all_as_nominal" value="false"/>
            <parameter key="decimal_point_character" value="."/>
            <parameter key="trim_attribute_names" value="true"/>
          </operator>
          <operator activated="true" class="concurrency:loop_attributes" compatibility="9.2.000-SNAPSHOT" expanded="true" height="82" name="Loop Attributes" width="90" x="380" y="136">
            <parameter key="attribute_filter_type" value="all"/>
            <parameter key="attribute" value=""/>
            <parameter key="attributes" value=""/>
            <parameter key="use_except_expression" value="false"/>
            <parameter key="value_type" value="attribute_value"/>
            <parameter key="use_value_type_exception" value="false"/>
            <parameter key="except_value_type" value="time"/>
            <parameter key="block_type" value="attribute_block"/>
            <parameter key="use_block_type_exception" value="false"/>
            <parameter key="except_block_type" value="value_matrix_row_start"/>
            <parameter key="invert_selection" value="false"/>
            <parameter key="include_special_attributes" value="false"/>
            <parameter key="attribute_name_macro" value="loop_attribute"/>
            <parameter key="reuse_results" value="true"/>
            <parameter key="enable_parallel_execution" value="true"/>
            <process expanded="true">
              <operator activated="true" class="generate_attributes" compatibility="9.2.000-SNAPSHOT" expanded="true" height="82" name="Generate Attributes" width="90" x="313" y="85">
                <list key="function_descriptions">
                  <parameter key="%{loop_attribute}_bis" value="if(eval(%{loop_attribute})&gt;5,&quot;true&quot;,&quot;false&quot;)"/>
                </list>
                <parameter key="keep_all" value="true"/>
              </operator>
              <connect from_port="input 1" to_op="Generate Attributes" to_port="example set input"/>
              <connect from_op="Generate Attributes" from_port="example set output" to_port="output 1"/>
              <portSpacing port="source_input 1" spacing="0"/>
              <portSpacing port="source_input 2" spacing="0"/>
              <portSpacing port="sink_output 1" spacing="0"/>
              <portSpacing port="sink_output 2" spacing="0"/>
            </process>
          </operator>
          <connect from_op="Create ExampleSet" from_port="output" to_op="Loop Attributes" to_port="input 1"/>
          <connect from_op="Loop Attributes" from_port="output 1" to_port="result 1"/>
          <portSpacing port="source_input 1" spacing="0"/>
          <portSpacing port="sink_result 1" spacing="0"/>
          <portSpacing port="sink_result 2" spacing="0"/>
        </process>
      </operator>
    </process>
    
    Hope it helps,

    Regards,

    Lionel

    Telcontar120User: "Telcontar120"
    New Altair Community Member
    Accepted Answer
    if you are using Loop Attributes, you should be referring to the attribute being handled via the associated macro, and this should clear up the problem that you were having with the EVAL function error.  That macro is bound to the operator so you don't have to enable anything to get it (but you do need to fill in the name you want to use in the parameters).
    Telcontar120User: "Telcontar120"
    New Altair Community Member
    Accepted Answer
    This is really hard to troubleshoot without data, but you could try the #{loop_attribute} macro syntax instead of eval(%{loop_attribute}) and see if that solves your problem.