2
$\begingroup$

I'm trying to measure association in my basket based on transactions. Let's imagine I have 5 products. Then, I calculate the number of client who bought product A and B, A and C, B and C and so on.

Total columns is the number of clients who bought the product.

I calculate penetration rate (or support when we use association rule) = number of client who bought product A and B / number of client (in my example 5)

Then, I calculate kind of confidence = number of client who bought product A and B / number of client who bought product A

Finally, I calculate my lift = confidence / support.

Results are here:

results

  1. Why my lift value are all the same by line?

=> I know why. Because support = p(a) * p(b) and confidence = p(a) * p(b) / p(a) so lift = 1/p(a)

  1. I need to take into account the volume effect because the products highlighted in my analysis are always those that people buy the most, so what techniques do you know for this problem?
$\endgroup$

1 Answer 1

2
$\begingroup$

You want to know how buying B affects buying A, that's the probability that someone has bought A given that they bought B which is written as $P(A|B)$.

$P(A|B)=\frac{P(A \text{ and } B)}{P(B)}$

The probability of someone buying B is computed from your sales data. Suppose you have $N$ customers, then $P(B)=\frac{\text{number buying B}}{N}$

Likewise, the probability of someone buying A and B is $P(A \text{ and } B)=\frac{\text{number buying A and B}}{N}$

Putting those expressions into the first formula gives:

$P(A|B)=\frac{\frac{\text{number buying A and B}}{N}}{\frac{\text{number buying B}}{N}}= \frac{\text{number buying A and B}}{\text{number buying B}}$

Is this the kind of association you were trying to calculate? Perhaps you were looking for a more complicated way to measuring the relationship.

$\endgroup$
2
  • $\begingroup$ Thanks for your answer. Indeed, I would like to know what products tends to be bought together. For the moment, i am looking for a simply way to measure the relationship. That's why I used that. However, the product which are highlight are always the buyest product. How to take into the sample size effect ? $\endgroup$
    – Hola at me
    Commented Jan 4, 2017 at 13:23
  • $\begingroup$ @Holaatme I don't think that the sample size affects the expected result of $P(A|B)$, why do you think that sample size would affect it? $\endgroup$
    – Hugh
    Commented Jan 4, 2017 at 14:46

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.