Options

Use of macros as global variables

Himanshu_PantHimanshu_Pant Member Posts: 46 Contributor I
Lets say I have used two macros-> macroA and macroB. I want to add a condition: If a value of a column (from a dataset)  is greater than 5, increment macroA  by 1 and if it is less than 5 increment macroB  by 1. 
Is it possible? if yes, then how. Please help.

Best Answer

  • Options
    MartinLiebigMartinLiebig Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 3,507 RM Data Scientist
    edited June 2021 Solution Accepted
    I am a bit confused here. Isnt macroA the cumsum of ColumnA? Not sure how you then calculate macroB from there?
    Likely this is not a job for macros anyway? Please check the attached process for the cumsum.

    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" class="utility:create_exampleset" compatibility="9.8.001" expanded="true" height="68" name="Create ExampleSet" width="90" x="45" y="136">
            <parameter key="generator_type" value="comma separated text"/>
            <parameter key="number_of_examples" value="100"/>
            <parameter key="use_stepsize" value="false"/>
            <list key="function_descriptions"/>
            <parameter key="add_id_attribute" value="false"/>
            <list key="numeric_series_configuration"/>
            <list key="date_series_configuration"/>
            <list key="date_series_configuration (interval)"/>
            <parameter key="date_format" value="yyyy-MM-dd HH:mm:ss"/>
            <parameter key="time_zone" value="SYSTEM"/>
            <parameter key="input_csv_text" value="Column A&#10;0&#10;1&#10;0&#10;1&#10;1&#10;1"/>
            <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="time_series:integration" compatibility="9.8.001" expanded="true" height="68" name="Integrate" width="90" x="246" y="136">
            <parameter key="attribute_filter_type" value="single"/>
            <parameter key="attribute" value="Column A"/>
            <parameter key="attributes" value=""/>
            <parameter key="use_except_expression" value="false"/>
            <parameter key="value_type" value="numeric"/>
            <parameter key="use_value_type_exception" value="false"/>
            <parameter key="except_value_type" value="real"/>
            <parameter key="block_type" value="value_series"/>
            <parameter key="use_block_type_exception" value="false"/>
            <parameter key="except_block_type" value="value_series_end"/>
            <parameter key="invert_selection" value="false"/>
            <parameter key="include_special_attributes" value="false"/>
            <parameter key="has_indices" value="false"/>
            <parameter key="indices_attribute" value=""/>
            <parameter key="overwrite_attributes" value="false"/>
            <parameter key="new_attributes_postfix" value="_integrated"/>
            <parameter key="skip_invalid_values" value="true"/>
            <parameter key="integration_method" value="cumulative sum"/>
          </operator>
          <connect from_op="Create ExampleSet" from_port="output" to_op="Integrate" to_port="example set"/>
          <connect from_op="Integrate" from_port="example set" 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

  • Options
    MartinLiebigMartinLiebig Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 3,507 RM Data Scientist
    yes it is. You first extract the value of the column using Extract Macro and then you can use Generate Macro to do the conditional increment.

    Best,
    Martin
    - Sr. Director Data Solutions, Altair RapidMiner -
    Dortmund, Germany
  • Options
    Himanshu_PantHimanshu_Pant Member Posts: 46 Contributor I
    I want to keep adding the value:
    lets say I have a column
    Column A
    0
    1
    0
    1
    1
    1

    I want the output
    macroA   macroB
    0 1
    1 1
    1 2
    2 2
    3 2
    4 2
  • Options
    Himanshu_PantHimanshu_Pant Member Posts: 46 Contributor I
    Can you please share rmp file?
  • Options
    Himanshu_PantHimanshu_Pant Member Posts: 46 Contributor I
    @mschmitz no need. Thank you.
Sign In or Register to comment.