Results 1 to 8 of 8

Thread: summing all numfields without defining variables with number of numfields

  1. #1

    Default summing all numfields without defining variables with number of numfields

    Hi There

    May be you can find a better way of summing all numeric fields without defining variables with number of numeric fields and emittin each

    I have tried many but could not done so far

    Kind Regards,

  2. #2
    Contributor
    Join Date
    Feb 2009
    Location
    Chicago
    Posts
    194

    Default

    Hi Kursattaskin,

    Have you tried using a histogram. That would do a nice job of defining a count or a sum of a field(s).
    Also, on another note, and I know you don't want to define variables for each, but you can use an aggregate node and using the group by as 1. This you would then define variables for each and do respective sum, count, groupMin and groupMax Values.

    Regards

    Wayne

  3. #3

    Default

    Hi xathras

    Thank you for your comment. Actually I am not asking counting or summing all fields on their unique occurances. I am looking for an easy way (not defining variable for all of the field, assuma there are 100 numeric fields) of summarizing on a key field (groupby like customer number) all numeric fields not histogram of each one.

    Hope I could explain what I tried to do.

    I am not so familier with BrainScript language, but I tried some loop functionality, however, I could not generate variable for each numeric field and output all of them one by one.

    Kind Regards,

  4. #4

    Default

    Hello everyone

    I did what I asked for using R Node, I am trying to do inside BrainScript but until now I could not
    I also attached a small small library that I developed for Audit Analytics, there are 4 nodes, summarize (like ACL Command), Simple profile, Duplicate SSSS (same-same-same-same and combinations) and unique record number, I guess there are better and more easy way to do those but I am very very new to LavaStorm.

    I hope you come with advice and some contribution so that we can make it better

    Kind Regards,
    Kursat Taskin, Istanbul
    Attached Files Attached Files

  5. #5
    Contributor
    Join Date
    Dec 2006
    Location
    Boston
    Posts
    485

    Default

    Kursat Taskin, nice job with the R node; I'm glad you found a way.

    A couple of comments, please take these as coaching and encouragement, as I mean no criticism.

    First, for the summerize node, I looked at your code in the library, and it is pretty good. I'm not sure you know, but there is a variable execCount which is set for each iteration of the BRAINscript. In your first Agg, you don't need to emit
    1 as KayitNo; rather on the second Agg (or even a filter, really, since you aren't agging at all), you could "emit execCount as RecNo_URN" to get that unique numbering per row. Otherwise, it looks pretty good.

    I noticed for your solution, you need to list the numeric fields you wish to aggregate. I think currently, in order to do it without listing the fields, you would need to use some language that can do the type inspection and only aggregate the numeric fields (and modify it's metadata dynamically). This can't currently be done easily in BRAINscript, it should be possible in R (I don't know R enough to propose a specific solution), and certainly you could do it in Python and Java nodes if you wish. Given your current solution, I also wanted to show you one that might be good enough for you as well, since it also does need the fields listed out.

    Take an "Agg Ex" node, and place the SumBy fields in the GroupBy parameter. Then modify the script parameter, add a line like this:
    emit value = groupSum('value')
    for each numeric field you wish to aggregate.

    It isn't as simple as just listing the fields as you can do in your node, but is fairly straightforward. I just wanted to offer it up as another alternative, and help show you how things could be done in BRAINscript.

    Cheers
    Rich


  6. #6

    Default

    Hi Rich

    Thank you for your addition to the subject. I know there is execCount, It will shorten the process, R node is good for such calculations, but isn't there a simple way of doing this with BrainScript? I as discovered, we can not define the number of output fields using while loop or similar. it is static, if it was possible then we can put the sum function inside a while loop and set counter limet to number of numeric fields or selected fields.

    Regards,
    Kursat

  7. #7
    Contributor
    Join Date
    Dec 2006
    Location
    Boston
    Posts
    485

    Default

    You are correct, a while loop can't dynamically configure the output fields. Currently, in BRAINscript, the metadata is configured through the emit statements, and so can't easily be configured dynamically.

    Because of that, currently, the best way is to do it in BRAINscript is in the above post, using groupSum, which requires a line per field. There is an enhancement request, PR4264, that might help this in the future, but that currently isn't scheduled for any release.

    Cheers
    Rich

  8. #8

    Default

    Hi Rich
    I will use groupSum, hope there will be enhancement to configure dynamic outputs.

    Kind Regards,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •