{"id":176,"date":"2018-01-21T11:54:00","date_gmt":"2018-01-21T10:54:00","guid":{"rendered":"https:\/\/kindsonthegenius.com\/blog\/2018\/01\/21\/how-to-reduce-expected-loss-in-classification-machine-learning\/"},"modified":"2020-08-22T09:22:48","modified_gmt":"2020-08-22T07:22:48","slug":"how-to-reduce-expected-loss-in-classification-machine-learning","status":"publish","type":"post","link":"https:\/\/kindsonthegenius.com\/blog\/how-to-reduce-expected-loss-in-classification-machine-learning\/","title":{"rendered":"How to Reduce Expected Loss in Classification (Machine Learning)"},"content":{"rendered":"<div style=\"color: #555555; font-size: 18px; line-height: 30px; text-align: justify;\">\n<div style=\"font-family: 'segoe ui';\">This lessons explains in simple terms how to minimize expected loss during classification.<br \/>Remember that when an input variable is classified wrongly, a loss is incurred. However, this loss can be large or can be minimal<\/p>\n<div style=\"clear: both; text-align: center;\"><a href=\"https:\/\/3.bp.blogspot.com\/-vZxc5id31a0\/WmR_IrONaII\/AAAAAAAAA3w\/lGFDBt-Up1c8pre45JKuyykQhQSskE1-ACLcBGAs\/s1600\/Reducing%2BExpected%2BLoss%2528thumbnail%2529.jpg\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" loading=\"lazy\" border=\"0\" data-original-height=\"348\" data-original-width=\"728\" height=\"152\" src=\"https:\/\/3.bp.blogspot.com\/-vZxc5id31a0\/WmR_IrONaII\/AAAAAAAAA3w\/lGFDBt-Up1c8pre45JKuyykQhQSskE1-ACLcBGAs\/s320\/Reducing%2BExpected%2BLoss%2528thumbnail%2529.jpg\" width=\"320\" \/><\/a><\/div>\n<p><span style=\"font-size: large;\"><span style=\"color: #45818e;\"><b>Example of Cancer<\/b><\/span><\/span><br \/><span style=\"color: #990000;\"><b>Scenario 1<\/b><\/span>: A patient that does not have cancer is misclassified as having cancer<br \/><b><span style=\"color: #134f5c;\">Scenario 2<\/span><\/b>: A patient that has cancer is misclassified as not having cancer.<\/p>\n<p>For these two misclassification scenarios, we can see that the loss incurred by the second scenario can be enormous, which may actually be death of the patient.<\/p>\n<p>So the objective is to reduce such misclassifications that would result in much loss. That means reducing the expected loss<\/p>\n<p><span style=\"color: #45818e;\"><span style=\"font-size: large;\"><span style=\"color: #134f5c;\"><b>Formalism<\/b><\/span><\/span><\/span><br \/>We can formalize the discussion by introducing a<span style=\"color: #660000;\"><i> loss function<\/i><\/span> also known as <span style=\"color: #660000;\"><i>cost function.<\/i><\/span> The <span style=\"color: #660000;\"><i>loss function<\/i><\/span> is a single overall measure of the&nbsp; loss incurred in taking any of the available decisions.<\/p>\n<p>The goal is to minimize this total loss incurred.<\/p>\n<p><span style=\"font-size: large;\"><span style=\"color: #45818e;\"><b>The Loss Matrix<\/b><\/span><\/span><br \/>The Loss Matrix is a table showing the decision that was taken relative to the true class. This is shown in Figure 1:<\/p>\n<table align=\"center\" cellpadding=\"0\" cellspacing=\"0\" style=\"margin-left: auto; margin-right: auto; text-align: center;\">\n<tbody>\n<tr>\n<td style=\"text-align: center;\"><a href=\"https:\/\/4.bp.blogspot.com\/-PtsWEmWqNUM\/WmR41G_9AeI\/AAAAAAAAA3Y\/Ic2yjXEsP1wvUkcQFSpRBmdNUuAOeH5MACLcBGAs\/s1600\/Loss%2BMatrix.JPG\" style=\"margin-left: auto; margin-right: auto;\"><img decoding=\"async\" loading=\"lazy\" border=\"0\" data-original-height=\"233\" data-original-width=\"382\" height=\"195\" src=\"https:\/\/4.bp.blogspot.com\/-PtsWEmWqNUM\/WmR41G_9AeI\/AAAAAAAAA3Y\/Ic2yjXEsP1wvUkcQFSpRBmdNUuAOeH5MACLcBGAs\/s320\/Loss%2BMatrix.JPG\" width=\"320\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">Figure 1: Loss Matrix for the Cancer Example<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The elements of the&nbsp; loss matrix represents the loss incurred by taking one of the available decision. The rows of the loss matrix represents the true class while the columns of the matrix represents the assignment of class based on our decision<\/p>\n<p>Assuming that for a new value of x, we assign it to class <span style=\"font-family: Times, &quot;Times New Roman&quot;, serif;\"><i>C<sub>j<\/sub><\/i><\/span> whereas the real correct class is <i><span style=\"color: black;\"><span style=\"font-family: Times, &quot;Times New Roman&quot;, serif;\">C<sub>k<\/sub><\/span><\/span><\/i>. It means we have incurred a loss <i><span style=\"font-family: Times, &quot;Times New Roman&quot;, serif;\">L<sub>kj<\/sub><\/span><\/i>, which is the <i><span style=\"color: black;\">k, j<\/span><\/i> element of the loss matrix.<br \/>The average loss function is given by the equation:<\/p>\n<div style=\"clear: both; text-align: center;\"><a href=\"https:\/\/4.bp.blogspot.com\/-lwDOCtfVjno\/WmR9IaDT71I\/AAAAAAAAA3k\/wTDMUZeB-CYabpZSaCW9fFmo0xp5Z5J-ACLcBGAs\/s1600\/Loss%2BFunction.jpg\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" loading=\"lazy\" border=\"0\" data-original-height=\"131\" data-original-width=\"617\" height=\"67\" src=\"https:\/\/4.bp.blogspot.com\/-lwDOCtfVjno\/WmR9IaDT71I\/AAAAAAAAA3k\/wTDMUZeB-CYabpZSaCW9fFmo0xp5Z5J-ACLcBGAs\/s320\/Loss%2BFunction.jpg\" width=\"320\" \/><\/a><\/div>\n<div style=\"clear: both; text-align: center;\"><\/div>\n<p>The best solution is one that minimizes the average loss function. For a given input vector x, our uncertainty in the correct class is expressed through the joint probability distribution <i><span style=\"font-family: Times, &quot;Times New Roman&quot;, serif;\"><span style=\"color: black;\">p(<\/span><\/span><\/i><b><span style=\"font-family: Times, &quot;Times New Roman&quot;, serif;\"><span style=\"color: black;\">x<\/span><\/span><\/b><i><span style=\"font-family: Times, &quot;Times New Roman&quot;, serif;\"><span style=\"color: black;\">, C<sub>k<\/sub>).<\/span><\/span><\/i><\/p>\n<p>As before, we can use the product rule which states that<\/p>\n<div style=\"text-align: center;\"><span style=\"color: black;\"><i><span style=\"font-family: Times, &quot;Times New Roman&quot;, serif;\">p(<\/span><\/i><b><span style=\"font-family: Times, &quot;Times New Roman&quot;, serif;\">x<\/span><\/b><i><span style=\"font-family: Times, &quot;Times New Roman&quot;, serif;\">, C<sub>k<\/sub>) = p(C<sub>k<\/sub> | <\/span><\/i><span style=\"font-family: Times, &quot;Times New Roman&quot;, serif;\"><b>x<\/b><\/span><i><span style=\"font-family: Times, &quot;Times New Roman&quot;, serif;\">)p(x)&nbsp;<\/span><\/i><\/span><\/div>\n<div style=\"text-align: center;\"><\/div>\n<p>to eliminate the common factor p(x). Therefore, the decision rule that minimizes the expected loss is one that assigns x to the class for which the quantity:<\/p>\n<div style=\"clear: both; text-align: center;\"><a href=\"https:\/\/4.bp.blogspot.com\/-tZ3Fcx1edA8\/WmNctEJEbyI\/AAAAAAAAA1k\/twMCRwtVlDYhqUDidtP2yJ5STTWWC3qhwCLcBGAs\/s1600\/Expected-Loss%2BFunction%2B2.png\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" loading=\"lazy\" border=\"0\" data-original-height=\"126\" data-original-width=\"414\" height=\"60\" src=\"https:\/\/4.bp.blogspot.com\/-tZ3Fcx1edA8\/WmNctEJEbyI\/AAAAAAAAA1k\/twMCRwtVlDYhqUDidtP2yJ5STTWWC3qhwCLcBGAs\/s200\/Expected-Loss%2BFunction%2B2.png\" width=\"200\" \/><\/a><\/div>\n<p>is minimum.<br \/>This can be found once we know the posterior class probabilities <span style=\"font-family: Times, &quot;Times New Roman&quot;, serif;\"><i><span style=\"color: black;\">p(C<sub>k<\/sub> | <\/span><\/i><b><span style=\"color: black;\">x<\/span><\/b><i><span style=\"color: black;\">)<\/span><\/i><\/span><\/p>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This lessons explains in simple terms how to minimize expected loss during classification.Remember that when an input variable is classified wrongly, a loss is incurred. &hellip; <\/p>\n","protected":false},"author":2,"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},"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/176"}],"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\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/comments?post=176"}],"version-history":[{"count":1,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/176\/revisions"}],"predecessor-version":[{"id":1441,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/176\/revisions\/1441"}],"wp:attachment":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/media?parent=176"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/categories?post=176"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/tags?post=176"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}