LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  Splitting data based on Rules

    Employee
    Posted 06-30-2011 14:59

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: mwillett

    Hi there,

    I have about 2.5M records I am working with and 50 (relatively simple) rules to run against each of those records.

    I want to know the only first rule that the record hits based on a sequence of rules I've defined. I know I can do this with 50 split nodes (one for each rule) but is there a more efficient way to do this?

    I've tried multiple output pins on a filter node but one record may hit multiple rules and I only want to know the first rule that each record hits. May be worth noting that all records will hit a rule as rule #50 is, in essence, "everything else go into bucket 50".

    Mike


  • 2.  RE: Splitting data based on Rules

    Employee
    Posted 06-30-2011 15:43

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: mmarinelli

    Mike,

    I've attached a graph which I think addresses your question by using a sequence of if..else statements. The top example simply flags the records with the first rule which each matched; the bottom example does this and also splits the data into multiple streams depending on the match. Please have a look and let me know if this is what you are looking for, or whether I've misinterpreted your question.

    Mark

    PS: I wanted to reply quickly, so I didn't take much time to think about optimizing this approach. If anyone has a more efficient approach, please contribute it.
    Attachments:
    ruleSequenceExample.brg


  • 3.  RE: Splitting data based on Rules

    Employee
    Posted 07-01-2011 08:50

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: rboccuzzi

    Mike, assuming Mark got your answer correct (looks like how I would have interpreted it as well, so hopefully he did), the only "tweak" I would give, in the form of "typing optimization", is changing the BRAINscript on the second node to look more like this (after the if/else if stuff):

    emit *, ruleMatch
    output "rule1" where ruleMatch == 1
    output "rule2" where ruleMatch == 2
    output "rule3" where ruleMatch == 3
    output "other" where ruleMatch == -1

    This will run the same as the graph Mark attached, but might be a bit easier for you to read/type. In this version, the first emit comes before any output statement, so it is a default for all outputs. For the following outputs, you can either say
    output "rule1" {
    where ruleMatch == 1
    }
    or replace it with a one line, since it is a single where statement as
    output "rule1" where ruleMatch == 1


    Cheers
    Rich


  • 4.  RE: Splitting data based on Rules

    Employee
    Posted 07-02-2011 00:44

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: mikewillett

    Great, thanks Mark and Rich,

    Actually, in hindsight, a disturbingly easy answer and one I'm almost embarressed to have asked. Sometimes you can't see the wood for the trees.

    I do like Rich's optimisation though. That's a good short cut to know.

    Mike