I’ve always been a fan of Probabilistic Modeling and Soft Computing because this is the only tool by which we can capture the uncertainty that we find in the nature. Among various probabilistic tools Bayes’ Net (BN) is one of my favorites (in full form Bayesian Belief Network). Use of BN is not new to software development. It has been used extensively for Machine Learning. Once Bill Gates said in LA Times that their competitive advantage of their software is due to their expertise in Bayes’ net. You can see how intelligently and beautifully Microsoft Office Assistant suggests you while you work in MS Office Applications. BN is also used for developing smart web applications with Collective Intelligence.
Now let me show you the use of BN for an interesting purpose. Before that I need to briefly explain about BN. BN is a probabilistic modeling technique that shows the causal relationship among various random variables in a particular context and used for answering any probabilistic questions regarding the random variables using Bayes’ theorem. For giving examples let me use hottDhaka.com which is social networking site and focused mainly on various spots in Dhaka city including restaurants, hotels, shopping centers etc. There is a spot in hottDhaka that is Aarong in Gulshan-1 which is a shopping center that provides with traditional handicraft dresses to home decor items to fashion accessories etc. Now what type of user visits that place and likes it is uncertain. But the person who loves to wear new and exceptional dresses with traditional flavor is most likely to visit that place. Moreover who lives in Gulshan-1 has a higher probability to visit that frequently than a person who lives in Dhanmondi. But we can’t say it for sure because user behavior is uncertain. A person for example a husband may not like Aarong and may also not live in Gulshan-1 but may need to visit that place because his wife loves that. So there are lot of uncertainties but the behavior of users maintains a definite probability distribution which we can model. [there are Aarong in many places, in this article I'm particularly talking about Aarong in Gulshan-1]
Let me model this Gulshan-Dress-Aarong scenario by BN. I assume Gulshan (G), Dress (D), and Aarong (A) to be three random variables which can take either of two values True(T) or False(F). G is True means the person under consideration lives in Gulshan-1, D is True means s/he loves wearing new traditional dresses, and A is True means s/he likes to visit Aarong etc. In BN diagram there are nodes for each random variable and the arrow from one node to another indicates causal relationships. Below is the model diagram for this example.

Bayes' Net for Gulshan-Dress-Aarong Scenario
There is an arrow from D to A indicates that D (dress loving) may influence the liking of Aarong. An arrow from G to D means that living in Gulshan-1 may influence in dress loving to visiting Aarong. A direct arrow from G to A means living or non-living in Gulshan-1 may also influence in liking Aarong. Now how much does a random variable influence to another is described by joint probability distribution associated with each node. The probabilities in consideration are,
P(G) = probability of a person living in Gulshan-1
P(~G) = probability of a person not living in Gulshan-1
P(D|G) = probability of a person loves dress given that s/he lives in Gulshan-1
P(D|~G) = probability of a person loves dress given that s/he doesn’t live in Gulshan-1
P(~D|G) = probability of a person doesn’t love dress given that s/he lives in Gulshan-1
P(~D|~G) = probability of a person doesn’t love dress given that s/he doesn’t live in Gulshan-1
P(A|G, D) = probability of a person likes Aarong given that s/he lives in Gulshan-1 and loves dress
P(A|G, ~D) = probability of a person likes Aarong given that s/he lives in Gulshan-1 and doesn’t love dress
P(A|~G, D) = probability of a person likes Aarong given that s/he doesn’t live in Gulshan-1 and loves dress
P(A|~G, ~D) = probability of a person likes Aarong given that s/he doesn’t live in Gulshan-1 and doesn’t love dress
etc.

Probabilities Associated with Nodes
The number of probability terms increases exponentially with the number of random variables and probability calculation becomes difficult when the network size gets large. Problem of BN calculation is NP-Hard. But the good news is there have already some efficient algorithms been developed in the literature for BN calculations.
The above BN can help us finding the answers to queries like,
- What is the probability that a person likes Aarong given that s/he doesn’t live in Gulshan-1 but loves new dresses?
- What is the probability that we find a person who likes Aarong but doesn’t like dresses lives in Gulshan-1?
- What is the probability that a person lives in Gulshan-1 but doesn’t like dresses will like Aarong?
- What is the probability that a person likes dress given that s/he lives in Gulshan-1?
We can find answers to any queries with probability. The above four are only a few for this particular example.
Now let me show you how BN can be used to predict user taste in your website (in this case hottDhaka). For simplicity of calculation let me consider the following simple BN.

Bayes' Net for User Taste Prediction
Suppose by past user activity you found that 50 users like Aarong out of 100 users. Out of these 50 Aarong loving users 40 like new dresses and among these 40 users 28 live in Gulshan-1. Now in the 10 dress non-loving users, 3 live in Gulshan-1. Further of other 50 non-aarong loving users 20 like new dresses. Now we can calculate the following probabilities.
P(A) = probability of Aarong loving users = 50/100 = 0.5
P(~A) = probability of Aarong non-loving users = 1 – P(A) = 1 – 0.5 = 0.5
P(D|A) = probability of dress loving users given that they also like Aarong = 40/50 = 0.8
P(D|~A) = probability of dress loving users given that they don’t like Aarong = 20/50 = 0.4
P(~D|A) = probability of dress non-loving users given that they also like Aarong = 10/50 = 0.2
P(~D|~A) = probability of dress non-loving users given that they don’t like Aarong = 30/50 = 0.6
P(G|D) = probability of users living in Gulshan-1 given that they love dress = 28/40 = 0.7
P(G|~D) = probability of users living in Gulshan-1 given that they don’t love dress = 3/10 = 0.3
P(~G|D) = probability of users not living in Gulshan-1 given that they love dress = 12/40 = 0.3
P(~G|~D) = probability of users not living in Gulshan-1 given that they don’t love dress = 7/10 = 0.7
Now suppose you want to suggest users of hottDhaka about spots when they are finished creating new account and filling up profile.
When any user fills in his/her home location and enters his/her home is in Gulshan-1, the probability that s/he would like new dresses can be calculated in the following way,
P(D) = P(D|A)P(A) + P(D|~A)P(~A) = 0.8×0.5 + 0.4×0.5 = 0.6
P(G) = P(G|D)P(D) + P(G|~D)P(~D) = 0.7×0.6 + 0.3×(1-0.6) = 0.54
P(D|G) = P(G|D)P(D)/P(G) = 0.7×0.6/0.54 = 0.78
So the probability that a user may like new dresses when s/he fills up his/her profile and puts his/her home is in Gulshan-1 is 0.78 or 78%. Now suppose after filling his/her home location he also chooses dress to be his/her choise from a favorites selection list, now you want to calculate the probability that s/he would like Aarong can be done in the following way,
P(A) = 0.5
P(G) = 0.54
P(G|A) = P(G|D)P(D|A) + P(G|~D)P(~D|A) = 0.7×0.8 + 0.3×0.2 = 0.62
P(A|G) = P(G|A)P(A)/P(G) = 0.62×0.5/0.54 = 0.57
Well now the probability of that particular user to like Aarong after filling his/her home location in Gulshan-1 and likes new dresses is 0.57 or 57%. So now based on this probability you can predict that this user may like to visit Aarong and you can then suggest him/her to visit Aarong
This decision process can further be improved by incorporating Fuzzy Inference Engine which will infer about the user taste more intelligently than simple hard limiting threshold. Using Fuzzy Inference Engine the following type of decision can be done using Fuzzy terms like pretty high, good, not bad etc,
IF probability of dress loving is pretty high AND probability of Aarong loving is good THEN suggest user to visit Aarong
Well, I’ve shown a very very and very simple example of application of Bayes’ net. You can’t imagine how beautifully it can be used to enhance user experience and making your web site smarter.