"Dynamically inserting Sections in Report - Branch? [SOLVED]"

vwegertvwegert Member Posts: 10 Contributor II
edited June 2019 in Help
Hello,

I'm rather new to RapidMiner, and I'm currently stuck at a point where I did't really expect to encounter any problems. I'm trying to implement something that is called control level processing in some other environments I use. I don't know whether that's a generally accepted term, though, so I'll describe what I'm trying to achieve briefly.

After some processing, I've got data that looks roughly like this:

KEY1 | KEY2 | DATE       | VALUE
AAAA | aaaa | 2015-01-01 | 10
AAAA | aaaa | 2015-01-02 | 12
AAAA | aaaa | 2015-01-03 |  8
AAAA | bbbb | 2015-01-01 | 20
AAAA | bbbb | 2015-01-02 | 18
AAAA | bbbb | 2015-01-03 | 19
BBBB | cccc | 2015-01-01 | 15
BBBB | cccc | 2015-01-02 | 12
BBBB | cccc | 2015-01-03 | 17
BBBB | aaaa | 2015-01-01 | 12
BBBB | aaaa | 2015-01-02 | 13
BBBB | aaaa | 2015-01-03 |  9
I have already succeeded in dynamically generating a separate graph for each combination of [tt]KEY1[/tt] and [tt]KEY2[/tt] (both polynomials). I don't know whether that's the most efficient way to do so, but here is what I did:
  • Remember the entire ExampleSet
  • Select Attributes to only keep [tt]KEY1[/tt] and [tt]KEY2[/tt]
  • Remove Duplicates, gibing me a list of distinct [tt]KEY1[/tt] and [tt]KEY2[/tt] pairs
  • Using Loop Examples, process that list
  • In the loop sub-workflow, use Extract Macro to determine the current [tt]KEY1[/tt] and [tt]KEY2[/tt]
  • Recall the stored ExampleSet
  • Filter Examples to keep only the entries belonging to the current [tt]KEY1[/tt] and [tt]KEY2[/tt]
  • Report the filtered set to the (previously opened) report
This works so far. Now I want to introduce intermediate headings (sections) because [tt]KEY1[/tt] and [tt]KEY2[/tt] in fact form a hierarchy. I need the report TOC to look like this (for the example data above):

1. AAAA
  1.1 aaaa
  1.2 bbbb
2. BBBB
  2.1 cccc
  2.2 aaaa
The secondary header level isn't a problem, but the primary level is unexpectedly hard. I've tried to store the previous value of [tt]KEY1[/tt] using Set Macro and then use a Branch operator to conditionally apply an Add Section operator and then update the macro, but so far, I haven't been able to get this working. I believe I need to use the condition type expression with a condition value like [tt]KEY1 <> %{prev_key1}[/tt], but all I get is runtime errors. Unfortunately, neither the documentation nor the example process are of much use to me. Am I following the right approach, and how do I get the Branch operator (or any other operator) to do what I need?

Thanks
 Volker

Answers

  • BalazsBaranyBalazsBarany Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert Posts: 955 Unicorn
    Hi,

    try the correct syntax for the condition:
    KEY1 != %{prev_key1}
    Also, you need to quote strings, so it's probably this:
    KEY1 != "%{prev_key1}"
    The expression syntax is for example used in Generate Attributes. In the helper dialog of this operator, you can find the valid functions and syntax elements.
  • vwegertvwegert Member Posts: 10 Contributor II
    Thanks a lot - actually, I was already using [tt]!=[/tt] in the condition, but the quotes were missing. I still haven't grokked where to quote what in RapidMiner, but at least this issue is solved.
  • BalazsBaranyBalazsBarany Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert Posts: 955 Unicorn
    You need to quote strings like you would in an Excel function, or a programming language.

    RapidMiner Macros are not really "variables" in the function context: instead, they are simply inserted as text into the evaluated expression. If your macro points to an attribute name, it shouldn't be quoted. If it points to an actual string value, it must be quoted. If it contains a number, it shouldn't be quoted.

    But you're right, there are places where it's not very intuitive.
Sign In or Register to comment.