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

Can i recall an atrribute with a string an a macro in a function expression?

PlättenzwergPlättenzwerg Member Posts: 2 Contributor I
I have multiple atrributes in pairs. The actual value and the target Value.
They are named Mi and SET Mi. 
I want to create the differenz between them. 
The plan was to loop(attribute) the operator genrate Attribute with the function expression %{loop_attribute} - ["SET "#loop_attribute ].
I tried diffrent functions like concat(), attribute() and the help of a second macro, but i cannot find the right expression.

Thanks for your help

Hermann

Best Answer

  • MartinLiebigMartinLiebig Administrator, Moderator, Employee-RapidMiner, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 3,533 RM Data Scientist
    Solution Accepted
    Hi Hermann,

    attached is a process showing this. The Generate Attribute equation I use is:
    eval(%{loop_attribute})-attribute("SET "+%{loop_attribute})

    I think you can adapt it from here?

    Best,
    Martin

    <?xml version="1.0" encoding="UTF-8"?><process version="9.8.001">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="9.8.001" 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" breakpoints="after" class="subprocess" compatibility="9.8.001" expanded="true" height="82" name="Subprocess" width="90" x="45" y="85">
            <process expanded="true">
              <operator activated="true" class="generate_data" compatibility="9.8.001" expanded="true" height="68" name="Generate Data" width="90" x="45" y="34">
                <parameter key="target_function" value="random"/>
                <parameter key="number_examples" value="100"/>
                <parameter key="number_of_attributes" value="5"/>
                <parameter key="attributes_lower_bound" value="-10.0"/>
                <parameter key="attributes_upper_bound" value="10.0"/>
                <parameter key="gaussian_standard_deviation" value="10.0"/>
                <parameter key="largest_radius" value="10.0"/>
                <parameter key="use_local_random_seed" value="false"/>
                <parameter key="local_random_seed" value="1992"/>
                <parameter key="datamanagement" value="double_array"/>
                <parameter key="data_management" value="auto"/>
              </operator>
              <operator activated="true" class="generate_id" compatibility="9.8.001" expanded="true" height="82" name="Generate ID" width="90" x="179" y="34">
                <parameter key="create_nominal_ids" value="false"/>
                <parameter key="offset" value="0"/>
              </operator>
              <operator activated="true" class="generate_data" compatibility="9.8.001" expanded="true" height="68" name="Generate Data (2)" width="90" x="45" y="238">
                <parameter key="target_function" value="random"/>
                <parameter key="number_examples" value="100"/>
                <parameter key="number_of_attributes" value="5"/>
                <parameter key="attributes_lower_bound" value="-10.0"/>
                <parameter key="attributes_upper_bound" value="10.0"/>
                <parameter key="gaussian_standard_deviation" value="10.0"/>
                <parameter key="largest_radius" value="10.0"/>
                <parameter key="use_local_random_seed" value="false"/>
                <parameter key="local_random_seed" value="1992"/>
                <parameter key="datamanagement" value="double_array"/>
                <parameter key="data_management" value="auto"/>
              </operator>
              <operator activated="true" class="generate_id" compatibility="9.8.001" expanded="true" height="82" name="Generate ID (2)" width="90" x="179" y="238">
                <parameter key="create_nominal_ids" value="false"/>
                <parameter key="offset" value="0"/>
              </operator>
              <operator activated="true" class="rename_by_replacing" compatibility="9.8.001" expanded="true" height="82" name="Rename by Replacing" width="90" x="313" y="238">
                <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="replace_what" value="(.+)"/>
                <parameter key="replace_by" value="SET $1"/>
              </operator>
              <operator activated="true" class="concurrency:join" compatibility="9.8.001" expanded="true" height="82" name="Join" width="90" x="447" y="85">
                <parameter key="remove_double_attributes" value="true"/>
                <parameter key="join_type" value="inner"/>
                <parameter key="use_id_attribute_as_key" value="false"/>
                <list key="key_attributes">
                  <parameter key="id" value="id"/>
                </list>
                <parameter key="keep_both_join_attributes" value="false"/>
              </operator>
              <connect from_op="Generate Data" from_port="output" to_op="Generate ID" to_port="example set input"/>
              <connect from_op="Generate ID" from_port="example set output" to_op="Join" to_port="left"/>
              <connect from_op="Generate Data (2)" from_port="output" to_op="Generate ID (2)" to_port="example set input"/>
              <connect from_op="Generate ID (2)" from_port="example set output" to_op="Rename by Replacing" to_port="example set input"/>
              <connect from_op="Rename by Replacing" from_port="example set output" to_op="Join" to_port="right"/>
              <connect from_op="Join" from_port="join" to_port="out 1"/>
              <portSpacing port="source_in 1" spacing="0"/>
              <portSpacing port="sink_out 1" spacing="0"/>
              <portSpacing port="sink_out 2" spacing="0"/>
            </process>
            <description align="center" color="transparent" colored="false" width="126">Generate an example data set</description>
          </operator>
          <operator activated="true" class="concurrency:loop_attributes" compatibility="9.8.001" expanded="true" height="82" name="Loop Attributes" width="90" x="246" y="85">
            <parameter key="attribute_filter_type" value="regular_expression"/>
            <parameter key="attribute" value=""/>
            <parameter key="attributes" value=""/>
            <parameter key="regular_expression" value="att.+"/>
            <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.8.001" expanded="true" height="82" name="Generate Attributes" width="90" x="112" y="34">
                <list key="function_descriptions">
                  <parameter key="Delta_%{loop_attribute}" value="eval(%{loop_attribute})-attribute(&quot;SET &quot;+%{loop_attribute})"/>
                </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="Subprocess" from_port="out 1" 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>







    - Sr. Director Data Solutions, Altair RapidMiner -
    Dortmund, Germany

Answers

Sign In or Register to comment.