{
  "id": 11290,
  "title": "Classification error",
  "url": "/competitions/datasciencebowl/discussion/11290",
  "author_name": "",
  "post_date": "2014-12-18T09:05:20.357Z",
  "votes": null,
  "comment_count": 12,
  "views": 3541,
  "content": "<p>hi,</p>\n<p>the error measure seems not very natural for me.</p>\n<p>The formula on the evaluation page says that it counts only the columns where target is 1.</p>\n<p>Anyway, since this is a classification problem I also evaluated the accuracy.</p>\n<p>I got 55% accuracy on a 20% random validation set.</p>\n<p>Submitting this leads me to 1.9 lb or so.</p>\n<p>The model is a drednet (neural net with ReLu's) on a 50x50 scaled version of the data.</p>\n<p>Have anyone evaluated accuracy too ?</p>",
  "messages": [
    {
      "id": "61456",
      "postDate": "12/18/2014 09:05:20",
      "content": "<p>hi,</p>\n<p>the error measure seems not very natural for me.</p>\n<p>The formula on the evaluation page says that it counts only the columns where target is 1.</p>\n<p>Anyway, since this is a classification problem I also evaluated the accuracy.</p>\n<p>I got 55% accuracy on a 20% random validation set.</p>\n<p>Submitting this leads me to 1.9 lb or so.</p>\n<p>The model is a drednet (neural net with ReLu's) on a 50x50 scaled version of the data.</p>\n<p>Have anyone evaluated accuracy too ?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "61458",
      "postDate": "12/18/2014 09:29:44",
      "content": "<p>According to the&nbsp;evaluation page:</p>\n<p style=\"padding-left: 30px\"><em>The submitted probabilities for a given image are not required to sum to one because they are rescaled prior to being scored (each row is divided by the row sum).</em></p>\n<p>With that pre-processing, then the log loss function does take account of all output predictions, and not just the target column. If you are using a softmax output layer, you won't notice the difference though, as your model is already scaling&nbsp;the outputs in the same way</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "61459",
      "postDate": "12/18/2014 09:35:34",
      "content": "<p>yep, but compare the formulas here on evaluation page and this one:</p>\n<p>https://www.kaggle.com/wiki/LogarithmicLoss</p>\n<p>There is a term missing&nbsp;&quot;(1-yi)*log(1-yi^)&quot; which counts the error for &quot;0&quot; targets.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "61460",
      "postDate": "12/18/2014 09:46:05",
      "content": "<p>You should note that yi is either 0 or 1. So, yi*log(yi^) + (1-yi)*log(1-yi^) is essentially one term. The two formulas are the same.</p>\n<p>As for the accuracy, I got similar result.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "61462",
      "postDate": "12/18/2014 09:50:13",
      "content": "<p>[quote=Michael Jahrer;61459]</p>\n<p>yep, but compare the formulas here on evaluation page and this one:</p>\n<p>https://www.kaggle.com/wiki/LogarithmicLoss</p>\n<p>There is a term missing&nbsp;&quot;(1-yi)*log(1-yi^)&quot; which counts the error for &quot;0&quot; targets.</p>\n<p>[/quote]</p>\n<p>It doesn't really matter, the 0's are being accounted for by the normalisation, although you are right it is not the same numerically.</p>\n<p>Adding the (1-yi) terms would&nbsp;increase the error&nbsp;value for&nbsp;classification&nbsp;errors which were &quot;really confident it is this specific wrong thing&quot; as opposed to &quot;not really sure what it is&quot;.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "61463",
      "postDate": "12/18/2014 09:57:22",
      "content": "<p>[quote=yr;61460]</p>\n<p>You should note that yi is either 0 or 1. So, yi*log(yi^) + (1-yi)*log(1-yi^) is essentially one term. The two formulas are the same.</p>\n<p>[/quote]</p>\n<p>I don't think the last sentence here is correct. The formulae are different, and would result in different metrics for the competition.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "61464",
      "postDate": "12/18/2014 09:57:23",
      "content": "<p>e.g. 4 classes, M=4<br>y=[0 0 1 0] &lt;-- targets<br>yp=[0.1 0.1 0.5 0.3] &lt;-- predictions</p>\n<p>sum(j=1,M,yj*log(ypj))<br>= 0*log(0.1) + 0*log(0.1) + 1*log(0.5) + 0*log(0.3) = -0.6931</p>\n<p>sum(j=1,M,yj*log(ypj)+(1-yj)*log(1-ypj))<br>= 0*log(0.1)+(1-0)*log(1-0.1) + 0*log(0.1)+(1-0)*log(1-0.1) + 1*log(0.5)+(1-1)*log(0.5) + 0*log(0.3)+(1-0)*log(1-0.3) = -1.2605</p>\n<p>with &quot;y*log(yp)&quot; -&gt; -0.6931<br>with &quot;y*log(yp)+(1-y)*log(1-yp)&quot; -&gt; -1.2605</p>\n<p>so there is a difference, or am I miss something ?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "61465",
      "postDate": "12/18/2014 10:14:26",
      "content": "<p>[quote=Michael Jahrer;61464]</p>\n<p>so there is a difference, or am I miss something ?</p>\n<p>[/quote]</p>\n<p>I was just about to post a similar numerical example.</p>\n<p>You are right, but as I said, it is not such a big difference in practical terms. The competition is focussing on confidence in the correct class, and does not care about your distribution of incorrect classes. However, with the output scaling, your confidence in the correct class <em>does depend on all the outputs</em>, not just the correct one.</p>\n<p>There may be good design reasons for this choice, such as not wanting to penalise poor categorisation to similar-looking items (the same kind of error a human&nbsp;might make).</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "61469",
      "postDate": "12/18/2014 11:13:46",
      "content": "<p>LogLoss is usually used in binary classification, y \\in {0, 1}. Therefore, &quot;y*log(yp)+(1-y)*log(1-yp)&quot; reduces to one term that is&nbsp;associated with the true target, i.e.,</p>\n<p>y = 1 : log(yp)</p>\n<p>y= 0 : log(1-yp) (Note: 1-yp here is the probability that the example is &quot;0&quot;)</p>\n<p>This is just the (negative) log likelihood of the data.</p>\n<p>Softmax loss/cross entry as in &quot;sum(j=1,M,yj*log(ypj))&quot; is a generalization of logloss to multi-class problem. It is the log likelihood of the data too. See:&nbsp;http://deeplearning.stanford.edu/wiki/index.php/Softmax_Regression</p>\n<p>[quote=Michael Jahrer;61464]</p>\n<p>e.g. 4 classes, M=4<br>y=[0 0 1 0] &lt;-- targets<br>yp=[0.1 0.1 0.5 0.3] &lt;-- predictions</p>\n<p>sum(j=1,M,yj*log(ypj))<br>= 0*log(0.1) + 0*log(0.1) + 1*log(0.5) + 0*log(0.3) = -0.6931</p>\n<p>sum(j=1,M,yj*log(ypj)+(1-yj)*log(1-ypj))<br>= 0*log(0.1)+(1-0)*log(1-0.1) + 0*log(0.1)+(1-0)*log(1-0.1) + 1*log(0.5)+(1-1)*log(0.5) + 0*log(0.3)+(1-0)*log(1-0.3) = -1.2605</p>\n<p>with &quot;y*log(yp)&quot; -&gt; -0.6931<br>with &quot;y*log(yp)+(1-y)*log(1-yp)&quot; -&gt; -1.2605</p>\n<p>so there is a difference, or am I miss something ?</p>\n<p>[/quote]</p>\n<p>In your above example, if you are using the second method to compute the error, then you are treating each target as a binary classification problem (multi-label classification in terminology). It is not the same as multi-class classification, which should use the first method if you are trying to get the multi-class logloss / softmax loss.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "61485",
      "postDate": "12/18/2014 14:31:32",
      "content": "<p>thanks yr, this makes sense</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "61505",
      "postDate": "12/18/2014 22:00:11",
      "content": "<p>The model currently in first has an accuracy of around 71-72% on a 20% random validation set.<br><br>Still got plenty of ground to cover to compete with humans&nbsp;=P</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "61508",
      "postDate": "12/18/2014 23:18:50",
      "content": "<p>The attachment file is a validation log of my model. includes NLL/Accuracy score.</p>\n<p>My model is CNN using Torch7.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "65900",
      "postDate": "03/10/2015 18:17:29",
      "content": "<p>Looking into parallel multinomial options using R. Seems like there are more use cases not using multinomial outputs in this area, where each of the 121 classes predicted sum over a more even range of probabilities--<strong>multi-class classification </strong>each row sums to 1.</p>\n<p>Does the competition allow<strong> multi-label classification </strong>submissions (e.g., [.15, .15, .4, .15, .15]) where each element in a given row will equal either 0 or 1 (e.g., [0, 0, 1, 0, 0]) where each row sums 1?</p>",
      "rawMarkdown": "",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 61458,
      "author_name": "slobo777",
      "author_url": "",
      "post_date": "12/18/2014 09:29:44",
      "content": "<p>According to the&nbsp;evaluation page:</p>\n<p style=\"padding-left: 30px\"><em>The submitted probabilities for a given image are not required to sum to one because they are rescaled prior to being scored (each row is divided by the row sum).</em></p>\n<p>With that pre-processing, then the log loss function does take account of all output predictions, and not just the target column. If you are using a softmax output layer, you won't notice the difference though, as your model is already scaling&nbsp;the outputs in the same way</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 61459,
      "author_name": "mjahrer",
      "author_url": "",
      "post_date": "12/18/2014 09:35:34",
      "content": "<p>yep, but compare the formulas here on evaluation page and this one:</p>\n<p>https://www.kaggle.com/wiki/LogarithmicLoss</p>\n<p>There is a term missing&nbsp;&quot;(1-yi)*log(1-yi^)&quot; which counts the error for &quot;0&quot; targets.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 61460,
      "author_name": "chenglongchen",
      "author_url": "",
      "post_date": "12/18/2014 09:46:05",
      "content": "<p>You should note that yi is either 0 or 1. So, yi*log(yi^) + (1-yi)*log(1-yi^) is essentially one term. The two formulas are the same.</p>\n<p>As for the accuracy, I got similar result.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 61462,
      "author_name": "slobo777",
      "author_url": "",
      "post_date": "12/18/2014 09:50:13",
      "content": "<p>[quote=Michael Jahrer;61459]</p>\n<p>yep, but compare the formulas here on evaluation page and this one:</p>\n<p>https://www.kaggle.com/wiki/LogarithmicLoss</p>\n<p>There is a term missing&nbsp;&quot;(1-yi)*log(1-yi^)&quot; which counts the error for &quot;0&quot; targets.</p>\n<p>[/quote]</p>\n<p>It doesn't really matter, the 0's are being accounted for by the normalisation, although you are right it is not the same numerically.</p>\n<p>Adding the (1-yi) terms would&nbsp;increase the error&nbsp;value for&nbsp;classification&nbsp;errors which were &quot;really confident it is this specific wrong thing&quot; as opposed to &quot;not really sure what it is&quot;.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 61463,
      "author_name": "slobo777",
      "author_url": "",
      "post_date": "12/18/2014 09:57:22",
      "content": "<p>[quote=yr;61460]</p>\n<p>You should note that yi is either 0 or 1. So, yi*log(yi^) + (1-yi)*log(1-yi^) is essentially one term. The two formulas are the same.</p>\n<p>[/quote]</p>\n<p>I don't think the last sentence here is correct. The formulae are different, and would result in different metrics for the competition.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 61464,
      "author_name": "mjahrer",
      "author_url": "",
      "post_date": "12/18/2014 09:57:23",
      "content": "<p>e.g. 4 classes, M=4<br>y=[0 0 1 0] &lt;-- targets<br>yp=[0.1 0.1 0.5 0.3] &lt;-- predictions</p>\n<p>sum(j=1,M,yj*log(ypj))<br>= 0*log(0.1) + 0*log(0.1) + 1*log(0.5) + 0*log(0.3) = -0.6931</p>\n<p>sum(j=1,M,yj*log(ypj)+(1-yj)*log(1-ypj))<br>= 0*log(0.1)+(1-0)*log(1-0.1) + 0*log(0.1)+(1-0)*log(1-0.1) + 1*log(0.5)+(1-1)*log(0.5) + 0*log(0.3)+(1-0)*log(1-0.3) = -1.2605</p>\n<p>with &quot;y*log(yp)&quot; -&gt; -0.6931<br>with &quot;y*log(yp)+(1-y)*log(1-yp)&quot; -&gt; -1.2605</p>\n<p>so there is a difference, or am I miss something ?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 61465,
      "author_name": "slobo777",
      "author_url": "",
      "post_date": "12/18/2014 10:14:26",
      "content": "<p>[quote=Michael Jahrer;61464]</p>\n<p>so there is a difference, or am I miss something ?</p>\n<p>[/quote]</p>\n<p>I was just about to post a similar numerical example.</p>\n<p>You are right, but as I said, it is not such a big difference in practical terms. The competition is focussing on confidence in the correct class, and does not care about your distribution of incorrect classes. However, with the output scaling, your confidence in the correct class <em>does depend on all the outputs</em>, not just the correct one.</p>\n<p>There may be good design reasons for this choice, such as not wanting to penalise poor categorisation to similar-looking items (the same kind of error a human&nbsp;might make).</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 61469,
      "author_name": "chenglongchen",
      "author_url": "",
      "post_date": "12/18/2014 11:13:46",
      "content": "<p>LogLoss is usually used in binary classification, y \\in {0, 1}. Therefore, &quot;y*log(yp)+(1-y)*log(1-yp)&quot; reduces to one term that is&nbsp;associated with the true target, i.e.,</p>\n<p>y = 1 : log(yp)</p>\n<p>y= 0 : log(1-yp) (Note: 1-yp here is the probability that the example is &quot;0&quot;)</p>\n<p>This is just the (negative) log likelihood of the data.</p>\n<p>Softmax loss/cross entry as in &quot;sum(j=1,M,yj*log(ypj))&quot; is a generalization of logloss to multi-class problem. It is the log likelihood of the data too. See:&nbsp;http://deeplearning.stanford.edu/wiki/index.php/Softmax_Regression</p>\n<p>[quote=Michael Jahrer;61464]</p>\n<p>e.g. 4 classes, M=4<br>y=[0 0 1 0] &lt;-- targets<br>yp=[0.1 0.1 0.5 0.3] &lt;-- predictions</p>\n<p>sum(j=1,M,yj*log(ypj))<br>= 0*log(0.1) + 0*log(0.1) + 1*log(0.5) + 0*log(0.3) = -0.6931</p>\n<p>sum(j=1,M,yj*log(ypj)+(1-yj)*log(1-ypj))<br>= 0*log(0.1)+(1-0)*log(1-0.1) + 0*log(0.1)+(1-0)*log(1-0.1) + 1*log(0.5)+(1-1)*log(0.5) + 0*log(0.3)+(1-0)*log(1-0.3) = -1.2605</p>\n<p>with &quot;y*log(yp)&quot; -&gt; -0.6931<br>with &quot;y*log(yp)+(1-y)*log(1-yp)&quot; -&gt; -1.2605</p>\n<p>so there is a difference, or am I miss something ?</p>\n<p>[/quote]</p>\n<p>In your above example, if you are using the second method to compute the error, then you are treating each target as a binary classification problem (multi-label classification in terminology). It is not the same as multi-class classification, which should use the first method if you are trying to get the multi-class logloss / softmax loss.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 61485,
      "author_name": "mjahrer",
      "author_url": "",
      "post_date": "12/18/2014 14:31:32",
      "content": "<p>thanks yr, this makes sense</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 61505,
      "author_name": "alecradford",
      "author_url": "",
      "post_date": "12/18/2014 22:00:11",
      "content": "<p>The model currently in first has an accuracy of around 71-72% on a 20% random validation set.<br><br>Still got plenty of ground to cover to compete with humans&nbsp;=P</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 61508,
      "author_name": "nagadomi",
      "author_url": "",
      "post_date": "12/18/2014 23:18:50",
      "content": "<p>The attachment file is a validation log of my model. includes NLL/Accuracy score.</p>\n<p>My model is CNN using Torch7.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 65900,
      "author_name": "zeccalehn",
      "author_url": "",
      "post_date": "03/10/2015 18:17:29",
      "content": "<p>Looking into parallel multinomial options using R. Seems like there are more use cases not using multinomial outputs in this area, where each of the 121 classes predicted sum over a more even range of probabilities--<strong>multi-class classification </strong>each row sums to 1.</p>\n<p>Does the competition allow<strong> multi-label classification </strong>submissions (e.g., [.15, .15, .4, .15, .15]) where each element in a given row will equal either 0 or 1 (e.g., [0, 0, 1, 0, 0]) where each row sums 1?</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "61456": "",
    "61458": "",
    "61459": "",
    "61460": "",
    "61462": "",
    "61463": "",
    "61464": "",
    "61465": "",
    "61469": "",
    "61485": "",
    "61505": "",
    "61508": "",
    "65900": ""
  },
  "source": "meta"
}