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

using loop parameters info for renaming

lorenzovlorenzov Member Posts: 2 Contributor I
edited June 2019 in Help
hi everyone,

not sure if the logic of what i'm doing is right, so here is the problem:

- i generated sequences of nominal values which i want to compare with a test sequence
- i want to use a loop to run different distance measures
- then collate the whole thing in a single table for exporting

the first script does it with separate streams/processes and then i join them (i'll have to post this separate because of the char limit)

the second one tries to do the same using a loop parameter block, but i don't seem to be able to make it work (see below)

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="6.3.000">
 <context>
   <input/>
   <output/>
   <macros/>
 </context>
 <operator activated="true" class="process" compatibility="6.3.000" expanded="true" name="Process">
   <process expanded="true">
     <operator activated="true" breakpoints="after" class="subprocess" compatibility="6.3.000" expanded="true" height="112" name="Subprocess" width="90" x="45" y="120">
       <process expanded="true">
         <operator activated="true" class="generate_data_user_specification" compatibility="6.3.000" expanded="true" height="60" name="Generate Data by User Specification (3)" width="90" x="380" y="30">
           <list key="attribute_values">
             <parameter key="att1" value="1"/>
             <parameter key="att2" value="2"/>
             <parameter key="att3" value="3"/>
             <parameter key="att4" value="4"/>
             <parameter key="att5" value="5"/>
           </list>
           <list key="set_additional_roles"/>
         </operator>
         <operator activated="true" class="generate_data_user_specification" compatibility="6.3.000" expanded="true" height="60" name="Generate Data by User Specification" width="90" x="45" y="30">
           <list key="attribute_values">
             <parameter key="att1" value="1"/>
             <parameter key="att2" value="2"/>
             <parameter key="att3" value="3"/>
             <parameter key="att4" value="4"/>
             <parameter key="att5" value="5"/>
           </list>
           <list key="set_additional_roles"/>
         </operator>
         <operator activated="true" class="loop" compatibility="6.3.000" expanded="true" height="76" name="Loop" width="90" x="246" y="300">
           <parameter key="iterations" value="100"/>
           <process expanded="true">
             <operator activated="true" class="generate_data_user_specification" compatibility="6.3.000" expanded="true" height="60" name="Generate Data by User Specification (4)" width="90" x="179" y="30">
               <list key="attribute_values">
                 <parameter key="att1" value="floor((rand()*9))"/>
                 <parameter key="att2" value="floor((rand()*9))"/>
                 <parameter key="att3" value="floor((rand()*9))"/>
                 <parameter key="att4" value="floor((rand()*9))"/>
                 <parameter key="att5" value="floor((rand()*9))"/>
               </list>
               <list key="set_additional_roles"/>
             </operator>
             <connect from_op="Generate Data by User Specification (4)" 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="generate_id" compatibility="6.3.000" expanded="true" height="76" name="Generate ID" width="90" x="514" y="30">
           <parameter key="create_nominal_ids" value="true"/>
         </operator>
         <operator activated="true" class="generate_data_user_specification" compatibility="6.3.000" expanded="true" height="60" name="Generate Data by User Specification (2)" width="90" x="45" y="120">
           <list key="attribute_values">
             <parameter key="att1" value="1"/>
             <parameter key="att2" value="2"/>
             <parameter key="att3" value="3"/>
             <parameter key="att4" value="4"/>
             <parameter key="att5" value="5"/>
           </list>
           <list key="set_additional_roles"/>
         </operator>
         <operator activated="true" class="generate_data_user_specification" compatibility="6.3.000" expanded="true" height="60" name="Generate Data by User Specification (5)" width="90" x="45" y="210">
           <list key="attribute_values">
             <parameter key="att1" value="1"/>
             <parameter key="att2" value="3"/>
             <parameter key="att3" value="2"/>
             <parameter key="att4" value="4"/>
             <parameter key="att5" value="5"/>
           </list>
           <list key="set_additional_roles"/>
         </operator>
         <operator activated="true" class="generate_data_user_specification" compatibility="6.3.000" expanded="true" height="60" name="Generate Data by User Specification (6)" width="90" x="45" y="300">
           <list key="attribute_values">
             <parameter key="att1" value="1"/>
             <parameter key="att2" value="2"/>
             <parameter key="att3" value="3"/>
             <parameter key="att4" value="6"/>
             <parameter key="att5" value="7"/>
           </list>
           <list key="set_additional_roles"/>
         </operator>
         <operator activated="true" class="append" compatibility="6.3.000" expanded="true" height="148" name="Append" width="90" x="246" y="75"/>
         <operator activated="true" class="generate_id" compatibility="6.3.000" expanded="true" height="76" name="Generate ID (2)" width="90" x="514" y="120">
           <parameter key="create_nominal_ids" value="true"/>
         </operator>
         <connect from_op="Generate Data by User Specification (3)" from_port="output" to_op="Generate ID" to_port="example set input"/>
         <connect from_op="Generate Data by User Specification" from_port="output" to_op="Append" to_port="example set 1"/>
         <connect from_op="Loop" from_port="output 1" to_op="Append" to_port="example set 5"/>
         <connect from_op="Generate ID" from_port="example set output" to_port="out 1"/>
         <connect from_op="Generate Data by User Specification (2)" from_port="output" to_op="Append" to_port="example set 2"/>
         <connect from_op="Generate Data by User Specification (5)" from_port="output" to_op="Append" to_port="example set 3"/>
         <connect from_op="Generate Data by User Specification (6)" from_port="output" to_op="Append" to_port="example set 4"/>
         <connect from_op="Append" from_port="merged set" to_op="Generate ID (2)" to_port="example set input"/>
         <connect from_op="Generate ID (2)" from_port="example set output" to_port="out 2"/>
         <portSpacing port="source_in 1" spacing="0"/>
         <portSpacing port="sink_out 1" spacing="0"/>
         <portSpacing port="sink_out 2" spacing="162"/>
         <portSpacing port="sink_out 3" spacing="0"/>
         <portSpacing port="sink_out 4" spacing="0"/>
       </process>
     </operator>
     <operator activated="true" class="multiply" compatibility="6.3.000" expanded="true" height="76" name="Multiply (2)" width="90" x="179" y="210"/>
     <operator activated="true" class="multiply" compatibility="6.3.000" expanded="true" height="76" name="Multiply" width="90" x="179" y="75"/>
     <operator activated="true" class="loop_parameters" compatibility="6.3.000" expanded="true" height="94" name="Loop Parameters" width="90" x="447" y="210">
       <list key="parameters">
         <parameter key="Cross Distances (2).numerical_measure" value="EuclideanDistance,CamberraDistance,ManhattanDistance"/>
       </list>
       <process expanded="true">
         <operator activated="true" class="cross_distances" compatibility="6.3.000" expanded="true" height="94" name="Cross Distances (2)" width="90" x="112" y="120"/>
         <operator activated="true" class="generate_macro" compatibility="6.3.000" expanded="true" height="76" name="Generate Macro" width="90" x="313" y="120">
           <list key="function_descriptions">
             <parameter key="colName" value="%{iteration}_model"/>
           </list>
         </operator>
         <operator activated="true" class="generate_id" compatibility="6.3.000" expanded="true" height="76" name="Generate ID (4)" width="90" x="447" y="120">
           <parameter key="create_nominal_ids" value="true"/>
         </operator>
         <operator activated="true" class="rename" compatibility="6.3.000" expanded="true" height="76" name="Rename (2)" width="90" x="581" y="120">
           <parameter key="old_name" value="distance"/>
           <parameter key="new_name" value="%{colName}"/>
           <list key="rename_additional_attributes"/>
         </operator>
         <connect from_port="input 1" to_op="Cross Distances (2)" to_port="request set"/>
         <connect from_port="input 2" to_op="Cross Distances (2)" to_port="reference set"/>
         <connect from_op="Cross Distances (2)" from_port="result set" to_op="Generate Macro" to_port="through 1"/>
         <connect from_op="Generate Macro" from_port="through 1" to_op="Generate ID (4)" to_port="example set input"/>
         <connect from_op="Generate ID (4)" 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_port="performance"/>
         <portSpacing port="source_input 1" spacing="0"/>
         <portSpacing port="source_input 2" spacing="0"/>
         <portSpacing port="source_input 3" spacing="0"/>
         <portSpacing port="sink_performance" spacing="0"/>
         <portSpacing port="sink_result 1" spacing="0"/>
         <portSpacing port="sink_result 2" spacing="0"/>
       </process>
     </operator>
     <connect from_op="Subprocess" from_port="out 1" to_op="Multiply" to_port="input"/>
     <connect from_op="Subprocess" from_port="out 2" to_op="Multiply (2)" to_port="input"/>
     <connect from_op="Subprocess" from_port="out 3" to_port="result 1"/>
     <connect from_op="Multiply (2)" from_port="output 1" to_op="Loop Parameters" to_port="input 2"/>
     <connect from_op="Multiply" from_port="output 1" to_op="Loop Parameters" to_port="input 1"/>
     <connect from_op="Loop Parameters" from_port="result 1" to_port="result 2"/>
     <portSpacing port="source_input 1" spacing="0"/>
     <portSpacing port="sink_result 1" spacing="0"/>
     <portSpacing port="sink_result 2" spacing="0"/>
     <portSpacing port="sink_result 3" spacing="0"/>
   </process>
 </operator>
</process>


any suggestion will be very much appreciated!

Lorenzo

Answers

  • lorenzovlorenzov Member Posts: 2 Contributor I
    and this is the working code without the loop

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="6.3.000">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="6.3.000" expanded="true" name="Process">
        <process expanded="true">
          <operator activated="true" breakpoints="after" class="subprocess" compatibility="6.3.000" expanded="true" height="112" name="Subprocess" width="90" x="45" y="120">
            <process expanded="true">
              <operator activated="true" class="generate_data_user_specification" compatibility="6.3.000" expanded="true" height="60" name="Generate Data by User Specification (3)" width="90" x="380" y="30">
                <list key="attribute_values">
                  <parameter key="att1" value="1"/>
                  <parameter key="att2" value="2"/>
                  <parameter key="att3" value="3"/>
                  <parameter key="att4" value="4"/>
                  <parameter key="att5" value="5"/>
                </list>
                <list key="set_additional_roles"/>
              </operator>
              <operator activated="true" class="generate_data_user_specification" compatibility="6.3.000" expanded="true" height="60" name="Generate Data by User Specification" width="90" x="45" y="30">
                <list key="attribute_values">
                  <parameter key="att1" value="1"/>
                  <parameter key="att2" value="2"/>
                  <parameter key="att3" value="3"/>
                  <parameter key="att4" value="4"/>
                  <parameter key="att5" value="5"/>
                </list>
                <list key="set_additional_roles"/>
              </operator>
              <operator activated="true" class="loop" compatibility="6.3.000" expanded="true" height="76" name="Loop" width="90" x="246" y="300">
                <parameter key="iterations" value="100"/>
                <process expanded="true">
                  <operator activated="true" class="generate_data_user_specification" compatibility="6.3.000" expanded="true" height="60" name="Generate Data by User Specification (4)" width="90" x="179" y="30">
                    <list key="attribute_values">
                      <parameter key="att1" value="floor((rand()*9))"/>
                      <parameter key="att2" value="floor((rand()*9))"/>
                      <parameter key="att3" value="floor((rand()*9))"/>
                      <parameter key="att4" value="floor((rand()*9))"/>
                      <parameter key="att5" value="floor((rand()*9))"/>
                    </list>
                    <list key="set_additional_roles"/>
                  </operator>
                  <connect from_op="Generate Data by User Specification (4)" 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="generate_id" compatibility="6.3.000" expanded="true" height="76" name="Generate ID" width="90" x="514" y="30">
                <parameter key="create_nominal_ids" value="true"/>
              </operator>
              <operator activated="true" class="generate_data_user_specification" compatibility="6.3.000" expanded="true" height="60" name="Generate Data by User Specification (2)" width="90" x="45" y="120">
                <list key="attribute_values">
                  <parameter key="att1" value="1"/>
                  <parameter key="att2" value="2"/>
                  <parameter key="att3" value="3"/>
                  <parameter key="att4" value="4"/>
                  <parameter key="att5" value="5"/>
                </list>
                <list key="set_additional_roles"/>
              </operator>
              <operator activated="true" class="generate_data_user_specification" compatibility="6.3.000" expanded="true" height="60" name="Generate Data by User Specification (5)" width="90" x="45" y="210">
                <list key="attribute_values">
                  <parameter key="att1" value="1"/>
                  <parameter key="att2" value="3"/>
                  <parameter key="att3" value="2"/>
                  <parameter key="att4" value="4"/>
                  <parameter key="att5" value="5"/>
                </list>
                <list key="set_additional_roles"/>
              </operator>
              <operator activated="true" class="generate_data_user_specification" compatibility="6.3.000" expanded="true" height="60" name="Generate Data by User Specification (6)" width="90" x="45" y="300">
                <list key="attribute_values">
                  <parameter key="att1" value="1"/>
                  <parameter key="att2" value="2"/>
                  <parameter key="att3" value="3"/>
                  <parameter key="att4" value="6"/>
                  <parameter key="att5" value="7"/>
                </list>
                <list key="set_additional_roles"/>
              </operator>
              <operator activated="true" class="append" compatibility="6.3.000" expanded="true" height="148" name="Append" width="90" x="246" y="75"/>
              <operator activated="true" class="generate_id" compatibility="6.3.000" expanded="true" height="76" name="Generate ID (2)" width="90" x="514" y="120">
                <parameter key="create_nominal_ids" value="true"/>
              </operator>
              <connect from_op="Generate Data by User Specification (3)" from_port="output" to_op="Generate ID" to_port="example set input"/>
              <connect from_op="Generate Data by User Specification" from_port="output" to_op="Append" to_port="example set 1"/>
              <connect from_op="Loop" from_port="output 1" to_op="Append" to_port="example set 5"/>
              <connect from_op="Generate ID" from_port="example set output" to_port="out 1"/>
              <connect from_op="Generate Data by User Specification (2)" from_port="output" to_op="Append" to_port="example set 2"/>
              <connect from_op="Generate Data by User Specification (5)" from_port="output" to_op="Append" to_port="example set 3"/>
              <connect from_op="Generate Data by User Specification (6)" from_port="output" to_op="Append" to_port="example set 4"/>
              <connect from_op="Append" from_port="merged set" to_op="Generate ID (2)" to_port="example set input"/>
              <connect from_op="Generate ID (2)" from_port="example set output" to_port="out 2"/>
              <portSpacing port="source_in 1" spacing="0"/>
              <portSpacing port="sink_out 1" spacing="0"/>
              <portSpacing port="sink_out 2" spacing="162"/>
              <portSpacing port="sink_out 3" spacing="0"/>
              <portSpacing port="sink_out 4" spacing="0"/>
            </process>
          </operator>
          <operator activated="true" class="multiply" compatibility="6.3.000" expanded="true" height="130" name="Multiply (2)" width="90" x="179" y="210"/>
          <operator activated="true" class="multiply" compatibility="6.3.000" expanded="true" height="130" name="Multiply" width="90" x="179" y="75"/>
          <operator activated="true" class="cross_distances" compatibility="6.3.000" expanded="true" height="94" name="Cross Distances (4)" width="90" x="380" y="435">
            <parameter key="measure_types" value="NumericalMeasures"/>
            <parameter key="nominal_measure" value="DiceSimilarity"/>
            <parameter key="numerical_measure" value="ManhattanDistance"/>
          </operator>
          <operator activated="true" class="cross_distances" compatibility="6.3.000" expanded="true" height="94" name="Cross Distances (3)" width="90" x="380" y="300">
            <parameter key="measure_types" value="NumericalMeasures"/>
            <parameter key="nominal_measure" value="DiceSimilarity"/>
            <parameter key="numerical_measure" value="DiceSimilarity"/>
          </operator>
          <operator activated="true" class="cross_distances" compatibility="6.3.000" expanded="true" height="94" name="Cross Distances (2)" width="90" x="380" y="165">
            <parameter key="measure_types" value="NumericalMeasures"/>
            <parameter key="nominal_measure" value="DiceSimilarity"/>
            <parameter key="numerical_measure" value="JaccardSimilarity"/>
          </operator>
          <operator activated="true" class="cross_distances" compatibility="6.3.000" expanded="true" height="94" name="Cross Distances" width="90" x="380" y="30">
            <parameter key="numerical_measure" value="KernelEuclideanDistance"/>
          </operator>
          <operator activated="true" class="generate_id" compatibility="6.3.000" expanded="true" height="76" name="Generate ID (3)" width="90" x="514" y="120"/>
          <operator activated="true" class="rename" compatibility="6.3.000" expanded="true" height="76" name="Rename" width="90" x="648" y="120">
            <parameter key="old_name" value="distance"/>
            <parameter key="new_name" value="mixedED"/>
            <list key="rename_additional_attributes">
              <parameter key="id" value="id"/>
            </list>
          </operator>
          <operator activated="true" class="generate_id" compatibility="6.3.000" expanded="true" height="76" name="Generate ID (4)" width="90" x="514" y="255"/>
          <operator activated="true" class="rename" compatibility="6.3.000" expanded="true" height="76" name="Rename (2)" width="90" x="648" y="255">
            <parameter key="old_name" value="distance"/>
            <parameter key="new_name" value="canberra"/>
            <list key="rename_additional_attributes">
              <parameter key="id" value="id"/>
            </list>
          </operator>
          <operator activated="true" class="join" compatibility="6.3.000" expanded="true" height="76" name="Join" width="90" x="782" y="165">
            <parameter key="join_type" value="left"/>
            <parameter key="use_id_attribute_as_key" value="false"/>
            <list key="key_attributes">
              <parameter key="id" value="id"/>
            </list>
          </operator>
          <operator activated="true" class="generate_id" compatibility="6.3.000" expanded="true" height="76" name="Generate ID (5)" width="90" x="514" y="390"/>
          <operator activated="true" class="rename" compatibility="6.3.000" expanded="true" height="76" name="Rename (3)" width="90" x="648" y="390">
            <parameter key="old_name" value="distance"/>
            <parameter key="new_name" value="dice"/>
            <list key="rename_additional_attributes">
              <parameter key="id" value="id"/>
            </list>
          </operator>
          <operator activated="true" class="join" compatibility="6.3.000" expanded="true" height="76" name="Join (2)" width="90" x="782" y="300">
            <parameter key="join_type" value="left"/>
            <parameter key="use_id_attribute_as_key" value="false"/>
            <list key="key_attributes">
              <parameter key="id" value="id"/>
            </list>
          </operator>
          <operator activated="true" class="generate_id" compatibility="6.3.000" expanded="true" height="76" name="Generate ID (6)" width="90" x="514" y="525"/>
          <operator activated="true" class="rename" compatibility="6.3.000" expanded="true" height="76" name="Rename (4)" width="90" x="648" y="525">
            <parameter key="old_name" value="distance"/>
            <parameter key="new_name" value="manhattan"/>
            <list key="rename_additional_attributes">
              <parameter key="id" value="id"/>
            </list>
          </operator>
          <operator activated="true" class="join" compatibility="6.3.000" expanded="true" height="76" name="Join (3)" width="90" x="782" y="435">
            <parameter key="join_type" value="left"/>
            <parameter key="use_id_attribute_as_key" value="false"/>
            <list key="key_attributes">
              <parameter key="id" value="id"/>
            </list>
          </operator>
          <connect from_op="Subprocess" from_port="out 1" to_op="Multiply" to_port="input"/>
          <connect from_op="Subprocess" from_port="out 2" to_op="Multiply (2)" to_port="input"/>
          <connect from_op="Subprocess" from_port="out 3" to_port="result 3"/>
          <connect from_op="Multiply (2)" from_port="output 1" to_op="Cross Distances" to_port="reference set"/>
          <connect from_op="Multiply (2)" from_port="output 2" to_op="Cross Distances (2)" to_port="reference set"/>
          <connect from_op="Multiply (2)" from_port="output 3" to_op="Cross Distances (3)" to_port="reference set"/>
          <connect from_op="Multiply (2)" from_port="output 4" to_op="Cross Distances (4)" to_port="reference set"/>
          <connect from_op="Multiply" from_port="output 1" to_op="Cross Distances" to_port="request set"/>
          <connect from_op="Multiply" from_port="output 2" to_op="Cross Distances (2)" to_port="request set"/>
          <connect from_op="Multiply" from_port="output 3" to_op="Cross Distances (3)" to_port="request set"/>
          <connect from_op="Multiply" from_port="output 4" to_op="Cross Distances (4)" to_port="request set"/>
          <connect from_op="Cross Distances (4)" from_port="result set" to_op="Generate ID (6)" to_port="example set input"/>
          <connect from_op="Cross Distances (3)" from_port="result set" to_op="Generate ID (5)" to_port="example set input"/>
          <connect from_op="Cross Distances (2)" from_port="result set" to_op="Generate ID (4)" to_port="example set input"/>
          <connect from_op="Cross Distances" from_port="result set" to_op="Generate ID (3)" to_port="example set input"/>
          <connect from_op="Cross Distances" from_port="request set" to_port="result 2"/>
          <connect from_op="Cross Distances" from_port="reference set" to_port="result 1"/>
          <connect from_op="Generate ID (3)" from_port="example set output" to_op="Rename" to_port="example set input"/>
          <connect from_op="Rename" from_port="example set output" to_op="Join" to_port="left"/>
          <connect from_op="Generate ID (4)" 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="Join" to_port="right"/>
          <connect from_op="Join" from_port="join" to_op="Join (2)" to_port="left"/>
          <connect from_op="Generate ID (5)" from_port="example set output" to_op="Rename (3)" to_port="example set input"/>
          <connect from_op="Rename (3)" from_port="example set output" to_op="Join (2)" to_port="right"/>
          <connect from_op="Join (2)" from_port="join" to_op="Join (3)" to_port="left"/>
          <connect from_op="Generate ID (6)" from_port="example set output" to_op="Rename (4)" to_port="example set input"/>
          <connect from_op="Rename (4)" from_port="example set output" to_op="Join (3)" to_port="right"/>
          <connect from_op="Join (3)" from_port="join" to_port="result 4"/>
          <portSpacing port="source_input 1" spacing="0"/>
          <portSpacing port="sink_result 1" spacing="0"/>
          <portSpacing port="sink_result 2" spacing="0"/>
          <portSpacing port="sink_result 3" spacing="0"/>
          <portSpacing port="sink_result 4" spacing="0"/>
          <portSpacing port="sink_result 5" spacing="0"/>
        </process>
      </operator>
    </process>

Sign In or Register to comment.