Loop through filtered values

asav_yuasav_yu MemberPosts:15Maven
edited August 2019 inHelp
I am having trouble putting together a loop.

I have a dataset with multiple products. Let's say I want to run the model three times for 3 different products. I created 3 macros with product names.

Then in my filter Product Name = Macro 1, run model on that filtered dataset. Then how do I create a loop so it goes Product Name = Macro 2 etc. run the model again for this dataset and so on for all specified macros ?

Really appreciate any help.

Best Answer

  • varunm1varunm1 Moderator, MemberPosts:1,207Unicorn
    Solution Accepted
    Hello@asav_yu

    Looks like a macro inside another macro is not possible. Did you try "loop values" operator for your requirement? This will filter data based on attribute value automatically. Please see below XML with titanic dataset.





    <宏/ >


















    <运营商激活= " true " class = " filter_examples”compatibility="9.3.001" expanded="true" height="103" name="Filter Examples" width="90" x="246" y="34">

























    Please inform if you need more information.
    Regards,
    Varun
    https://www.varunmandalapu.com/

    Be Safe. Follow precautions and Maintain Social Distancing

    asav_yu

Answers

  • varunm1varunm1 Moderator, MemberPosts:1,207Unicorn
    Hello@asav_yu

    Once you set the number of iterations to 3 in loop operator, you can write Product Name = Macro%{execution_count}. If possible rename macros to Macro_1, Macro_2, Macro_3 and try Macro_%{execution_count}. I suggested this renaming cause, I am not sure if rapidminer can deal with spaces.

    The said statement will give value Macro_1 for first execution, Macro_2 for the second execution of the loop and soon. I am just guessing your process and proposing this but if you could provide your XML the solution can be more specific.
    Regards,
    Varun
    https://www.varunmandalapu.com/

    Be Safe. Follow precautions and Maintain Social Distancing

    Tghadially
  • asav_yuasav_yu MemberPosts:15Maven
    edited August 2019
    @varunm1This is great. It almost worked but after I apply a filter there are no examples left in the dataset so it can't find the filter value. Product name is polynominal so for Macro_1 I set value "Product name" in quotation marks. I can't figure out why it doesn't work. Here is a simplified version:

    < div > < ?xml version = " 1.0 " encoding = " utf - 8 " ?> <过程s version="9.3.000">
     
       
       
       
     
     
       
       
       
       
       
       
       
         
           
           
           
           
           
             
               
                 
                 
               
             
             
               
               
               
               
                 
               
               
               
             
             
             
             
             
             
           
         
         
         
         
         
       
     

    Tghadially
  • asav_yuasav_yu MemberPosts:15Maven
    @varunm1Thank you. That however will cycle through all possible products for me (100+) but I also would like define which ones exactly. But I will do it another way, I will eliminate the ones i don't wont prior to Loop and then it will just loop through the ones I want.

    Thanks again for your help!
    Tghadially