Reuse results of loop while removing attributes

qwertz2qwertz2 MemberPosts:49Guru
edited November 2018 inHelp

Dear all,

Here is a feature proposal I would like to discuss with you: I just came across a process where I wanted to remove attributes within a loop. This could be done using "loop attributes" and "select attributes" as its nested operator.

However, I discovered that the loop will be carried out as many times as attributes were in the set at the beginning of the loop. In my case I remove attributes while looping and reuse the result. But still the loop goes over attributes which aren't there anymore after removal.

Feature proposal: Have the option to adapt loop iterations to existent attributes only when reuse of result is activated.

This sample code removes att2 in the first loop. However, in the console is shown that there are still three iterations for att1, att2, att3.










< parameter key="number_examples" value="25"/>
< parameter key="number_of_attributes" value="3"/>


< parameter key="reuse_results" value="true"/>

<操作符= " true " class = " select_attribute激活s" compatibility="7.5.001" expanded="true" height="82" name="Select Attributes" width="90" x="45" y="34">
< parameter key="attribute_filter_type" value="regular_expression"/>
< parameter key="regular_expression" value="att2.*"/>
< parameter key="except_regular_expression" value="%{loop_attribute}"/>
< parameter key="invert_selection" value="true"/>


< parameter key="log_value" value="%{loop_attribute}"/>


















Cheers

Sachs

Best Answer

  • 艾丁_Klapic艾丁_Klapic Moderator, Employee, RMResearcher, MemberPosts:299RM Data Scientist
    Solution Accepted

    嗨,萨克斯,

    challenge accepted:)

    I added a few Operators to your process and hope the result fits your needs.

    The macro %{a} represents the actual number of executions this Operator has.

    Best,

    艾丁










    < parameter key="number_examples" value="25"/>
    < parameter key="number_of_attributes" value="3"/>

    <运营商激活= " true " class = "系列:窗口" compatibility="7.4.000" expanded="true" height="82" name="Windowing" width="90" x="246" y="34">
    < parameter key="window_size" value="5"/>



    < parameter key="reuse_results" value="true"/>



    < parameter key="expression" value="cut(%{loop_attribute},0,index(%{loop_attribute},"-"))"/>


    <操作符= " true " class = " select_attribute激活s" compatibility="7.5.001" expanded="true" height="82" name="Select Attributes" width="90" x="179" y="34">
    < parameter key="attribute_filter_type" value="regular_expression"/>
    < parameter key="regular_expression" value="%{expression}.*"/>
    < parameter key="use_except_expression" value="true"/>
    < parameter key="except_regular_expression" value="%{loop_attribute}"/>
    < parameter key="invert_selection" value="true"/>

    <操作符= " true " class = " select_attribute激活s" compatibility="7.5.001" expanded="true" height="82" name="Select Attributes (2)" width="90" x="313" y="85">
    < parameter key="attribute_filter_type" value="single"/>
    < parameter key="attribute" value="%{loop_attribute}"/>
    < parameter key="except_regular_expression" value="%{loop_attribute}"/>

    <操作符= " true " class = " select_attribute激活s" compatibility="7.5.001" expanded="true" height="82" name="Select Attributes (3)" width="90" x="447" y="136">
    < parameter key="attribute_filter_type" value="single"/>
    < parameter key="attribute" value="%{loop_attribute}"/>
    < parameter key="except_regular_expression" value="%{loop_attribute}"/>
    < parameter key="invert_selection" value="true"/>


    < parameter key="condition_type" value="expression"/>
    < parameter key="expression" value="%{a}==1"/>


    < parameter key="name" value="dataset"/>








    < parameter key="name" value="dataset"/>


    < parameter key="join_type" value="left"/>



    < parameter key="name" value="dataset"/>






















    < parameter key="name" value="dataset"/>

    <操作符= " true " class = " select_attribute激活s" compatibility="7.5.001" expanded="true" height="82" name="Select Attributes (4)" width="90" x="514" y="136">
    < parameter key="attribute_filter_type" value="single"/>
    < parameter key="attribute" value="id"/>
    < parameter key="except_regular_expression" value="%{loop_attribute}"/>
    < parameter key="invert_selection" value="true"/>
    < parameter key="include_special_attributes" value="true"/>












Answers

  • qwertz2qwertz2 MemberPosts:49Guru

    For those of you who want to know more on the background / use case:

    Appearingly a simple question but in detail this one drove me mad: I am looking for a regular expression which takes a string out of a macro (e.g. "att1-a") as a reverence value.

    All attribute names shall be selected that have the same prefix before the "-" (--> prefix = "att1") but NOT if the complete reverence value is identical to the attribute's name.


    att1-a --> no match because list entry identical to reference
    att1-b --> match because prefix is the same
    att1-c --> match because prefix is the same
    att2-a --> no match because prefix is different
    att2-b --> no match because prefix is different
    att2-c --> no match because prefix is different

    I came close to the desired result but in the end the looping over already removed attributes lead to an empty set in the end.










    < parameter key="number_examples" value="25"/>
    < parameter key="number_of_attributes" value="3"/>

    <运营商激活= " true " class = "系列:窗口" compatibility="7.4.000" expanded="true" height="82" name="Windowing" width="90" x="179" y="34">
    < parameter key="window_size" value="5"/>


    < parameter key="reuse_results" value="true"/>



    < parameter key="expression" value="cut(%{loop_attribute},0,index(%{loop_attribute},"-"))"/>


    <操作符= " true " class = " select_attribute激活s" compatibility="7.5.001" expanded="true" height="82" name="Select Attributes" width="90" x="179" y="34">
    < parameter key="attribute_filter_type" value="regular_expression"/>
    < parameter key="regular_expression" value="%{expression}.*"/>
    < parameter key="use_except_expression" value="true"/>
    < parameter key="except_regular_expression" value="%{loop_attribute}"/>
    < parameter key="invert_selection" value="true"/>



















  • Thomas_OttThomas_Ott RapidMiner Certified Analyst, RapidMiner Certified Expert, MemberPosts:1,761Unicorn

    Thanks for the idea! I've passed this onto the Developers!

  • qwertz2qwertz2 MemberPosts:49Guru

    Hi Edin,

    That's a pretty impressive piece of code! Congratulations!

    Best regards

    Sachs

Sign InorRegisterto comment.