SNS College of Engineering Department of Computer Science and Engineering Bayes’ Theorem Presented By, S.Yamuna AP/CSE 7/28/2017 Artificial Intelligence 1 Bayes’ Theorem An insurance company divides its clients into two categories: those who are accident prone and those who are not. Statistics show there is a 40% chance an accident prone person will have an accident within 1 year whereas there is a 20% chance non-accident prone people will have an accident within the first year. If 30% of the population is accident prone, what is the probability that a new policyholder has an accident within 1 year? 7/28/2017 Artificial Intelligence 2 Bayes’ Theorem Let A be the event a person is accident prone Let F be the event a person has an accident within 1 year P A F C A AC P AC F C F 7/28/2017 P A F Artificial Intelligence P AC F 3 Bayes’ Theorem Notice we’ve divided up or partitioned the sample space along accident prone and nonaccident prone P A F C A AC P AC F C F P A F 7/28/2017 P AC F Artificial Intelligence 4 Bayes’ Theorem Notice that A F andAC F are mutually exclusive events and that A F AC F F Therefore PF PA F P AC F We need to find P A F and P AC F How? 7/28/2017 Artificial Intelligence 5 Bayes’ Theorem Recall from conditional probability P E F P E |F P F P E |F P F P E F P F E P F |E P E P F |E P E P E F P F E 7/28/2017 Artificial Intelligence 6 Bayes’ Theorem Thus: P A F P F | A P A P AC F P F | AC P AC P(F|AC) = 0.2 since non-accident prone people have a 20% chance of having an accident within 1 year 7/28/2017 P(A) = 0.30 since 30% of population is accident prone P(F|A) = 0.40 since if a person is accident prone, then his chance of having an accident within 1 year is 40% P(AC) = 1- P(A) = 0.70 Artificial Intelligence 7 Bayes’ Theorem Updating our Venn Diagram P A F C A P AC F C AC F P A F P F | AP A P AC F P F | AC P AC Notice again that PF PA F P AC F 7/28/2017 Artificial Intelligence 8 Bayes’ Theorem So the probability of having an accident within 1 year is: C P F P AF P A F P F | AP A P F | AC P AC 0.400.30 0.200.70 0.26 7/28/2017 Artificial Intelligence 9 Bayes’ Theorem Using Tree Diagrams: Accident w/in 1 year P(F|A)=0.40 Accident Prone P(A) = 0.30 No Accident w/in 1 year P(FC|A)=0.60 Not Accident Prone P(AC) = 0.70 Accident w/in 1 year P(F|AC)=0.20 No Accident w/in 1 year P(FC|AC)=0.80 7/28/2017 Artificial Intelligence P A F P A F C P AC F P AC F C 10 Bayes’ Theorem Notice you can have an accident within 1 year by following branch A until F is reached The probability that F is reached via branch A is given by P F | A P A In other words, the probability of being accident prone and having one within 1 year is P A F P F | A P A 7/28/2017 Artificial Intelligence 11 Bayes’ Theorem You can also have an accident within 1 year by following branch AC until F is reached The probability that F is reached via branch AC is given by P F | AC P AC In other words, the probability of NOT being accident prone and having one within 1 year is P AC F P F | AC P AC 7/28/2017 Artificial Intelligence 12 Bayes’ Theorem What would happen if we had partitioned our sample space over more events, say A1 , A2 ,, An, all them mutually exclusive? Venn Diagram A1 A2 ...... An-1 An F (etc.) P A1 F P A2 F Artificial Intelligence P A F 7/28/2017 n1 P An F 13 Bayes’ Theorem P F P A1 F P A2 F P An F For each P Ai F P F | Ai P Ai P F P A1 F P A2 F P An F P F | A1 P A1 P F | A2 P A2 P F | An P An n P F | Ai P Ai i 1 7/28/2017 Artificial Intelligence 14 Bayes’ Theorem Tree Diagram P A1 P A2 P An1 P An 7/28/2017 P F |A1 P F C |A1 P F |A2 P F C |A2 P F | An1 P F C | An1 P F | An P F C | An Artificial Intelligence 15 Bayes’ Theorem Notice that F can be reached via A1 , A2 ,, An branches Multiplying across each branch tells us the probability of the intersection Adding up all these products gives: n P F P F | Ai P Ai i 1 7/28/2017 Artificial Intelligence 16 Bayes’ Theorem Ex: 2 (text tractor example) Suppose there are 3 assembly lines: Red, White, and Blue. Chances of a tractor not starting for each line are 6%, 11%, and 8%. We know 48% are red and 31% are blue. The rest are white. What % don’t start? 7/28/2017 Artificial Intelligence 17 Bayes’ Theorem Soln. R: red W: white B: blue N: not starting P(R) = 0.48 P(W) = 0.21 P(B) = 0.31 P(N | R) = 0.06 P(N | W) = 0.11 P(N | B) = 0.08 7/28/2017 Artificial Intelligence 18 Bayes’ Theorem Soln. P N P N |R P R P N |W P W P N |B P B 0.06 0.48 0.11 0.21 0.08 0.31 0.0767 7/28/2017 Artificial Intelligence 19 Bayes’ Theorem Main theorem: Suppose we know P E |F . We would like to use this information to find P F |E if possible. Discovered by Reverend Thomas Bayes 7/28/2017 Artificial Intelligence 20 Bayes’ Theorem Main theorem: Ex. Suppose B1 and B2 partition a space and A is some event. Use PB1 , PB2 , PA|B1 , and P A|B2 to determine P B1 | A. 7/28/2017 Artificial Intelligence 21 Bayes’ Theorem P B1 A Recall the formulas: P B1 | A P A P B1 A P A B1 P A|B1 P B1 P A P B1 P A|B1 P B2 P A|B2 P B1 A So, P B1 | A P A P A|B1 P B1 P B1 P A|B1 P B2 P A|B2 7/28/2017 Artificial Intelligence 22 Bayes’ Theorem Bayes’ Theorem: P Bk | A P A|Bk P Bk n P A|B P B i 1 7/28/2017 i Artificial Intelligence i 23 Bayes’ Theorem Ex. 4 (text tractor example) 3 assembly lines: Red, White, and Blue. Some tractors don’t start (see Ex. 2). Find prob. of each line producing a non-starting tractor. P(R) = 0.48 P(W) = 0.21 P(B) = 0.31 7/28/2017 P(N | R) = 0.06 P(N | W) = 0.11 P(N | B) = 0.08 Artificial Intelligence 24 Bayes’ Theorem Soln. Find P(R | N), P(W | N), and P(B | N) P(R) = 0.48 P(N | R) = 0.06 P(W) = 0.21 P(N | W) = 0.11 P(B) = 0.31 P(N | B) = 0.08 7/28/2017 Artificial Intelligence 25 Bayes’ Theorem Soln. P R N P R |N P N P N |R P R P N |R P R P N |W P W P N |B P B 0.06 0.48 0.06 0.48 0.11 0.21 0.08 0.31 0.3755 7/28/2017 Artificial Intelligence 26 Bayes’ Theorem Soln. P W |N P N |W P W P N |R P R P N |W P W P N |B P B 0.11 0.21 0.06 0.48 0.11 0.21 0.08 0.31 0.3012 P B |N 0.3233 7/28/2017 Artificial Intelligence 27 Bayes’ Theorem Focus on the Project: We want to find the following probabilities: P S |Y T C and P F |Y T C . To get these, use Bayes’ Theorem 7/28/2017 Artificial Intelligence 28 Bayes’ Theorem Focus on the Project: P S |Y T C P Y T C | S P S P Y T C | S P S P Y T C |F P F P F |Y T C P Y T C |F P F P Y T C | S P S P Y T C |F P F 7/28/2017 Artificial Intelligence 29 Bayes’ Theorem Focus on the Project: P S |Y T C P Y T C | S P S P Y T C | S P S P Y T C |F P F In Excel, we find the probability to be approx. 0.4774 7/28/2017 Artificial Intelligence 30 Bayes’ Theorem Focus on the Project: P Y T C |F P F P F |Y T C P Y T C | S P S P Y T C |F P F In Excel,we find the probability to be approx. 0.5226 7/28/2017 Artificial Intelligence 31 Bayes’ Theorem Focus on the Project: Let Z be the value of a loan work out for a borrower with 7 years, Bachelor’s, Normal… E Z Success Prob. Success Failure Prob. Failure 4,000 ,000 0.4774 250 ,000 0.5226 $2,040 ,000 7/28/2017 Artificial Intelligence 32 Bayes’ Theorem Focus on the Project: Since foreclosure value is $2,100,000 and on average we would receive $2,040,000 from a borrower with John Sanders characteristics, we should foreclose. 7/28/2017 Artificial Intelligence 33 Bayes’ Theorem Focus on the Project: However, there were only 239 records containing 7 years experience. Look at range of value 6, 7, and 8 (1 year more and less) 7/28/2017 Artificial Intelligence 34 Bayes’ Theorem Focus on the Project: Use DCOUNT function with an extra “Years in Business” heading Years In Former Bank Business BR >=6 Education Level State Of Economy Loan Paid Years In Back? Business yes <=8 Same for “no” Added a new column 7/28/2017 Artificial Intelligence 35 Bayes’ Theorem Focus on the Project: From this you get 349 successful and 323 failed records Let Y be a borrower with 6, 7, or 8 years experience 349 PY | S 1470 7/28/2017 and 323 PY |F 1779 Artificial Intelligence 36 Bayes’ Theorem Focus on the Project: P Y T C | S P Y | S P T | S P C | S 0.2374 0.5301 0.5823 0.0733 P Y T C |F P Y |F P T |F P C |F 0.1816 0.5314 0.5222 0.0504 7/28/2017 Artificial Intelligence 37 Bayes’ Theorem Focus on the Project: Use Bayes’ Theorem to get new probabilities P S |Y T C 0.5575 P F |Y T C 0.4425 Z : 6, 7, or 8 years, Bachelor’s, Normal (indicates work out) E Z $2,341 ,000 7/28/2017 Artificial Intelligence 38 Bayes’ Theorem Focus on the Project: We can look at a large range of years. Look at range of value 5, 6, 7, 8, and 9 (2 years more and less) 7/28/2017 Artificial Intelligence 39 Bayes’ Theorem Focus on the Project: Use DCOUNT function with an extra “Years in Business” heading Years In Former Bank Business BR >=5 Education Level State Of Economy Loan Paid Years In Back? Business yes <=9 Same for “no” Added a new column 7/28/2017 Artificial Intelligence 40 Bayes’ Theorem Focus on the Project: From this you get 566 successful and 564 failed records Let Y be a borrower with 5, 6, 7, 8, or 9 years exper. 566 PY "| S 1470 7/28/2017 and 564 PY "|F 1779 Artificial Intelligence 41 Bayes’ Theorem Focus on the Project: P Y T C | S P Y | S P T | S P C | S 0.3850 0.5301 0.5823 0.1189 P Y T C |F P Y |F P T |F P C |F 0.3170 0.5314 0.5222 0.0880 7/28/2017 Artificial Intelligence 42 Bayes’ Theorem Focus on the Project: Use Bayes’ Theorem to get new probabilities P S |Y T C 0.5392 P F |Y T C 0.4608 Z : 5, 6, 7, 8, or 9 years, Bachelor’s, Normal E Z $2,272,000 (indicates work out) 7/28/2017 Artificial Intelligence 43 Bayes’ Theorem Focus on the Project: Since E Z and E Z both indicated a work out while onlyE Z indicated a foreclosure, we will work out a new payment schedule. 7/28/2017 Artificial Intelligence 44
© Copyright 2026 Paperzz