"create a loop with rapidMiner"

samia
samia New Altair Community Member
edited November 5 in Community Q&A
hello,i want to use polynomial regression so as to predict the amount of products sales,whene i use it,it gives me one formula to calculate the predictive amount for all products,but the problem is that i have lot off products so logicaly it has to give me for each product his suitbale formula,so,after lot of search i found that i have to create a loop with rapidMiner that it will iterate the produts and give them the formula for each product but i don't know how to create it and make relation with products,,can you help me please?

Answers

  • MariusHelf
    MariusHelf New Altair Community Member
    Hi Samia,

    to help you, we would need to know the format of your data. Please describe which columns and attributes you have, or give a small example. The link in my signature provides further advice on which information to include in a question.

    Best regards,
    Marius
  • samia
    samia New Altair Community Member
    hi,thank you for your reply,so,i have an excel file that contains the attributes:name of product,amount of sales,year,month,day,and i have 30 name of products,so what i want to do is to predict the amount of each product for all days of January 2013,i imported the file into rapidMiner,and i made the attribute amount as a label attribute,so,it gave me the formula to calculate the wanted amount as :a*year+b*month+c*day+d.but i have to give for each product his formula to calculate his predictive amount.so that is why i spok about loop but i don't know how to use them and if there are any other solution you can tell me thank you so much.
  • StaryVena
    StaryVena New Altair Community Member
    Hello samia,
    I hope this process is what you want:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.2.008">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="5.2.008" expanded="true" name="Process">
        <process expanded="true" height="190" width="346">
          <operator activated="true" class="read_excel" compatibility="5.2.008" expanded="true" height="60" name="Read Excel" width="90" x="45" y="30">
            <list key="annotations"/>
            <list key="data_set_meta_data_information"/>
          </operator>
          <operator activated="true" class="loop_attributes" compatibility="5.2.008" expanded="true" height="60" name="Loop Attributes" width="90" x="246" y="30">
            <parameter key="attribute_filter_type" value="single"/>
            <parameter key="attribute" value="attributePRODUCTname"/>
            <parameter key="iteration_macro" value="product"/>
            <process expanded="true" height="504" width="777">
              <operator activated="true" class="filter_examples" compatibility="5.2.008" expanded="true" height="76" name="Filter Examples" width="90" x="45" y="30">
                <parameter key="condition_class" value="attribute_value_filter"/>
                <parameter key="parameter_string" value="attributePRODUCTname=%{product}"/>
              </operator>
              <operator activated="true" class="x_validation" compatibility="5.0.000" expanded="true" height="112" name="Validation" width="90" x="246" y="30">
                <description>A cross validation including a linear regression.</description>
                <process expanded="true" height="654" width="466">
                  <operator activated="true" class="linear_regression" compatibility="5.0.000" expanded="true" height="94" name="Linear Regression" width="90" x="45" y="30"/>
                  <connect from_port="training" to_op="Linear Regression" to_port="training set"/>
                  <connect from_op="Linear Regression" from_port="model" to_port="model"/>
                  <portSpacing port="source_training" spacing="0"/>
                  <portSpacing port="sink_model" spacing="0"/>
                  <portSpacing port="sink_through 1" spacing="0"/>
                </process>
                <process expanded="true" height="654" width="466">
                  <operator activated="true" class="apply_model" compatibility="5.0.000" expanded="true" height="76" name="Apply Model" width="90" x="45" y="30">
                    <list key="application_parameters"/>
                  </operator>
                  <operator activated="true" class="performance" compatibility="5.0.000" expanded="true" height="76" name="Performance" width="90" x="179" y="30"/>
                  <connect from_port="model" to_op="Apply Model" to_port="model"/>
                  <connect from_port="test set" to_op="Apply Model" to_port="unlabelled data"/>
                  <connect from_op="Apply Model" from_port="labelled data" to_op="Performance" to_port="labelled data"/>
                  <connect from_op="Performance" from_port="performance" to_port="averagable 1"/>
                  <portSpacing port="source_model" spacing="0"/>
                  <portSpacing port="source_test set" spacing="0"/>
                  <portSpacing port="source_through 1" spacing="0"/>
                  <portSpacing port="sink_averagable 1" spacing="0"/>
                  <portSpacing port="sink_averagable 2" spacing="0"/>
                </process>
              </operator>
              <operator activated="true" class="store" compatibility="5.2.008" expanded="true" height="60" name="Store (2)" width="90" x="447" y="30">
                <parameter key="repository_entry" value="//default/%{product}model"/>
              </operator>
              <operator activated="true" class="store" compatibility="5.2.008" expanded="true" height="60" name="Store" width="90" x="447" y="120">
                <parameter key="repository_entry" value="//default/%{product}performance"/>
              </operator>
              <connect from_port="example set" to_op="Filter Examples" to_port="example set input"/>
              <connect from_op="Filter Examples" from_port="example set output" to_op="Validation" to_port="training"/>
              <connect from_op="Validation" from_port="model" to_op="Store (2)" to_port="input"/>
              <connect from_op="Validation" from_port="averagable 1" to_op="Store" to_port="input"/>
              <portSpacing port="source_example set" spacing="0"/>
              <portSpacing port="sink_example set" spacing="0"/>
            </process>
          </operator>
          <connect from_op="Read Excel" from_port="output" to_op="Loop Attributes" to_port="example set"/>
          <connect from_op="Loop Attributes" from_port="example set" 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>
    Best,
    Václav
  • samia
    samia New Altair Community Member
    hello,thank you for your help,but i didn't understant this code,is it for creating a loop?how can i add it in rapidMiner and make relation with  what i want?
    best regards.
  • StaryVena
    StaryVena New Altair Community Member
    Hello,
    next to Process tab in rapidminer (it is above place, where you put operators) is XML tab.  You can place there the code and then click on green check mark to apply changes.

    Best,
    Václav
  • samia
    samia New Altair Community Member
    ok,i have made the xml code and i applied the changes,but i don't know what can i do after that ! how can i use this?
    thank you.
  • StaryVena
    StaryVena New Altair Community Member
    What process do: In reads excel file, than i iterates over values of one attribute (products). It select only examples with one product name (
    Filter Examples operator) in each iteration. Than X-Validation creates model and calculate performance. This two objects are stored in repository.
    What you have to do:
    Set properly Read Excel operator.
    Set the attribute in the Loop Attributes according to name of the attribute which handles product name. Now it is set to attributePRODUCTname.
    Same as in the Loop Attributes set parameter string in the Filter Examples to right attribute name.

    Best,
    Václav
  • samia
    samia New Altair Community Member
    hello,sorry for lot of questions but i'm new in rapidMiner so it not easy for me to understand how to use it
    so, to set the Read excel operation, as i understood from what you said is that i must change
    the properties in the xml file such:to change  name="Read Excel" by name="the name of my excel file".!
  • StaryVena
    StaryVena New Altair Community Member
    Hello,
    no, when you paste the XML code and click on the apply button, you can switch back to the Process tab and edit there settings using GUI.

    Best,
    Václav
  • samia
    samia New Altair Community Member
    hello,i tried to send you a print screen so as to understand more what i'm doing but there is no option there that allow me to do that,can you give me you mail i think it will be more helpful.
  • StaryVena
    StaryVena New Altair Community Member
    Hello,
    you can upload your image on some free image hosting like http://postimage.org/. And then put the link here. I think it is better for other users. But if you want, I can send you my email via private message.

    Best,
    Václav
  • samia
    samia New Altair Community Member
    ok that is good,here is the link of the image: http://s9.postimage.org/ufc8x1agf/rapid_Miner.png
    so i tried what you said to me and i tried to add polynomia regression but it doesn't work  :'(