Download presentation
Presentation is loading. Please wait.
Published byLorena O’Connor’ Modified over 8 years ago
1
1 Lecture Notes 16: Bayes’ Theorem and Data Mining Zhangxi Lin ISQS 6347
2
2 Modeling Uncertainty Probability Review Bayes Classifier Value of Information Conditional Probability and Bayes’ Theorem Expected Value of Perfect Information Expected Value of Imperfect Information
3
3 Probability Review P(A|B) = P(A and B) / P(B) “Probability of A given B” Example, there are 40 female students in a class of 100. 10 of them are from some foreign countries. 20 male students are also foreign students. Even A: student from a foreign country Even B: a female student If randomly choosing a female student to present in the class, the probability she is a foreign student: P(A|B) = 10 / 40 = 0.25, or P(A|B) = P (A & B) / P (B) = (10 /100) / (40 / 100) = 0.1 / 0.4 = 0.25 That is, P(A|B) = # of A&B / # of B = (# of A&B / Total) / (# of B / Total) = P(A & B) / P(B)
4
4 Venn Diagrams Female (30) Foreign Student (20) Female foreign student (10) (10) 30+10 = 40 20+10 = 30 Male non-foreign student (40)
5
5 Probability Review Complement Female Foreign student Non Female Non Foreign Student
6
6 Bayes Classifier
7
7 Bayes’ Theorem (From Wikipedia) In probability theory, Bayes' theorem (often called Bayes' Law) relates the conditional and marginal probabilities of two random events. It is often used to compute posterior probabilities given observations. For example, a patient may be observed to have certain symptoms. Bayes' theorem can be used to compute the probability that a proposed diagnosis is correct, given that observation.probability theoryconditional and marginal probabilitiesrandom eventsposterior probabilities As a formal theorem, Bayes' theorem is valid in all interpretations of probability. However, it plays a central role in the debate around the foundations of statistics: frequentist and Bayesian interpretations disagree about the ways in which probabilities should be assigned in applications. Frequentists assign probabilities to random events according to their frequencies of occurrence or to subsets of populations as proportions of the whole, while Bayesians describe probabilities in terms of beliefs and degrees of uncertainty. The articles on Bayesian probability and frequentist probability discuss these debates at greater length.theoreminterpretations of probability foundations of statisticsfrequentistBayesianBayesian probabilityfrequentist probability
8
8 Bayes’ Theorem So: The above formula is referred to as Bayes’ theorem. It is extremely Useful in decision analysis when using information.
9
9 Example of Bayes Theorem Given: A doctor knows that meningitis (M) causes stiff neck (S) 50% of the time Prior probability of any patient having meningitis is 1/50,000 Prior probability of any patient having stiff neck is 1/20 If a patient has stiff neck, what’s the probability he/she has meningitis?
10
10 Bayes Classifiers Consider each attribute and class label as random variables Given a record with attributes (A 1, A 2,…,A n ) Goal is to predict class C (= (c 1, c 2, …, c m )) Specifically, we want to find the value of C that maximizes P(C| A 1, A 2,…,A n ) Can we estimate P(C| A 1, A 2,…,A n ) directly from data?
11
11 Bayes Classifiers Approach: compute the posterior probability P(C | A 1, A 2, …, A n ) for all values of C using the Bayes theorem Choose value of C that maximizes P(C | A 1, A 2, …, A n ) Equivalent to choosing value of C that maximizes P(A 1, A 2, …, A n |C) P(C) How to estimate P(A 1, A 2, …, A n | C )?
12
12 Example C: Evade (Yes, No) A1: Refund (Yes, No) A2: Marital Status (Single, Married, Divorced) A3: Taxable income (60k – 220k) We can obtain P(A1, A2, A3|C), P(A1, A2, A3), and P(C) from the data set Then calculate P(C|A1, A2, A3) for predictions given A1, A2, and A3, while C is unknown.
13
13 Naïve Bayes Classifier Assume independence among attributes A i when class is given: P(A 1, A 2, …, A n |C) = P(A 1 | C j ) P(A 2 | C j )… P(A n | C j ) Can estimate P(A i | C j ) for all A i and C j. New point is classified to C j if P(C j ) P(A i | C j ) is maximal. Note: The above is equivalent to find i such that P(A i | C j ) is maximal, since P(C j ) is identical.
14
14 How to Estimate Probabilities from Data? Class: P(C) = N c /N e.g., P(No) = 7/10, P(Yes) = 3/10 For discrete attributes: P(A i | C k ) = |A ik |/ N c where |A ik | is number of instances having attribute A i and belongs to class C k Examples: P(Status=Married|No) = 4/7 P(Refund=Yes|Yes)=0 k
15
15 *How to Estimate Probabilities from Data? For continuous attributes: Discretize the range into bins one ordinal attribute per bin violates independence assumption Two-way split: (A v) choose only one of the two splits as new attribute Probability density estimation: Assume attribute follows a normal distribution Use data to estimate parameters of distribution (e.g., mean and standard deviation) Once probability distribution is known, can use it to estimate the conditional probability P(A i |c)
16
16 *How to Estimate Probabilities from Data? Normal distribution: One for each (A i,c i ) pair For (Income, Class=No): If Class=No sample mean = 110 sample variance = 2975
17
17 Example of Naïve Bayes Classifier l P(X|Class=No) = P(Refund=No|Class=No) P(Married| Class=No) P(Income=120K| Class=No) = 4/7 4/7 0.0072 = 0.0024 l P(X|Class=Yes) = P(Refund=No| Class=Yes) P(Married| Class=Yes) P(Income=120K| Class=Yes) = 1 0 1.2 10 -9 = 0 Since P(X|No)P(No) > P(X|Yes)P(Yes) Therefore P(No|X) > P(Yes|X) => Class = No Given a Test Record:
18
18 Naïve Bayes Classifier If one of the conditional probability is zero, then the entire expression becomes zero Probability estimation: c: number of classes p: prior probability m: parameter
19
19 *Example of Naïve Bayes Classifier A: attributes M: mammals N: non-mammals P(A|M)P(M) > P(A|N)P(N) => Mammals
20
20 Naïve Bayes (Summary) Robust to isolated noise points Handle missing values by ignoring the instance during probability estimate calculations Robust to irrelevant attributes Independence assumption may not hold for some attributes Use other techniques such as Bayesian Belief Networks (BBN)
21
21 Value of Information When facing uncertain prospects we need information in order to reduce uncertainty Information gathering includes consulting experts, conducting surveys, performing mathematical or statistical analyses, etc.
22
22 Use insurance Pay $100+$2 = $102 Not use insurance Pay $100 Buyer $18 Good Bad - $100 Bad 0.99 0.01 0.99 0.01 Good Expected Value of Perfect Information (EVPI) $20 - $2 Problem: An buyer is to buy something online EMV = $18.8 EMV = $17.8 Seller type Net gain
23
23 Expected Value of Imperfect Information (EVII) We rarely access to perfect information, which is common. Thus we must extend our analysis to deal with imperfect information. Now suppose we can access the online reputation to estimate the risk in trading with a seller. Someone provide their suggestions to you according to their experience. Their predictions are not 100% correct: If the product is actually good, the person’s prediction is 90% correct, whereas the remaining 10% is suggested bad. If the product is actually bad, the person’s prediction is 80% correct, whereas the remaining 20% is suggested good. Although the estimate is not accurate enough, it can be used to improve our decision making: If we predict the risk is high to buy the product online, we purchase insurance
24
24 Decision Tree Buyer Insurance No Ins Insurance No Ins Bad (?) Good (?) Predicted Good Predicted Bad Questions: 1. Given the suggestion What is your decision? 2. What is the probability wrt the decision you made? 3. How do you estimate The accuracy of a prediction? Bad (?) Good (?) Bad (?) Good (?) Bad (?) Good (?) $18 - $100 $20 - $2 $18 $20 - $2 - $100 Extended from the previous online trading question Seller type
25
25 Applying Bayes’ Theorem Let “Good” be even A Let “Bad” be even B Let “Predicted Good” be event G Let “Predicted Bad” be event W According to the previous information, for example by data mining the historical data, we know: P(G|A) = 0.9, P(W|A) = 0.1 P(W|B) = 0.8, P(G|B) = 0.2 P(A) = 0.99, P(B) = 0.01 We want to learn the probability the outcome is good providing the prediction is “good”. i.e. P(A|G) = ? We want to learn the probability the outcome is bad providing the prediction is “bad”. i.e. P(B|W) = ? We may apply Bayes theorem to solve this with imperfect information
26
26 Calculate P(G) and P(W) P(G) = P(G|A)P(A) + P(G|B)P(B) = 0.9 * 0.99 + 0.2 * 0.01 = 0.893 P(W) = P(W|B)P(B) + P(W|A)P(A) = 0.8 * 0.01 + 0.1 * 0.99 = 0.107 = 1 - P(G)
27
27 Applying Bayes’ Theorem We have P(A|G) = P(G|A)P(A) / P(G) = P(G|A)P(A) / [P(G|A)P(A) + P(G|B)P(B)] = P(G|A)P(A) / [P(G|A)P(A) + P(G|B)(1 - P(A))] = 0.9 * 0.99 / [0.9 * 0.99 + 0.2 * 0.01] = 0.9978 > 0.99 P(B|W) = P(W|B)P(B) / P(W) = P(W|B)P(B) / [P(W|B)P(B) + P(W|A)P(A)] = P(W|B)P(B) / [P(W|B)P(B) + P(W|A)(1 - P(B))] = 0.8 * 0.01 / [0.8 * 0.01 + 0.1 * 0.99] = 0.0748 > 0.01 Apparently, data mining provides good information and changes the original probability
28
28 Decision Tree Buyer Insurance No Ins Insurance No Ins Bad (0.0022) Good (0.9978) Predicted Good P(G) = 0.893 Predicted Bad P(W) = 0.107 Bad (0.0748) Good (0.9252) Bad (0.0748) Good (0.9252) Bad (0.0022) Good (0.9978) $18 - $100 $20 - $2 $18 $20 - $2 - $100 EMV = $19.87 Your choice EMV = $17.78 EMV = $11.03 EMV = $16.50 Your choice Data mining can significantly improve your decision making accuracy! P(A) = 0.99, P(B) = 0.01 Seller type
29
29 Consequences of a Decision Predicted Good (G) (not to buy insurance) Predicted Bad (W) (need to buy insurance $2) Actual Good (A) a Gain $20 b Net Gain $18 Actual Bad (B) c Lose $100 d Cost $2 P(G|A) = a / (a + b) = 0.9, P(W|A) = b / (a + b) = 0.1 P(W|B) = c / (c + d) = 0.8, P(G|B) = d / (c + d) = 0.2 P(A) = (a + b) / (a + b + c + d) =0.99 P(B) = (c + d) / (a + b + c + d) = 0.01 P(G) = (a + c) / (a + b + c + d) = 0.893 P(W) = (b + d) / (a + b + c + d) = 0.107
30
30 German Bank Credit Decision Computed Good (Action A, B) Computed Bad (Action A, B) Actual Good True Positive 600 ($6, 0) False Negative 100 (0, -$1) Actual Bad False Positive 80 (-$2, -$1) True Negative 220 (-$20, 0) 700 300 680 320 This is a modified version of the German Bank credit decision problem. 1. Assume because of the anti-discrimination regulation there could be a cost in FN depending on the action taken. 2. The bank has two choices of actions: A & B. Each will have different results. 3.Question 1: When the classification model suggests that a specific loan applicant has a probability 0.8 to be GOOD, which action should be taken? 4. Question 2: When the classification model suggests that a specific loan applicant has a probability 0.6 to be GOOD, which action should be taken?
31
31 The Payoffs from Two Actions Computed Good (Action A) Computed Bad (Action A) Actual Good True Positive 600 ($6) False Negative 100 (0) Actual Bad False Positive 100 (-$2) True Negative 200 (-$20) 700 300 700 300 Computed Good (Action B) Computed Bad (Action B) Actual Good True Positive 600 (0) False Negative 100 (-$1) Actual Bad False Positive 100 (-$1) True Negative 200 (0) 700 300 700 300
32
32 Summary There are two decision scenarios In previous classification problems, when predicted target is 1 then take an action, otherwise do nothing. Only the action will make something different. There is a cutoff value for this kind of decision. A risk- aversion person may set a higher level of cutoff value, when the utility function is not linear with regard to the monetary result. The risk-aversion person may opt for earn less without the emotional worry of the risk. In current Bayesian decision problem, when the predicted target is 1 then take action A, otherwise take Action B. Both actions will result in some outcomes.
33
33 Web Page Browsing P0 P2 P4 P3 P1 P5 0.7 0.3 We notice that 1.P(P2|P4P0) may not equal to P(P2|P4P1) 2.There is only one entrance of the web site at P0 3.There is no link from P3 to other pages. Problem: When a browsing user Entered P5 from P2, What is the probability He will proceed to P3? How to solve the problem in general? 1. Assume this is the first Order Markovian chain. 2. Construct a transition probability matrix
34
34 Transition Probabilities P0/HP1P2P3P4P5Exit P0/H P1 P2 P3 P4 P5 Exit P(H,1) P(1,1) P(2,1) P(3,1) P(4,1) P(5,1) 0 P(H,2) P(1,2) P(2,2) P(3,2) P(4,2) P(5,2) 0 P(H,3) P(1,3) P(2,3) P(3,3) P(4,3) P(5,3) 0 P(H,4) P(1,4) P(2,4) P(3,4) P(4,4) P(5,4) 0 P(H,5) P(1,5) P(2,5) P(3,5) P(4,5) P(5,5) 0 P(H,E) P(1,E) P(2,E) P(3,E) P(4,E) P(5,E) 0 P(H,H) P(1,H) P(2,H) P(3,H) P(4,H) P(5,H) 0 P(K,L)=Probability of traveling FROM K TO L
35
35 Demonstration Dataset: Commrex web log data Data Exploration Link analysis The links among nodes Calculate the transition matrix The Bayesian network model for the web log data Reference: David Heckerman, “A Tutorial on Learning With Bayesian Networks,” March 1995 (Revised November 1996), Technical Report, MSR-TR-95- 06\\BASRV1\ISQS6347\tr-95-06.pdf
36
36 Readings SPB, Chapter 3 RG, Chapter 10
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.