Data Mining

Download Free Data Mining Source Code In C/C++, C#, Visual Basic, Visual Basic.NET, Java,
and other programming languages
Welcome to Data Mining Sign in | Join | Help
in Search

Data Mining Source Code Newsletter

Announcing The Data Mining Source Code Newsletter!

Subscribe By Email | Subscribe By RSS Feed

filler for count the presense of value>0 in multiple fields?

Last post 07-15-2008, 20:30 by umar98. 2 replies.
Sort Posts: Previous Next
  •  07-13-2008, 13:57 8137

    filler for count the presense of value>0 in multiple fields?

    Hi dear,

     

    If I have multiple fields like:

    CustID  Items_A_Bought        Items_B_Bought ... Items_Z_Bought

    John    1                                 7                          0

    Jack    0                                0                           1

    Jess    2                                2                           2

     And I want to calculate how many types of items they bought:

    John  2 (A and B)

    Jack 1 (C)

    Jess 3 (A,B, C)

     The way I can think of is to use Filler node to fill where @FIELD>0 with 1, then sum_n(@fields_between(Item_A_Bought,Item_Z_Bought). Is there any other way to do this?

    Thanks,

  •  07-13-2008, 16:17 8140 in reply to 8137

    Re: filler for count the presense of value>0 in multiple fields?

    Attachment: test7.zip

    Your method seems fine.

    Most of my analysis is on a database, so I would solve this data analysis a little differently.  See the attached zipped stream+data, it will pushback the processing as SQL when you are connected to a database (I'm not sure if the functions  "sum_n(@fields_between"  would work as SQL).

    My alternative hardcodes the field names and could be tedious if you have a lot of fields, but a script can be used to loop through all the fields and build the expression dynamically if you have hundreds of fields.

    I also used an aggregate in case you have the same customer on many rows.  You can remove the aggregate node if you want the customer transactions to be separate.

    Cheers

    Tim

     

  •  07-15-2008, 20:30 8153 in reply to 8137

    Re: filler for count the presense of value>0 in multiple fields?

    You can try this:

    count_greater_than(0, @FIELDS_BETWEEN(Item_A_Bought,Item_Z_Bought))

    So.. you didn't need to use Filler node anymore.

     

    Umar

    SPSS Indonesia

Announcing The Data Mining Source Code Newsletter!

Subscribe By Email | Subscribe By RSS Feed