1
$\begingroup$

Reading about association rules mining made me somehow confused. I am wondering if this is possible that in a transaction, an item occurs more than once? Considering the following database as a reference:

Transaction id  Items
         t1     {1,4,1}
         t2     {2}
         t3     {1,2,1}
         t4     {2,2}
         t5     {1, 2, 3, 5}
$\endgroup$

1 Answer 1

2
$\begingroup$

I don't think so. Are your item sets destined for the apriori algorithm? The apriori algorithm is based on the presence or absence of items in, say, a shopping basket. It doesn't care about how many items you buy of a particular kind. Alternatively, you could treat different quantities as different items -- so that a six-pack of beer is different from a two-four.

$\endgroup$
10
  • $\begingroup$ Yes, I am referring to apriori algorithm. what do you mean two-four? in addition, how can I tell the algorithm that these 6 items are actually 6 instances of a same type? $\endgroup$
    – lonesome
    Commented Nov 8, 2015 at 4:34
  • $\begingroup$ A two-four is a pack of 24 bottles of beer. It's a Canadian thing. The apriori algorithm uses a big transaction matrix - items in columns, transactions in rows, with a 0 or 1 in each cell. It can't deal with "6 items of the same type", so you would have to clean the data first: "Joe bought beer and chips"; "Jane bought beer and beef". There may be a different algorithm out there that handles multiples. Why do you want to make that distinction? i.e. buying 6 beers is associated with buying 2 large pizzas? But buying 5 beers is associated with .... buying fish sticks. $\endgroup$
    – Placidia
    Commented Nov 8, 2015 at 4:42
  • $\begingroup$ the distinction is due to the fact that , in my mind, buying 6 of a soft drink with something would have more weight compare to buying , say, 2 of the same soft drink with some other item. In other words, it would be more associated to the first item compare to the second item. does that make any sense? I hope it does. $\endgroup$
    – lonesome
    Commented Nov 8, 2015 at 10:55
  • $\begingroup$ If you want to relate quantity to presence - as in the more diapers you buy the more likely you are to buy baby food - then you are into logistic regression models. However these only work for one response at a time. For groceries, the quantity is a function of how many people you are feeding. Lots of hot dogs go with lots of hot dog buns. A large quantity might indicate that someone is holding a party, or in a hardware situation, that the purchaser is a builder. You would need a lot of domain specific knowledge to build a model like that. apriori isn't that smart. $\endgroup$
    – Placidia
    Commented Nov 8, 2015 at 14:28
  • $\begingroup$ Actually my real model is not about shopping list but it can be seen as what I explained. In this case, that apriori is a little dumb for such functionalities, what is your suggestion? I mean in terms of statistic modeling. $\endgroup$
    – lonesome
    Commented Nov 9, 2015 at 1:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.