[SOLVED] Finding one exampleset within another without id attribute

tennenrishin
tennenrishin New Altair Community Member
edited November 2024 in Community Q&A
Let A be a large exampleset, without an id attribute.
Let B be a smaller exampleset with the same set of attributes, but fewer examples, say N.
(Usually N < 5)

Suppose we know that B is equal to some contiguous subrange of the examples in A. In other words, there exists some integer K such that every attribute in example B == every attribute in example A[K+J] for all J from 1 to N.

How can I get K? (e.g. into a macro)
Tagged:

Answers

  • homburg
    homburg New Altair Community Member
    Hi,

    matching patterns in example sets is a tricky thing. There are no operators for this in RapidMiner. You may have a look at this process, it does what you are looking for, although using it in combination with a huge example set may take some time...

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="6.0.008">
     <context>
       <input/>
       <output/>
       <macros/>
     </context>
     <operator activated="true" class="process" compatibility="6.0.008" expanded="true" name="Process">
       <process expanded="true">
         <operator activated="true" class="retrieve" compatibility="6.0.008" expanded="true" height="60" name="Set B" width="90" x="45" y="120">
           <parameter key="repository_entry" value="//Samples/data/Golf"/>
         </operator>
         <operator activated="true" class="filter_example_range" compatibility="6.0.008" expanded="true" height="76" name="Filter Example Range" width="90" x="179" y="120">
           <parameter key="first_example" value="5"/>
           <parameter key="last_example" value="8"/>
         </operator>
         <operator activated="true" class="extract_macro" compatibility="6.0.008" expanded="true" height="60" name="Size B" width="90" x="313" y="120">
           <parameter key="macro" value="size_b"/>
           <list key="additional_macros"/>
         </operator>
         <operator activated="true" class="loop" compatibility="6.0.008" expanded="true" height="76" name="SET A" width="90" x="45" y="30">
           <parameter key="iterations" value="10"/>
           <process expanded="true">
             <operator activated="true" class="retrieve" compatibility="6.0.008" expanded="true" height="60" name="Retrieve Golf" width="90" x="112" y="30">
               <parameter key="repository_entry" value="//Samples/data/Golf"/>
             </operator>
             <connect from_op="Retrieve Golf" from_port="output" to_port="output 1"/>
             <portSpacing port="source_input 1" spacing="0"/>
             <portSpacing port="sink_output 1" spacing="0"/>
             <portSpacing port="sink_output 2" spacing="0"/>
           </process>
         </operator>
         <operator activated="true" class="append" compatibility="6.0.008" expanded="true" height="76" name="Append" width="90" x="179" y="30"/>
         <operator activated="true" class="extract_macro" compatibility="6.0.008" expanded="true" height="60" name="Size A" width="90" x="313" y="30">
           <parameter key="macro" value="size_a"/>
           <list key="additional_macros"/>
         </operator>
         <operator activated="true" class="subprocess" compatibility="6.0.008" expanded="true" height="94" name="Find Match" width="90" x="514" y="75">
           <process expanded="true">
             <operator activated="true" class="loop" compatibility="6.0.008" expanded="true" height="94" name="Loop Content" width="90" x="313" y="30">
               <parameter key="set_iteration_macro" value="true"/>
               <parameter key="iterations" value="%{size_a}"/>
               <process expanded="true">
                 <operator activated="true" class="generate_macro" compatibility="6.0.008" expanded="true" height="76" name="Generate Macro" width="90" x="313" y="30">
                   <list key="function_descriptions">
                     <parameter key="end_index" value="str(%{iteration} + %{size_b} - 1)"/>
                   </list>
                 </operator>
                 <operator activated="true" class="filter_example_range" compatibility="6.0.008" expanded="true" height="76" name="Filter Example Range (2)" width="90" x="447" y="30">
                   <parameter key="first_example" value="%{iteration}"/>
                   <parameter key="last_example" value="%{end_index}"/>
                 </operator>
                 <operator activated="true" class="subprocess" compatibility="6.0.008" expanded="true" height="94" name="Compare" width="90" x="581" y="75">
                   <process expanded="true">
                     <operator activated="true" class="loop" compatibility="6.0.008" expanded="true" height="94" name="Loop" width="90" x="179" y="30">
                       <parameter key="set_iteration_macro" value="true"/>
                       <parameter key="macro_name" value="pattern_row"/>
                       <parameter key="iterations" value="%{size_b}"/>
                       <process expanded="true">
                         <operator activated="true" class="filter_example_range" compatibility="6.0.008" expanded="true" height="76" name="Filter Example Range (3)" width="90" x="112" y="30">
                           <parameter key="first_example" value="%{pattern_row}"/>
                           <parameter key="last_example" value="%{pattern_row}"/>
                         </operator>
                         <operator activated="true" class="filter_example_range" compatibility="6.0.008" expanded="true" height="76" name="Filter Example Range (4)" width="90" x="112" y="120">
                           <parameter key="first_example" value="%{pattern_row}"/>
                           <parameter key="last_example" value="%{pattern_row}"/>
                         </operator>
                         <operator activated="true" class="append" compatibility="6.0.008" expanded="true" height="94" name="Append (2)" width="90" x="246" y="75"/>
                         <operator activated="true" class="remove_duplicates" compatibility="6.0.008" expanded="true" height="76" name="Remove Duplicates" width="90" x="380" y="75">
                           <parameter key="include_special_attributes" value="true"/>
                         </operator>
                         <connect from_port="input 1" to_op="Filter Example Range (3)" to_port="example set input"/>
                         <connect from_port="input 2" to_op="Filter Example Range (4)" to_port="example set input"/>
                         <connect from_op="Filter Example Range (3)" from_port="example set output" to_op="Append (2)" to_port="example set 1"/>
                         <connect from_op="Filter Example Range (4)" from_port="example set output" to_op="Append (2)" to_port="example set 2"/>
                         <connect from_op="Append (2)" from_port="merged set" to_op="Remove Duplicates" to_port="example set input"/>
                         <connect from_op="Remove Duplicates" 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="source_input 3" spacing="0"/>
                         <portSpacing port="sink_output 1" spacing="0"/>
                         <portSpacing port="sink_output 2" spacing="0"/>
                       </process>
                     </operator>
                     <operator activated="true" class="append" compatibility="6.0.008" expanded="true" height="76" name="Append (3)" width="90" x="313" y="30"/>
                     <operator activated="true" class="branch" compatibility="6.0.008" expanded="true" height="76" name="Branch" width="90" x="514" y="30">
                       <parameter key="condition_type" value="max_examples"/>
                       <parameter key="condition_value" value="%{size_b}"/>
                       <process expanded="true">
                         <operator activated="true" class="generate_data_user_specification" compatibility="6.0.008" expanded="true" height="60" name="Start Match Table" width="90" x="179" y="30">
                           <list key="attribute_values">
                             <parameter key="match_in_line" value="%{iteration}"/>
                           </list>
                           <list key="set_additional_roles"/>
                         </operator>
                         <connect from_op="Start Match Table" from_port="output" to_port="input 1"/>
                         <portSpacing port="source_condition" spacing="0"/>
                         <portSpacing port="source_input 1" spacing="0"/>
                         <portSpacing port="sink_input 1" spacing="0"/>
                         <portSpacing port="sink_input 2" spacing="0"/>
                       </process>
                       <process expanded="true">
                         <portSpacing port="source_condition" spacing="0"/>
                         <portSpacing port="source_input 1" spacing="0"/>
                         <portSpacing port="sink_input 1" spacing="0"/>
                         <portSpacing port="sink_input 2" spacing="0"/>
                       </process>
                     </operator>
                     <connect from_port="in 1" to_op="Loop" to_port="input 1"/>
                     <connect from_port="in 2" to_op="Loop" to_port="input 2"/>
                     <connect from_op="Loop" from_port="output 1" to_op="Append (3)" to_port="example set 1"/>
                     <connect from_op="Append (3)" from_port="merged set" to_op="Branch" to_port="condition"/>
                     <connect from_op="Branch" from_port="input 1" to_port="out 1"/>
                     <portSpacing port="source_in 1" spacing="0"/>
                     <portSpacing port="source_in 2" spacing="0"/>
                     <portSpacing port="source_in 3" spacing="0"/>
                     <portSpacing port="sink_out 1" spacing="0"/>
                     <portSpacing port="sink_out 2" spacing="0"/>
                   </process>
                 </operator>
                 <connect from_port="input 1" to_op="Generate Macro" to_port="through 1"/>
                 <connect from_port="input 2" to_op="Compare" to_port="in 2"/>
                 <connect from_op="Generate Macro" from_port="through 1" to_op="Filter Example Range (2)" to_port="example set input"/>
                 <connect from_op="Filter Example Range (2)" from_port="example set output" to_op="Compare" to_port="in 1"/>
                 <connect from_op="Compare" from_port="out 1" to_port="output 1"/>
                 <portSpacing port="source_input 1" spacing="0"/>
                 <portSpacing port="source_input 2" spacing="0"/>
                 <portSpacing port="source_input 3" spacing="0"/>
                 <portSpacing port="sink_output 1" spacing="0"/>
                 <portSpacing port="sink_output 2" spacing="0"/>
               </process>
             </operator>
             <operator activated="true" class="append" compatibility="6.0.008" expanded="true" height="76" name="Collect Matches" width="90" x="447" y="30"/>
             <connect from_port="in 1" to_op="Loop Content" to_port="input 1"/>
             <connect from_port="in 2" to_op="Loop Content" to_port="input 2"/>
             <connect from_op="Loop Content" from_port="output 1" to_op="Collect Matches" to_port="example set 1"/>
             <connect from_op="Collect Matches" from_port="merged set" to_port="out 1"/>
             <portSpacing port="source_in 1" spacing="0"/>
             <portSpacing port="source_in 2" spacing="0"/>
             <portSpacing port="source_in 3" spacing="0"/>
             <portSpacing port="sink_out 1" spacing="0"/>
             <portSpacing port="sink_out 2" spacing="0"/>
           </process>
         </operator>
         <connect from_op="Set B" from_port="output" to_op="Filter Example Range" to_port="example set input"/>
         <connect from_op="Filter Example Range" from_port="example set output" to_op="Size B" to_port="example set"/>
         <connect from_op="Size B" from_port="example set" to_op="Find Match" to_port="in 2"/>
         <connect from_op="SET A" from_port="output 1" to_op="Append" to_port="example set 1"/>
         <connect from_op="Append" from_port="merged set" to_op="Size A" to_port="example set"/>
         <connect from_op="Size A" from_port="example set" to_op="Find Match" to_port="in 1"/>
         <connect from_op="Find Match" from_port="out 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>
    Cheers,
    Helge
  • tennenrishin
    tennenrishin New Altair Community Member
    Thank you!

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.