{"id":461,"date":"2013-07-11T14:02:02","date_gmt":"2013-07-11T18:02:02","guid":{"rendered":"http:\/\/www.lichun.cc\/blog\/?p=461"},"modified":"2013-07-14T14:47:31","modified_gmt":"2013-07-14T18:47:31","slug":"understand-bayes-theorem-prior-likelihood-posterior-evidence","status":"publish","type":"post","link":"https:\/\/www.lichun.cc\/blog\/2013\/07\/understand-bayes-theorem-prior-likelihood-posterior-evidence\/","title":{"rendered":"Understand Bayes Theorem (prior\/likelihood\/posterior\/evidence)"},"content":{"rendered":"<p><a href=\"http:\/\/en.wikipedia.org\/wiki\/Bayes'_theorem\" target=\"_blank\">Bayes Theorem<\/a> is a very common and fundamental theorem used in Data mining and Machine learning. Its formula is pretty simple:<\/p>\n<pre>\r\nP(X|Y) = ( P(Y|X) * P(X) ) \/ P(Y), which is Posterior = ( Likelihood * Prior ) \/  Evidence\r\n<\/pre>\n<p>So I was wondering why they are called correspondingly like that.<\/p>\n<p>Let&#8217;s use an example to find out their meanings.<\/p>\n<p><!--more--><\/p>\n<h2>Example<\/h2>\n<p>Suppose we have 100 movies and 50 books.<br \/>\nThere are 3 different movie types: Action, Sci-fi, Romance,<br \/>\n2 different book types: Sci-fi, Romance <\/p>\n<pre>\r\n20 of those 100 movies are Action.\r\n30 are Sci-fi\r\n50 are Romance.\r\n\r\n15 of those 50 books are Sci-fi\r\n35 are Romance\r\n<\/pre>\n<p>So given a unclassified object,<\/p>\n<pre>\r\nThe probability that it's a movie is 100\/150, 50\/150 for book.\r\nThe probability that it's a Sci-fi type is 45\/150, 20\/150 for Action and 85\/150 for Romance.\r\n<\/pre>\n<pre>\r\nIf we already know it's a movie, then the probability that it's an action movie is 20\/100, 30\/100 for Sci-fi and 50\/100 for Romance.\r\nIf we already know it's a book, then that probability that it's an Sci-fi book is 15\/50, 35\/50 for Romance.\r\n<\/pre>\n<p>Right now, we want to know that given an object which has type Sci-fi, what the probability is if it&#8217;s a movie?<\/p>\n<p>Using Bayes theorem, we know that the formula is:<\/p>\n<pre>\r\nP(movie|Sci-fi) = P(Sci-fi| Movie) * P(Movie) \/ P(Sci-fi)\r\n<\/pre>\n<p>Here, P(movie|Sci-fi) is called <b>Posterior<\/b>,<br \/>\nP(Sci-fi|Movie) is <b>Likelihood<\/b>,<br \/>\nP(movie) is <b>Prior<\/b>,<br \/>\nP(Sci-fi) is <b>Evidence<\/b>.<\/p>\n<p>Now let&#8217;s see why they are called like that.<\/p>\n<p><b>Prior<\/b>: <b>Before<\/b> we <b>observe<\/b> it&#8217;s a Sci-fi type, the object is completely unknown to us. Our goal is to find out the possibility that it&#8217;s a movie, we actually have the data <b>prior(or before)<\/b> our <b>observation<\/b>, which is the possibility that it&#8217;s a movie if it&#8217;s a completely unknown object: <b>P(movie)<\/b>.<\/p>\n<p><b>Posterior<\/b>: <b>After<\/b> we <b>observed<\/b> it&#8217;s a Sci-fi type, we know something about the object. Because it&#8217;s <b>post(or after)<\/b> the <b>observation<\/b>, we call it <b>posterior<\/b>: P(movie|Sci-fi).<\/p>\n<p><b>Evidence<\/b>: Because we&#8217;ve already known it&#8217;s a Sci-fi type, what has happened is happened. We <b>witness<\/b> it&#8217;s appearance, so to us, it&#8217;s an <b>evidence<\/b>, and the chance we get this evidence is <b>P(Sci-fi)<\/b>.<\/p>\n<p><b>Likelihood<\/b>: The dictionary meaning of this word is chance or probability that one thing will happen. Here it means when it&#8217;s a movie, what the chance will be if it is also a Sci-fi type. This term is very important in Machine Learning.<\/p>\n<p>So why those probabilities are named like that, the <b>observation time<\/b> is a very important reason.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Bayes Theorem is a very common and fundamental theorem used in Data mining and Machine learning. Its formula is pretty simple: P(X|Y) = ( P(Y|X) * P(X) ) \/ P(Y), which is Posterior = ( Likelihood * Prior ) \/ Evidence So I was wondering why they are called correspondingly like that. Let&#8217;s use an [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[67],"tags":[69,70],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2s9sh-7r","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.lichun.cc\/blog\/wp-json\/wp\/v2\/posts\/461"}],"collection":[{"href":"https:\/\/www.lichun.cc\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lichun.cc\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lichun.cc\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lichun.cc\/blog\/wp-json\/wp\/v2\/comments?post=461"}],"version-history":[{"count":26,"href":"https:\/\/www.lichun.cc\/blog\/wp-json\/wp\/v2\/posts\/461\/revisions"}],"predecessor-version":[{"id":489,"href":"https:\/\/www.lichun.cc\/blog\/wp-json\/wp\/v2\/posts\/461\/revisions\/489"}],"wp:attachment":[{"href":"https:\/\/www.lichun.cc\/blog\/wp-json\/wp\/v2\/media?parent=461"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lichun.cc\/blog\/wp-json\/wp\/v2\/categories?post=461"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lichun.cc\/blog\/wp-json\/wp\/v2\/tags?post=461"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}