# Is Naive Bayes fine for simple “Suggested products” solution?

I have the opportunity to develop a simple solution to display suggested products on an e-commerce website. My first choice was to use Naive Bayes due to its simplicity of implementation. However, I got to this state:

$P(buys|product.type,product.brand) = \frac{P(buys) * P(product.type|buys) * P(product.brand|buys)}{P(product.type,product.brand)}$

As we compare P(buys) and P(does not buy), the denominator is a constant and we can compare P(buys) and P(does not buy) based on their numerator only.

Determining the probabilities $P(product.type|buys)$ is easy by looking at what the user bought in the past.

However, I'm not sure how I would determine $P(buys)$.

Is it the number of products bought divided by the total products available in the shop? But the number of products available varies with time. Is it fine to take the current number of products, which will be different from the number of products that were available when the user made his last order (an extreme example: the user can have ordered 3 of the 5 products that were available at launch, but now there are 10000 products).

-
 Could you explain how you got to the "this state" displayed equation in your question? It seems to be equivalent to $$P(B|AC) = P(B)P(A|B)P(C|B)$$ which doesn't seem quite right to me. – Dilip Sarwate Nov 28 '11 at 13:48 I edited the question detailing how I got to this expression. Here is what inspired me: en.wikipedia.org/wiki/Naive_Bayes_classifier#Testing – user300811 Nov 28 '11 at 14:00 I would suggest looking at past data to see if it is reasonable to model Product.type and Product.brand as conditionally independent conditioned on a Buy decision. If not, the assumptions of the naive Bayes classifier are not fully met, and whether "Is Naive Bayes fine?" has a Yes or No answer can only be determined by you. – Dilip Sarwate Nov 28 '11 at 14:33 you're right I should check this assumption first, thanks for pointing it out. – user300811 Nov 28 '11 at 14:43

Prior $P(buys)$ is constant for each person. Some people buy more, others buy less, but for any particular person, if you don't know anything about the product he's looking at, the probability of buying is some constant.

This means that, to find the posterior $P(buys|X)$, you don't actually have to know $P(buys)$.

$P(buys|X)$ = $P(X|buys) P(buys) / P(X) = k P(X|buys)$, where $k$ is a constant. To maximize $P(buys|X)$, you thus just maximize $P(X|buys)$.

The much bigger problem is that for any particular individual, you will have too little data to go on. A solution is to somehow group people who you think are similar. You could use their demographics (age, sex, location), but people on your site from the same demographic might be shopping for different things. In addition to demographics, you could also use the product category that they've bought in the past. So, for example, group all 25-35 year old women on the West Coast who've bought a computer-related product in the past into a single "person".

-