Macro: Apply on all examples, not only on one

Legacy UserLegacy User Member Posts: 0 Newbie
edited June 2019 in Help
Hello guys,

I am jsut getting familiar with macros. I am using the following workflow that I have taken from myexperiment. My problem is that it works for one single value and for all. The idea here is the following: I have a similarity matrix: id1,id2, similar. I want tofind the top 10 most similar items to a certain item(=id1). The following process works if i set the id in the xml. How can I make this work for all the id?

Thank you in advance.

Best,
Elena

P.S.: Is there a more concrete manual of macros in RM? I haven't found anything,
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.3.015">
  <context>
    <input/>
    <output/>
    <macros>
      <macro>
        <key>id</key>
        <value>1599_1350505843.jpg</value>
      </macro>
      <macro>
        <key>recommendation_no</key>
        <value>10</value>
      </macro>
    </macros>
  </context>
  <operator activated="true" class="process" compatibility="5.3.015" expanded="true" name="Process">
    <process expanded="true">
      <operator activated="true" class="retrieve" compatibility="5.3.015" expanded="true" height="60" name="Retrieve Similarity2_0.01" width="90" x="45" y="30">
        <parameter key="repository_entry" value="//MyNewRepos/workflows/Improved/Similarity2_0.01"/>
      </operator>
      <operator activated="true" class="filter_examples" compatibility="5.3.015" expanded="true" height="76" name="Filter Examples" width="90" x="179" y="30">
        <parameter key="condition_class" value="attribute_value_filter"/>
        <parameter key="parameter_string" value="FIRST_ID=%{id}"/>
      </operator>
      <operator activated="true" class="filter_examples" compatibility="5.3.015" expanded="true" height="76" name="Filter Examples (2)" width="90" x="313" y="120">
        <parameter key="condition_class" value="attribute_value_filter"/>
        <parameter key="parameter_string" value="SECOND_ID=%{id}"/>
      </operator>
      <operator activated="true" class="rename" compatibility="5.3.015" expanded="true" height="76" name="Rename" width="90" x="447" y="120">
        <parameter key="old_name" value="FIRST_ID"/>
        <parameter key="new_name" value="temp"/>
        <list key="rename_additional_attributes">
          <parameter key="SECOND_ID" value="FIRST_ID"/>
          <parameter key="temp" value="SECOND_ID"/>
        </list>
      </operator>
      <operator activated="true" class="append" compatibility="5.3.015" expanded="true" height="94" name="Append" width="90" x="581" y="30"/>
      <operator activated="true" class="select_attributes" compatibility="5.3.015" expanded="true" height="76" name="Select Attributes" width="90" x="715" y="30">
        <parameter key="attribute_filter_type" value="single"/>
        <parameter key="attribute" value="FIRST_ID"/>
        <parameter key="invert_selection" value="true"/>
      </operator>
      <operator activated="true" class="rename" compatibility="5.3.015" expanded="true" height="76" name="Rename (2)" width="90" x="849" y="30">
        <parameter key="old_name" value="SECOND_ID"/>
        <parameter key="new_name" value="recommendation"/>
        <list key="rename_additional_attributes">
          <parameter key="DISTANCE" value="score"/>
        </list>
      </operator>
      <operator activated="true" class="sort" compatibility="5.3.015" expanded="true" height="76" name="Sort" width="90" x="983" y="30">
        <parameter key="attribute_name" value="score"/>
        <parameter key="sorting_direction" value="decreasing"/>
      </operator>
      <operator activated="true" class="filter_example_range" compatibility="5.3.015" expanded="true" height="76" name="Filter Example Range" width="90" x="1117" y="30">
        <parameter key="first_example" value="1"/>
        <parameter key="last_example" value="%{recommendation_no}"/>
      </operator>
      <connect from_op="Retrieve Similarity2_0.01" from_port="output" to_op="Filter Examples" to_port="example set input"/>
      <connect from_op="Filter Examples" from_port="example set output" to_op="Append" to_port="example set 1"/>
      <connect from_op="Filter Examples" from_port="original" to_op="Filter Examples (2)" to_port="example set input"/>
      <connect from_op="Filter Examples (2)" from_port="example set output" to_op="Rename" to_port="example set input"/>
      <connect from_op="Rename" from_port="example set output" to_op="Append" to_port="example set 2"/>
      <connect from_op="Append" from_port="merged set" to_op="Select Attributes" to_port="example set input"/>
      <connect from_op="Select Attributes" from_port="example set output" to_op="Rename (2)" to_port="example set input"/>
      <connect from_op="Rename (2)" from_port="example set output" to_op="Sort" to_port="example set input"/>
      <connect from_op="Sort" from_port="example set output" to_op="Filter Example Range" to_port="example set input"/>
      <connect from_op="Filter Example Range" from_port="example set output" to_port="result 1"/>
      <portSpacing port="source_input 1" spacing="90"/>
      <portSpacing port="sink_result 1" spacing="0"/>
      <portSpacing port="sink_result 2" spacing="0"/>
    </process>
  </operator>
</process>
Tagged:

Answers

  • MariusHelfMariusHelf RapidMiner Certified Expert, Member Posts: 1,869 Unicorn
    Hi,

    you can probably use Loop Examples around your current process. Set the loop_attribute to "FIRST_ID" and iteration_macro to "id" and your process should give recommendations for all ids.

    Best regards,
    Marius
  • Legacy UserLegacy User Member Posts: 0 Newbie
    Hi Marius,

    thanks for the reply. I figured this out afterall. I jst changed the whole thing.
    It took me some time to figrue out that the macro input value is in the xml though. ;)

    Best,
    Elena
  • MariusHelfMariusHelf RapidMiner Certified Expert, Member Posts: 1,869 Unicorn
    Hi Elena,

    next time you can directly use the XML: in RapidMiner, go to the View menu -> Show View and make sure that the XML view is visible. There you can simply paste my XML code, and the process will be visible in RapidMiner.

    Best regards,
    Marius
Sign In or Register to comment.