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

Problem with loop modelling output saving

sebastian_gonzasebastian_gonza RapidMiner Certified Analyst, Member Posts: 52 Guru
edited December 2018 in Help

Hi

 

I have a Data set with Client ID | Order ID | Quantity | Price, what I want to do is a regression per client ID  like Quantity = Beta + alpha*Price and save the output in a collection, I got to the collection but it keeps printing the same value over and over again, also I would like to append the Client ID to their respective model but I dont know how, could someone help me please?

 

Thanks

 

Attached: Sample data and process

 

<?xml version="1.0" encoding="UTF-8"?><process version="9.0.002">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="9.0.002" expanded="true" name="Process">
<process expanded="true">
<operator activated="true" class="retrieve" compatibility="9.0.002" expanded="true" height="68" name="Retrieve pedidos_con_cliente_importe" width="90" x="45" y="340">
<parameter key="repository_entry" value="pedidos_con_cliente_importe"/>
</operator>
<operator activated="true" class="select_attributes" compatibility="9.0.002" expanded="true" height="82" name="Select Attributes (5)" width="90" x="179" y="340">
<parameter key="attribute_filter_type" value="subset"/>
<parameter key="attributes" value="Cantidad|IdCliente|IdPedido|Importe|Precio calculado"/>
</operator>
<operator activated="true" class="set_role" compatibility="9.0.002" expanded="true" height="82" name="Set Role" width="90" x="313" y="340">
<parameter key="attribute_name" value="Cantidad"/>
<parameter key="target_role" value="label"/>
<list key="set_additional_roles"/>
</operator>
<operator activated="true" class="remove_duplicates" compatibility="9.0.002" expanded="true" height="103" name="Remove Duplicates" width="90" x="447" y="340">
<parameter key="attribute_filter_type" value="subset"/>
<parameter key="attributes" value="IdCliente|IdPedido|Importe|Cantidad"/>
</operator>
<operator activated="true" class="concurrency:loop_values" compatibility="9.0.002" expanded="true" height="82" name="Loop Values" width="90" x="581" y="340">
<parameter key="attribute" value="IdCliente"/>
<process expanded="true">
<operator activated="true" class="select_attributes" compatibility="9.0.002" expanded="true" height="82" name="Select Attributes (6)" width="90" x="112" y="34">
<parameter key="attribute_filter_type" value="subset"/>
<parameter key="attributes" value="Cantidad|Precio calculado"/>
</operator>
<operator activated="true" class="linear_regression" compatibility="9.0.002" expanded="true" height="103" name="Linear Regression" width="90" x="246" y="34">
<parameter key="eliminate_colinear_features" value="false"/>
<parameter key="use_bias" value="false"/>
</operator>
<connect from_port="input 1" to_op="Select Attributes (6)" to_port="example set input"/>
<connect from_op="Select Attributes (6)" from_port="example set output" to_op="Linear Regression" to_port="training set"/>
<connect from_op="Linear Regression" from_port="model" to_port="output 1"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="source_input 2" spacing="0"/>
<portSpacing port="sink_output 1" spacing="0"/>
<portSpacing port="sink_output 2" spacing="0"/>
</process>
</operator>
<operator activated="true" class="collect" compatibility="9.0.002" expanded="true" height="82" name="Collect" width="90" x="715" y="340"/>
<connect from_op="Retrieve pedidos_con_cliente_importe" from_port="output" to_op="Select Attributes (5)" to_port="example set input"/>
<connect from_op="Select Attributes (5)" from_port="example set output" to_op="Set Role" to_port="example set input"/>
<connect from_op="Set Role" from_port="example set output" to_op="Remove Duplicates" to_port="example set input"/>
<connect from_op="Remove Duplicates" from_port="example set output" to_op="Loop Values" to_port="input 1"/>
<connect from_op="Loop Values" from_port="output 1" to_op="Collect" to_port="input 1"/>
<connect from_op="Collect" from_port="collection" 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>

 

 

