{"id":5579,"date":"2023-07-13T16:13:58","date_gmt":"2023-07-13T08:13:58","guid":{"rendered":"https:\/\/fanyuzhao.com\/?p=5579"},"modified":"2023-07-14T08:45:37","modified_gmt":"2023-07-14T00:45:37","slug":"sigmoid-function","status":"publish","type":"post","link":"https:\/\/fanyuzhao.com\/?p=5579","title":{"rendered":"Sigmoid &#038; Logistic"},"content":{"rendered":"\n<p>Sigmoid function is largely used for the binary classification, in either machine learning algorithm or econometrics.<\/p>\n\n\n\n<p>Why the Sigmoid Function shapes in this form?<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Firstly, let&#8217;s introduce the <strong><em>odds<\/em><\/strong>.<\/h3>\n\n\n\n<p><strong>Odds<\/strong> provide a measure of the likelihood of a particular outcome. They are calculated as the ratio of the number of outcomes that produce that outcome to the number that do not.<\/p>\n\n\n\n<p>Odds also have a simple relation with probability: the odds of an outcome are the ratio of the probability that the outcome occurs to the probability that the outcome does not occur. In mathematical terms, <strong><em>p<\/em><\/strong> is the probability of the outcome, and <strong><em>1-p<\/em><\/strong> is the probability of not occurring.<\/p>\n\n\n\n<p>$$ odds = \\frac{p}{1-p} $$<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Odd and Probability<\/h4>\n\n\n\n<p>Let&#8217;s find some insights behind the probability and the odd. Probability links with the outcomes in that for each outcomes, the probability give its specific corresponding probability. <span class=\"katex math inline\">Pr(Y)<\/span>, where <span class=\"katex math inline\">Y<\/span> is the outcome, and <span class=\"katex math inline\">Pr(\\cdot)<\/span> is the probability density function that project outcomes to it&#8217;s prob.<\/p>\n\n\n\n<p>What about the odds? Odds is more like a ratio that is calculated by the probability as the formula says.<\/p>\n\n\n\n<p><strong>Implication<\/strong>: Compared to the probability, odds provide more about how the binary classification <strong>is balanced or not<\/strong>, but the probability distribution.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Example<\/h4>\n\n\n\n<p>Rolling a six-side die. The probability of rolling 6 is <span class=\"katex math inline\">1\/6<\/span>, but the odd is $1\/5.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Formula<\/h4>\n\n\n\n<p>$$ odd = \\frac{Pr(Y)}{1-Pr(Y)} $$<\/p>\n\n\n\n<p>, where <span class=\"katex math inline\">Y<\/span> is the outcomes.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Logit<\/h3>\n\n\n\n<p>As the probability <span class=\"katex math inline\">Pr(Y)<\/span> is always between <span class=\"katex math inline\">[0,1]<\/span>, the odds must be non-negative, <span class=\"katex math inline\">odd \\in [0,\\infty]<\/span>. We may want to apply a monotonic transformation to re-gauge that range of <strong>odds<\/strong>. We will apply on the logarithm.<\/p>\n\n\n\n<p>$$ Sigmoid\/Logistic := log(odds) =log\\bigg( \\frac{Pr(Y)}{1-Pr(Y)} \\bigg) $$<\/p>\n\n\n\n<p>We then get the Sigmoid function.<\/p>\n\n\n\n<p>As the transformation we apply on is monotonic, the Sigmoid function remains the similar properties as the odd. The Sigmoid function keeps the similar implication, representing the balance of the binary outcomes.<\/p>\n\n\n\n<p>Then, we bridge <span class=\"katex math inline\">Y = f(X)<\/span>, the outcome <span class=\"katex math inline\">Y<\/span> is a function of events <span class=\"katex math inline\">X<\/span>. Here, we assume a linear form as <span class=\"katex math inline\">Y = X\\beta<\/span>. The sigmoid function would then become a function of <span class=\"katex math inline\">X<\/span>.<\/p>\n\n\n\n<p>$$g(X) = log\\bigg( \\frac{Pr(X\\beta)}{1-Pr(X\\beta)} \\bigg) $$<\/p>\n\n\n\n<p>$$ e^g = \\frac{p}{1-p} $$<\/p>\n\n\n\n<p>$$ p = \\frac{e^g}{e^g+1}=\\frac{1}{1+e^{-g}}$$<\/p>\n\n\n\n<p>$$ p = \\frac{1}{1+e^{-X\\beta}}$$<\/p>\n\n\n\n<p>We finally get out logistic sigmoid function as above.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sigmoid function is largely used for the binary classification, in either machine learning algorithm or econometrics. Why the Sigmoid Function shapes in this form? Firstly, let&#8217;s introduce the odds. Odds provide a measure of the likelihood of a particular outcome. They are calculated as the ratio of the number of outcomes that produce that outcome &hellip; <a href=\"https:\/\/fanyuzhao.com\/?p=5579\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Sigmoid &#038; Logistic<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,8,18,26],"tags":[],"_links":{"self":[{"href":"https:\/\/fanyuzhao.com\/index.php?rest_route=\/wp\/v2\/posts\/5579"}],"collection":[{"href":"https:\/\/fanyuzhao.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fanyuzhao.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fanyuzhao.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fanyuzhao.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5579"}],"version-history":[{"count":11,"href":"https:\/\/fanyuzhao.com\/index.php?rest_route=\/wp\/v2\/posts\/5579\/revisions"}],"predecessor-version":[{"id":5590,"href":"https:\/\/fanyuzhao.com\/index.php?rest_route=\/wp\/v2\/posts\/5579\/revisions\/5590"}],"wp:attachment":[{"href":"https:\/\/fanyuzhao.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5579"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fanyuzhao.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5579"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fanyuzhao.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5579"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}