Issue with setting multiple values in a single macro using "OR" with Set Macros in RapidMiner

BLRMAH25BLRMAH25 Member Posts: 5 Newbie

I am currently facing an issue with setting multiple values in a single macro using "OR" with Set Macros in RapidMiner.

I have tried using the following syntax to add multiple values to a macro:

{value1|value2|value3}
also few other syntax with and without the curly braces also

I would greatly appreciate it if anyone could share any insights or solutions regarding this issue.
Mo_Abdolrahim  @MarcoBarradas @MarcoBarradas


Answers

  • jwpfaujwpfau Employee, Member Posts: 274 RM Engineering
    Hi,

    Can you share an example process of what you want to achieve?

    At least to me it's not clear where the values are coming from.

    Greetings,
    Jonas
  • BLRMAH25BLRMAH25 Member Posts: 5 Newbie
    Hi Jonas,

    I'll take an example, let's say to specify a Macro for a column named "Fruits", the purpose of the Macro is to select the values "apple", "banana", and "orange" from this column using the "OR" operator. However, I am facing difficulty in defining multiple values for a single macro.

    Regards,
    M


  • jwpfaujwpfau Employee, Member Posts: 274 RM Engineering
    Hi,

    So your Fruits column does look somewhat like this?

    Fruits
    apple
    orange
    banana
    pineapple
    tomato
    pear
    apple

    And your generated macro should contain "true" in this case?

    Or do you want to convert all matching Fruits into a "|" concatenated string like "apple|orange|banana|apple"?

    Greetings,
    Jonas
  • BLRMAH25BLRMAH25 Member Posts: 5 Newbie
    I just want the examples which have apple| banana| orange using macros, for filter examples
  • jwpfaujwpfau Employee, Member Posts: 274 RM Engineering
    edited April 2023
    Something like this?

    <?xml version="1.0" encoding="UTF-8"?><process version="10.1.002">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="10.1.002" 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="10.1.002" expanded="true" height="68" name="Create ExampleSet" width="90" x="45" y="34">
            <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="Id,Fruits&#10;1,apple&#10;2,orange&#10;3,banana&#10;4,pineapple&#10;5,tomato&#10;6,pear&#10;7,apple"/>
            <parameter key="column_separator" value=","/>
            <parameter key="parse_all_as_nominal" value="true"/>
            <parameter key="decimal_point_character" value="."/>
            <parameter key="trim_attribute_names" value="true"/>
          </operator>
          <operator activated="true" class="set_macro" compatibility="10.1.002" expanded="true" height="82" name="Set Macro" width="90" x="246" y="34">
            <parameter key="macro" value="fruits"/>
            <parameter key="value" value="apple|banana|orange"/>
          </operator>
          <operator activated="true" class="filter_examples" compatibility="10.1.002" expanded="true" height="103" name="Filter Examples" width="90" x="447" y="34">
            <parameter key="parameter_expression" value="matches([Fruits], %{fruits})"/>
            <parameter key="condition_class" value="expression"/>
            <parameter key="invert_filter" value="false"/>
            <list key="filters_list"/>
            <parameter key="filters_logic_and" value="true"/>
            <parameter key="filters_check_metadata" value="true"/>
          </operator>
          <connect from_op="Create ExampleSet" from_port="output" to_op="Set Macro" to_port="through 1"/>
          <connect from_op="Set Macro" from_port="through 1" to_op="Filter Examples" to_port="example set input"/>
          <connect from_op="Filter Examples" from_port="example set output" 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>
    

  • BLRMAH25BLRMAH25 Member Posts: 5 Newbie
    Set macro operator
    macro name   |   values
    fruits               |   apple | banana | orange (defining multiple values in this single macro)

    then use this macros as %{fruits}


  • jwpfaujwpfau Employee, Member Posts: 274 RM Engineering
    edited April 2023
    You can copy the shared process xml from my previous post and paste it into the Process panel of RapidMiner Studio.


    Alternatively you could also use condition class custom_filters on Filter Examples


  • BLRMAH25BLRMAH25 Member Posts: 5 Newbie
    It's not giving an output when I am doing the above filteration, its only giving it for "apple" not taking the value after OR
    operator
  • jwpfaujwpfau Employee, Member Posts: 274 RM Engineering
    Can you share your process xml? You can copy it from View → Show Panel → XML 
Sign In or Register to comment.