Best Answers

  • MartinLiebigMartinLiebig Administrator, Moderator, Employee-RapidMiner, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 3,533 RM Data Scientist
    Solution Accepted

    Hi,

    attached is a solution. You need Operator Toolbox extension to run this.

     

    Best,

    Martin

     

    <?xml version="1.0" encoding="UTF-8"?><process version="9.0.002">
    <context>
    <input/>
    <output/>
    <macros/>
    </context>
    <operator activated="true" class="process" compatibility="9.0.002" expanded="true" name="Process">
    <process expanded="true">
    <operator activated="true" class="retrieve" compatibility="9.0.002" expanded="true" height="68" name="Retrieve pedidos_con_cliente_importe" width="90" x="45" y="340">
    <parameter key="repository_entry" value="pedidos_con_cliente_importe"/>
    </operator>
    <operator activated="true" class="select_attributes" compatibility="9.0.002" expanded="true" height="82" name="Select Attributes (5)" width="90" x="179" y="340">
    <parameter key="attribute_filter_type" value="subset"/>
    <parameter key="attributes" value="Cantidad|IdCliente|IdPedido|Importe|Precio calculado"/>
    </operator>
    <operator activated="true" class="set_role" compatibility="9.0.002" expanded="true" height="82" name="Set Role" width="90" x="313" y="340">
    <parameter key="attribute_name" value="Cantidad"/>
    <parameter key="target_role" value="label"/>
    <list key="set_additional_roles"/>
    </operator>
    <operator activated="true" class="remove_duplicates" compatibility="9.0.002" expanded="true" height="103" name="Remove Duplicates" width="90" x="447" y="340">
    <parameter key="attribute_filter_type" value="subset"/>
    <parameter key="attributes" value="IdCliente|IdPedido|Importe|Cantidad"/>
    </operator>
    <operator activated="false" class="concurrency:loop_values" compatibility="9.0.002" expanded="true" height="68" name="Loop Values" width="90" x="782" y="238">
    <parameter key="attribute" value="IdCliente"/>
    <process expanded="true">
    <operator activated="true" class="select_attributes" compatibility="9.0.002" expanded="true" height="82" name="Select Attributes (6)" width="90" x="581" y="136">
    <parameter key="attribute_filter_type" value="subset"/>
    <parameter key="attributes" value="Cantidad|Precio calculado"/>
    </operator>
    <operator activated="true" class="linear_regression" compatibility="9.0.002" expanded="true" height="103" name="Linear Regression" width="90" x="715" y="136">
    <parameter key="eliminate_colinear_features" value="false"/>
    <parameter key="use_bias" value="false"/>
    </operator>
    <connect from_op="Select Attributes (6)" from_port="example set output" to_op="Linear Regression" to_port="training set"/>
    <portSpacing port="source_input 1" spacing="0"/>
    <portSpacing port="sink_output 1" spacing="0"/>
    </process>
    </operator>
    <operator activated="true" class="collect" compatibility="9.0.002" expanded="true" height="82" name="Collect" width="90" x="983" y="340"/>
    <operator activated="true" class="operator_toolbox:group_into_collection" compatibility="1.5.000-SNAPSHOT" expanded="true" height="82" name="Group Into Collection" width="90" x="581" y="340">
    <parameter key="group_by_attribute" value="IdCliente"/>
    </operator>
    <operator activated="true" class="loop_collection" compatibility="9.0.002" expanded="true" height="82" name="Loop Collection" width="90" x="782" y="340">
    <process expanded="true">
    <operator activated="true" class="select_attributes" compatibility="9.0.002" expanded="true" height="82" name="Select Attributes (2)" width="90" x="179" y="85">
    <parameter key="attribute_filter_type" value="subset"/>
    <parameter key="attributes" value="Cantidad|Precio calculado"/>
    </operator>
    <operator activated="true" class="linear_regression" compatibility="9.0.002" expanded="true" height="103" name="Linear Regression (2)" width="90" x="313" y="85">
    <parameter key="eliminate_colinear_features" value="false"/>
    <parameter key="use_bias" value="false"/>
    </operator>
    <connect from_port="single" to_op="Select Attributes (2)" to_port="example set input"/>
    <connect from_op="Select Attributes (2)" from_port="example set output" to_op="Linear Regression (2)" to_port="training set"/>
    <connect from_op="Linear Regression (2)" from_port="model" to_port="output 1"/>
    <portSpacing port="source_single" spacing="0"/>
    <portSpacing port="sink_output 1" spacing="0"/>
    <portSpacing port="sink_output 2" spacing="0"/>
    </process>
    </operator>
    <connect from_op="Retrieve pedidos_con_cliente_importe" from_port="output" to_op="Select Attributes (5)" to_port="example set input"/>
    <connect from_op="Select Attributes (5)" from_port="example set output" to_op="Set Role" to_port="example set input"/>
    <connect from_op="Set Role" from_port="example set output" to_op="Remove Duplicates" to_port="example set input"/>
    <connect from_op="Remove Duplicates" from_port="example set output" to_op="Collect" to_port="input 1"/>
    <connect from_op="Collect" from_port="collection" 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
  • MartinLiebigMartinLiebig Administrator, Moderator, Employee-RapidMiner, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 3,533 RM Data Scientist
    Solution Accepted

    @sebastian_gonza,

    did you use macros? Attached a version with annotate.

     

    Cheers,

    Martin

     

    <?xml version="1.0" encoding="UTF-8"?><process version="9.0.002">
    <context>
    <input/>
    <output/>
    <macros/>
    </context>
    <operator activated="true" class="process" compatibility="9.0.002" expanded="true" name="Process">
    <process expanded="true">
    <operator activated="true" class="retrieve" compatibility="9.0.002" expanded="true" height="68" name="Retrieve pedidos_con_cliente_importe" width="90" x="45" y="340">
    <parameter key="repository_entry" value="pedidos_con_cliente_importe"/>
    </operator>
    <operator activated="true" class="select_attributes" compatibility="9.0.002" expanded="true" height="82" name="Select Attributes (5)" width="90" x="179" y="340">
    <parameter key="attribute_filter_type" value="subset"/>
    <parameter key="attributes" value="Cantidad|IdCliente|IdPedido|Importe|Precio calculado"/>
    </operator>
    <operator activated="true" class="set_role" compatibility="9.0.002" expanded="true" height="82" name="Set Role" width="90" x="313" y="340">
    <parameter key="attribute_name" value="Cantidad"/>
    <parameter key="target_role" value="label"/>
    <list key="set_additional_roles"/>
    </operator>
    <operator activated="true" class="remove_duplicates" compatibility="9.0.002" expanded="true" height="103" name="Remove Duplicates" width="90" x="447" y="340">
    <parameter key="attribute_filter_type" value="subset"/>
    <parameter key="attributes" value="IdCliente|IdPedido|Importe|Cantidad"/>
    </operator>
    <operator activated="false" class="concurrency:loop_values" compatibility="9.0.002" expanded="true" height="68" name="Loop Values" width="90" x="782" y="238">
    <parameter key="attribute" value="IdCliente"/>
    <process expanded="true">
    <operator activated="true" class="select_attributes" compatibility="9.0.002" expanded="true" height="82" name="Select Attributes (6)" width="90" x="581" y="136">
    <parameter key="attribute_filter_type" value="subset"/>
    <parameter key="attributes" value="Cantidad|Precio calculado"/>
    </operator>
    <operator activated="true" class="linear_regression" compatibility="9.0.002" expanded="true" height="103" name="Linear Regression" width="90" x="715" y="136">
    <parameter key="eliminate_colinear_features" value="false"/>
    <parameter key="use_bias" value="false"/>
    </operator>
    <connect from_op="Select Attributes (6)" from_port="example set output" to_op="Linear Regression" to_port="training set"/>
    <portSpacing port="source_input 1" spacing="0"/>
    <portSpacing port="sink_output 1" spacing="0"/>
    </process>
    </operator>
    <operator activated="true" class="collect" compatibility="9.0.002" expanded="true" height="82" name="Collect" width="90" x="983" y="340"/>
    <operator activated="true" class="operator_toolbox:group_into_collection" compatibility="1.5.000-SNAPSHOT" expanded="true" height="82" name="Group Into Collection" width="90" x="581" y="340">
    <parameter key="group_by_attribute" value="IdCliente"/>
    </operator>
    <operator activated="true" class="loop_collection" compatibility="9.0.002" expanded="true" height="82" name="Loop Collection" width="90" x="782" y="340">
    <process expanded="true">
    <operator activated="true" class="extract_macro" compatibility="9.0.002" expanded="true" height="68" name="Extract Macro" width="90" x="45" y="34">
    <parameter key="macro" value="IdCliente"/>
    <parameter key="macro_type" value="data_value"/>
    <parameter key="attribute_name" value="IdCliente"/>
    <parameter key="example_index" value="1"/>
    <list key="additional_macros"/>
    </operator>
    <operator activated="true" class="select_attributes" compatibility="9.0.002" expanded="true" height="82" name="Select Attributes (2)" width="90" x="179" y="85">
    <parameter key="attribute_filter_type" value="subset"/>
    <parameter key="attributes" value="Cantidad|Precio calculado"/>
    </operator>
    <operator activated="true" class="linear_regression" compatibility="9.0.002" expanded="true" height="103" name="Linear Regression (2)" width="90" x="313" y="85">
    <parameter key="eliminate_colinear_features" value="false"/>
    <parameter key="use_bias" value="false"/>
    </operator>
    <operator activated="true" class="annotate" compatibility="9.0.002" expanded="true" height="68" name="Annotate" width="90" x="514" y="85">
    <list key="annotations">
    <parameter key="Comment" value="%{IdCliente}"/>
    </list>
    </operator>
    <connect from_port="single" to_op="Extract Macro" to_port="example set"/>
    <connect from_op="Extract Macro" from_port="example set" to_op="Select Attributes (2)" to_port="example set input"/>
    <connect from_op="Select Attributes (2)" from_port="example set output" to_op="Linear Regression (2)" to_port="training set"/>
    <connect from_op="Linear Regression (2)" from_port="model" to_op="Annotate" to_port="input"/>
    <connect from_op="Annotate" from_port="output" to_port="output 1"/>
    <portSpacing port="source_single" spacing="0"/>
    <portSpacing port="sink_output 1" spacing="0"/>
    <portSpacing port="sink_output 2" spacing="0"/>
    </process>
    </operator>
    <connect from_op="Retrieve pedidos_con_cliente_importe" from_port="output" to_op="Select Attributes (5)" to_port="example set input"/>
    <connect from_op="Select Attributes (5)" from_port="example set output" to_op="Set Role" to_port="example set input"/>
    <connect from_op="Set Role" from_port="example set output" to_op="Remove Duplicates" to_port="example set input"/>
    <connect from_op="Remove Duplicates" from_port="example set output" to_op="Collect" to_port="input 1"/>
    <connect from_op="Collect" from_port="collection" 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

  • sebastian_gonzasebastian_gonza RapidMiner Certified Analyst, Member Posts: 52 Guru

    Sample Data

  • lionelderkrikorlionelderkrikor RapidMiner Certified Analyst, Member Posts: 1,195 Unicorn

    Hi @sebastian_gonza,

     

    Can you check your XML file : It seems to be broken (it can not be loaded in RapidMiner)

     

    Regards,

     

    Lionel

  • sebastian_gonzasebastian_gonza RapidMiner Certified Analyst, Member Posts: 52 Guru

    <?xml version="1.0" encoding="UTF-8"?><process version="9.0.002">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="9.0.002" expanded="true" name="Process">
        <process expanded="true">
          <operator activated="true" class="retrieve" compatibility="9.0.002" expanded="true" height="68" name="Retrieve pedidos_con_cliente_importe" width="90" x="45" y="340">
            <parameter key="repository_entry" value="pedidos_con_cliente_importe"/>
          </operator>
          <operator activated="true" class="select_attributes" compatibility="9.0.002" expanded="true" height="82" name="Select Attributes (5)" width="90" x="179" y="340">
            <parameter key="attribute_filter_type" value="subset"/>
            <parameter key="attributes" value="Cantidad|IdCliente|IdPedido|Importe|Precio calculado"/>
          </operator>
          <operator activated="true" class="set_role" compatibility="9.0.002" expanded="true" height="82" name="Set Role" width="90" x="313" y="340">
            <parameter key="attribute_name" value="Cantidad"/>
            <parameter key="target_role" value="label"/>
            <list key="set_additional_roles"/>
          </operator>
          <operator activated="true" class="remove_duplicates" compatibility="9.0.002" expanded="true" height="103" name="Remove Duplicates" width="90" x="447" y="340">
            <parameter key="attribute_filter_type" value="subset"/>
            <parameter key="attributes" value="IdCliente|IdPedido|Importe|Cantidad"/>
          </operator>
          <operator activated="true" class="concurrency:loop_values" compatibility="9.0.002" expanded="true" height="82" name="Loop Values" width="90" x="581" y="340">
            <parameter key="attribute" value="IdCliente"/>
            <process expanded="true">
              <operator activated="true" class="select_attributes" compatibility="9.0.002" expanded="true" height="82" name="Select Attributes (6)" width="90" x="112" y="34">
                <parameter key="attribute_filter_type" value="subset"/>
                <parameter key="attributes" value="Cantidad|Precio calculado"/>
              </operator>
              <operator activated="true" class="linear_regression" compatibility="9.0.002" expanded="true" height="103" name="Linear Regression" width="90" x="246" y="34">
                <parameter key="eliminate_colinear_features" value="false"/>
                <parameter key="use_bias" value="false"/>
              </operator>
              <connect from_port="input 1" to_op="Select Attributes (6)" to_port="example set input"/>
              <connect from_op="Select Attributes (6)" from_port="example set output" to_op="Linear Regression" to_port="training set"/>
              <connect from_op="Linear Regression" from_port="model" to_port="output 1"/>
              <portSpacing port="source_input 1" spacing="0"/>
              <portSpacing port="source_input 2" spacing="0"/>
              <portSpacing port="sink_output 1" spacing="0"/>
              <portSpacing port="sink_output 2" spacing="0"/>
            </process>
          </operator>
          <operator activated="true" class="collect" compatibility="9.0.002" expanded="true" height="82" name="Collect" width="90" x="715" y="340"/>
          <connect from_op="Retrieve pedidos_con_cliente_importe" from_port="output" to_op="Select Attributes (5)" to_port="example set input"/>
          <connect from_op="Select Attributes (5)" from_port="example set output" to_op="Set Role" to_port="example set input"/>
          <connect from_op="Set Role" from_port="example set output" to_op="Remove Duplicates" to_port="example set input"/>
          <connect from_op="Remove Duplicates" from_port="example set output" to_op="Loop Values" to_port="input 1"/>
          <connect from_op="Loop Values" from_port="output 1" to_op="Collect" to_port="input 1"/>
          <connect from_op="Collect" from_port="collection" 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>

  • sebastian_gonzasebastian_gonza RapidMiner Certified Analyst, Member Posts: 52 Guru

    Thank you Martin :)

  • sebastian_gonzasebastian_gonza RapidMiner Certified Analyst, Member Posts: 52 Guru

    Sorry one last thing, I tried using "Append" operator to join all the model results in a table but it only allows a table to be joined, also I cant append the IDclient to each model, could you help me please?

     

    Thank you

  • MartinLiebigMartinLiebig Administrator, Moderator, Employee-RapidMiner, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 3,533 RM Data Scientist

    Hi,

    i think Annotate is the way to go here.

     

    BR,

    Martin

    - Sr. Director Data Solutions, Altair RapidMiner -
    Dortmund, Germany
  • sebastian_gonzasebastian_gonza RapidMiner Certified Analyst, Member Posts: 52 Guru

    Sorry, I could not ad the IdCliente to each model with annotate, I set the parameters 

     

    Annotation name = Comment

    Annotation value = IdCliente

     

    But no specific model has the IdClient append to the IOObject

     

    Should it be another annotation name?

Sign In or Register to comment.