{"id":1903,"date":"2019-04-13T12:00:00","date_gmt":"2019-04-13T10:00:00","guid":{"rendered":"https:\/\/kindsonthegenius.com\/blog\/machine-learning-101-rules-of-probability-bayes-theorem\/"},"modified":"2026-07-05T03:22:47","modified_gmt":"2026-07-05T01:22:47","slug":"machine-learning-101-rules-of-probability-bayes-theorem","status":"publish","type":"post","link":"https:\/\/kindsonthegenius.com\/blog\/machine-learning-101-rules-of-probability-bayes-theorem\/","title":{"rendered":"Machine Learning 101 \u2013 Rules of Probability &#038; Bayes\u2019 Theorem"},"content":{"rendered":"<p>We will now consider some of the important rules of probability. Meanwhile we would also understand the meaning of terms along the line. They include:<\/p>\n<ol>\n<li><a href=\"#t1\">Conditional Probability<\/a><\/li>\n<li><a href=\"#t2\">Sum Rule<\/a><\/li>\n<li><a href=\"#t3\">Product Rule<\/a><\/li>\n<li><a href=\"#t4\">Bayes Theorem<\/a><\/li>\n<li><a href=\"#t5\">Summary<\/a><\/li>\n<\/ol>\n<p>Some term you need to know includes <em>Joint Probability<\/em> and <em>Marginal Probability<\/em><\/p>\n<p>Let&#8217;s start with Conditional Probability.<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t1\">1. Conditional Probability<\/strong><\/h4>\n<p>We would use the example of the box of apples and oranges from <a href=\"https:\/\/kindsonthegenius.com\/tempsite\/machine-learning-101-introduction-to-probability-theory\/\">Lecture 8 (Introduction to Probability Theory)<\/a>.\u00a0 And we would illustrate by an example.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-700 aligncenter\" src=\"https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2020\/09\/Boxes-of-oranges-and-apples-300x199.jpg\" alt=\"\" width=\"300\" height=\"199\" \/><\/p>\n<p>Assume that we randomly select a box. Then from this box, we randomly pick a fruit without replacing the first one. If we already know the probability of picking a box to be P(B), then what is the probability P(F) that the fruit is an apple.<\/p>\n<p>In other words, given a known probability, P(B), what is the probability of P(F).<\/p>\n<p>This is written of the form:<\/p>\n<p>P(F | B)<\/p>\n<p>and read as: the conditional probability of F, given B.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t2\">2. The Sum Rule<\/strong><\/h4>\n<p>In this case, we would state the Sum Rule and then explain it. Later, we would apply it to our apple and oranges example.<\/p>\n<p>Note that I&#8217;m using upper and lower case<em> p<\/em> the same.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-711\" src=\"https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2020\/09\/Sum-rule-1-300x79.jpg\" alt=\"Sum rule\" width=\"300\" height=\"79\" \/><\/p>\n<p>We would have written it in terms of the boxes example but it would be clearer we understand the formula.<\/p>\n<p>P(X, Y) is known as the<strong><em> joint probability<\/em> <\/strong>of X and Y. It is read as the probability of X and Y.<\/p>\n<p>Also, P(X) is known as marginal probability of X.<\/p>\n<p>Therefore, the sum rule simply means that we can find the probability of X by summing up all the joint probabilities of X over Y. But you may ask, how do we find the joint probability?<\/p>\n<p>We get it using the product rule!<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t3\">3. The Product Rule<\/strong><\/h4>\n<p>As mentioned, the product rule helps us find joint probability. The product rule states:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-712\" src=\"https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2020\/09\/Product-Rule.jpg\" alt=\"Product Rule\" width=\"292\" height=\"53\" \/><\/p>\n<p>What if we interchange X and Y? The know about the symmetry property which says that the product rule is same as:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-714\" src=\"https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2020\/09\/Symmetry-property-of-product-rule-300x57.jpg\" alt=\"Symmetry property of product rule\" width=\"300\" height=\"57\" \/><\/p>\n<p>Here P(Y, X) is the joint probability of Y and X while P(X | Y) is the conditional probability of X\u00a0 given Y.<\/p>\n<p>Finally, P(X) is the <em><strong>marginal probability<\/strong><\/em> of X (or just the <em>probability of X<\/em>).\u00a0 But you may ask: how do we find conditional probability?<\/p>\n<p>We get it using the Bayes&#8217; Theorem!<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t4\">4. Bayes Theorem<\/strong><\/h4>\n<p>Bayes theorem helps us find conditional probability.\u00a0 It simply derived from the product rule.<\/p>\n<p>If we rewrite the product rule\u00a0 in terms of P(X|Y)\u00a0 we would have:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-713\" src=\"https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2020\/09\/Bayes-Rule-1-300x96.jpg\" alt=\"Bayes Rule 1\" width=\"198\" height=\"64\" \/><\/p>\n<p>Now we can use the symmetry property from the product rule to replace the numerator. The we have:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-715 aligncenter\" src=\"https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2020\/09\/Final-Bayes-Theorem-300x77.jpg\" alt=\"Final Bayes Theorem\" width=\"300\" height=\"77\" \/><\/p>\n<p>This is the legendary Bayes&#8217; theorem!<\/p>\n<p>I would recommend you take some time to get it around your head. Maybe, write it out a number of times. Also see how you can derive it.<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t5\">5. Summary<\/strong><\/h4>\n<p>What have we learnt so far?<\/p>\n<ul>\n<li>First you now understand the terms, conditional probability, marginal probability and joint probability<\/li>\n<li>You now know of the sum rule which helps us find the marginal probability. It states that the marginal probability of X is the sum of joint probabilities of X and Y over Y<\/li>\n<li>You also now know of the product rule which helps us find the joint probability<\/li>\n<li>You also know know of Bayes&#8217; theorem which helps us find the conditional probabilities.<\/li>\n<\/ul>\n<p>In the next class, we would see how we can apply all of these to solve a problem<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We will now consider some of the important rules of probability. Meanwhile we would also understand the meaning of terms along the line. They include: &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"pagelayer_contact_templates":[],"_pagelayer_content":"","footnotes":""},"categories":[16],"tags":[],"class_list":["post-1903","post","type-post","status-publish","format-standard","hentry","category-machine-learning"],"_links":{"self":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/1903","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/comments?post=1903"}],"version-history":[{"count":1,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/1903\/revisions"}],"predecessor-version":[{"id":2071,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/1903\/revisions\/2071"}],"wp:attachment":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/media?parent=1903"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/categories?post=1903"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/tags?post=1903"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}