2
$\begingroup$

I just made an implementation of P(A|B)/P(¬A|B) for a "people who bought this also bought..." algorithm.

I'm doing it by

P(A|B) = count_users(bought_A_and_B)/count_users(bought_A)
P(¬A|B) = count_users(bought_B_but_not_A)/count_users(did_not_buy_A)

Then dividing the top one by the bottom one I get a score which makes absolute sense, but what kind of correlation am I calculating? What is this method called? Where can I read more about it?

[EDIT] This is not for using in a production environment, it is just some algorithm which appeared out of the blue in an online course I'm taking, I was just wondering where it could come from. Also, when the number of users who bought item B but not item A is zero I just skip the pair until I get more data. The same goes on when the number of users who bought A is zero.

$\endgroup$
3
$\begingroup$

The topic is called Association Rule Learning, which is one of the most basic (and rather old-fashioned) ways to build a recommender system. The most widely known algorithms are called A Priori and FP Growth. Every good book about Data Mining should contain a chapter about it.

However, the formula seems to be wrong.

$P(A|B)$ means Probability of A given B, so

P(A|B)=count_users(bought(A,B)) / count_users(bought_B)

is correct.

Furthermore, the mentioned algorithms do not take into account something like $P(\neg A|B)$, because the fact that a user has not bought A could have multiple meanings

  • user does not like A
  • user does not know that A exists or is sold here
  • user does not bought A although he likes it for one of the thousand seemingly arbitrary motivatiors of human behavior.

because not buying something is an implicit preference. If the user would have stated explicitly that he does not like A (may be in a survey), it is called an explicit preference. In case of implicit negative preferences, the negative preferences are often excluded from the model.

If explicit preferences are given, the overall formula $\frac{P(A|B)}{P(\neg A|B)}$ would make sense and represent the Odds Ratio.

$\endgroup$
  • $\begingroup$ (BTW: I was using the formula as you defined it, I mixed A and B when writing the question. Good you notice!) $\endgroup$ – NotGaeL Oct 11 '13 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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