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
Looping, Branching, and Appending tutorial challenge process
MickMcWilliams
Member Posts: 11 Contributor II
I'm new to RM and am trying to complete the challenge for the Looping, Branching, and Appending tutorial. I'm trying to use the Extract Macro operator to create a macro to hold the value for the number of examples in the smallest Passenger Class group (Second Class N=277) so I can then set the "max size" macro in the Set Macro operator to that value. I'd be VERY grateful if someone could please provide a description of how this can be done. Thanks!
Tagged:
1
Best Answer
-
Thomas_Ott RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 1,761 Unicorn
Sorry been busy. I will try to answer this tomorrow before I travel.
0
Answers
Adding to this request... I believe I'm just one step from figuring out how to do this. I just need to learn how to referance my loop control macro ("loop_value") in a regular expression within a branch operator "expression" parameter. When I use "eval(%{class_size_First})<eval(%{min size})" as the branch operator expression parameter, the process runs without error (though it of course doesn't achieve the objective). I just need to figure out how to replace "eval(%{class_size_First})" with a string that replaced "First" with a reference to the loop_value macro so the first iteration will evaluate to "eval(%{class_size_First})" the second iteration to "eval(%{class_size_Second})" and the third iteration to "eval(%{class_size_Third})". Can anyone tell me the needed syntax to do this? Thanks very much!
It's a bit hard to understand without a process. Would you mind attaching the XML of hte process and a snapshot of the data that's being fed in?
Thanks for you willingness to help me out here, Thomas. I've attached the exported process here. As you'll see, the data used is the Titanic data set that's used in the Looping, Branching, and Appending RapidMiner tutorial. Hopefully this will provide you with what you need to advise on this. Thanks again!
To provide a bit more information... The problem I'm having is with the syntax for the "expression" parameter in the Branch operator that's imbedded in the first Loop Values operator (Loop Values (3)). With the syntax "eval(%{class_size_First})<eval(%{min size})" the operator works but, of course, always refers to the "class_size_First" macro. So, I need a way to get it to replace "First" with the string held in the current "loop_value" macro. Thanks again!
Ok, I have Monday brain so bear with me. It looks like %{class_size_First} won't work because I don't think you can embed a macro %{class_size_%{loop_value}} inside a macro, but I haven't tried. You could try a Filter Examples and filter by %{loop_value} then extract the class size?
Thanks, Thomas! I does appear that and expression cannot call a macro from within another macro (that would be a good capability to add in some upcoming RM upgrade). Per your advice I've used a Filter Examples operator to get around that and the process now correctly finds the Passenger Class category with the lowest N of examples (277). However, I then need to execute a second Loop Values operator to repeatedly invoke the Sample operator to sample the examples in the two larger Passenger Class categories sub-samples down to 277 examples. But the Filter Examples operator that starts the second Loop Values operator's sub-process requires an "exa" input and so can't accept the first Loop Values operator's "out" output as it's input. Is there a way to get around this? I've attached the current version of the process .rmp file for your reference. Thanks again for sticking with me on this!
Just wondering if Thomas, or anyone else, might be willing/able to take a few minutes to help me work out this still unresolved question. I know that working, for example, in Excel, SPSS or R, I could do this same thing with a few minutes relatively simple programming. This is very basic functionality so I expect it must be readily doable in RapidMiner and it's just my relative lack of familiarity with RM that's holding me back. Any help at resolving this question shortly would be very much appreciated. Thanks!
Thanks, Thomas. As it happens, today I was able to get an answer. All that was needed was to insert an Append operator between the two Loop Values operators. That transformed the IOCollectionObject - three examples as produced by the Filter Examples operator in the first Loop Values operator - into a single Examples object that worked as Input for the second Loop Values operator. So, the question is now resolved. Thanks again for your help!
HA! I'm glad I checked this thread again, i was about to get started on this. Awesome, I'm glad you got the solution and I hope you stick around the community and help where you can!
Hi MickMcWilliams,
I am struggling with the same exercise and read this thread but probably I still do not understand something about how RM loops and branches work. Could you please share your solution on this forum, so I can check what I do wrong?
Many thanks!
András
Hi @nocibambi, if you want to get someone's attention, I would suggest you use the '@' symbol followed by their community handle. Like what I did to get your attention.
Quoting from my prior post here (https://community.rapidminer.com/t5/Getting-Started-Forum/Looping-Branching-and-Appending-tutorial-challenge-process/m-p/38899#M597)... "All that was needed was to insert an Append operator between the two Loop Values operators. That transformed the IOCollectionObject - three examples as produced by the Filter Examples operator in the first Loop Values operator - into a single Examples object that worked as Input for the second Loop Values operator. So, the question is now resolved. Thanks again for your help!" Hope this helps you...
Hi All,
@Thomas_Ott, thank you for the tip!
@MickMcWilliams, thanks for the prompt reply. I did read that post and I uses the Append object between the two loops (actually, even before I wrote here). Still, it does not work and I would like to find out what is the problem, so this is why I asked.
hello @nocibambi welcome to the community! I'd recommend posting your XML process here (see https://youtu.be/KkgB5QXWXJ8 and "Read Before Posting" on right when you reply) and attach your dataset. This way we can replicate what you're doing and help you better.
Scott
Hi @sgenzer,
Tried the exercise as well (multiple times) as far as I can tell I followed the tutorial instructions verbatim. However, I keep getting the impossible parameter error. Unlike with previous stages, the inside of the loop process does not provide the guide marks (not sure if by design or an error) as previous comments diverted from the tutorial by adding processes. I also followed a YouTube video with the guy also having some trouble (https://www.youtube.com/watch?v=lhSCmAL0SIs). Tried various input options for the branches which did not change the error.
Thanks,
hello @SHSguy - hmm never seen that video before but I am immediately concerned when it is from 2016 using ver 7.1 and we're in 2018 using ver 8.2. Again, if you post your XML and your dataset, it is much easier to figure out what your issues are.
Scott
This discussion has been very helpful. I am new to RapidMiner and have been facing the same problem as @MickMcWilliams .Thanks to your idea I have been able to solve this issue of having three different 'IOCollectionObject ' and collecting them into one example set. However, a very weird thing keeps happening, I am able to get the desired solution (831 total examples: 277 each from the three passenger class) only when I have a breakpoint inside the first loop > branch(breakpoint after) or in the sublevel below that branch in the 'then' clause. If I don't have that breakpoint the all the examples are included (total 1309). Any idea what might be causing this?.
I have attached the code here (uses the titanic data).Thanks in advance!