{
  "id": 303801,
  "title": "Evaluation metric ??",
  "url": "/competitions/g-research-crypto-forecasting/discussion/303801",
  "author_name": "",
  "post_date": "2022-01-29T13:02:40.709564900Z",
  "votes": 1,
  "comment_count": 2,
  "views": 0,
  "content": "<p>I saw the post that describe the evaluation metric function (<a href=\"https://www.kaggle.com/c/g-research-crypto-forecasting/discussion/291845\" target=\"_blank\">https://www.kaggle.com/c/g-research-crypto-forecasting/discussion/291845</a>) but I noticed that the mean is calculated in a strange way:</p>\n<p>mean_a = np.sum(a * w) / sum_w<br>\n  mean_b = np.sum(b * w) / sum_w</p>\n<p>Is not the mean of x, for example, is : sum(x)/n , where n = len(x)</p>\n<p>and then if values in x are weighted by another vector w, then it becomes:</p>\n<p>sum(x*w) / sum_w / n</p>\n<p>where sum_w = sum(w), and sum(w/sum_w) = 1</p>\n<p>If so, then the calculation of mean_a &amp; mean_b should be like</p>\n<p>mean_a = np.sum(a * w) / sum_w /<strong>n</strong><br>\nmean_b = np.sum(b * w) / sum_w / <strong>n</strong></p>\n<p>where n = len(a) = len(b) = len(w)</p>\n<p>Why there is no <strong>n</strong>?</p>",
  "messages": [
    {
      "id": "1668228",
      "postDate": "01/29/2022 13:02:40",
      "content": "<p>I saw the post that describe the evaluation metric function (<a href=\"https://www.kaggle.com/c/g-research-crypto-forecasting/discussion/291845\" target=\"_blank\">https://www.kaggle.com/c/g-research-crypto-forecasting/discussion/291845</a>) but I noticed that the mean is calculated in a strange way:</p>\n<p>mean_a = np.sum(a * w) / sum_w<br>\n  mean_b = np.sum(b * w) / sum_w</p>\n<p>Is not the mean of x, for example, is : sum(x)/n , where n = len(x)</p>\n<p>and then if values in x are weighted by another vector w, then it becomes:</p>\n<p>sum(x*w) / sum_w / n</p>\n<p>where sum_w = sum(w), and sum(w/sum_w) = 1</p>\n<p>If so, then the calculation of mean_a &amp; mean_b should be like</p>\n<p>mean_a = np.sum(a * w) / sum_w /<strong>n</strong><br>\nmean_b = np.sum(b * w) / sum_w / <strong>n</strong></p>\n<p>where n = len(a) = len(b) = len(w)</p>\n<p>Why there is no <strong>n</strong>?</p>",
      "rawMarkdown": "I saw the post that describe the evaluation metric function (https://www.kaggle.com/c/g-research-crypto-forecasting/discussion/291845) but I noticed that the mean is calculated in a strange way:\n\n\n  mean_a = np.sum(a * w) / sum_w\n  mean_b = np.sum(b * w) / sum_w\n\n\nIs not the mean of x, for example, is : sum(x)/n , where n = len(x)\n\nand then if values in x are weighted by another vector w, then it becomes:\n\nsum(x*w) / sum_w / n\n\nwhere sum_w = sum(w), and sum(w/sum_w) = 1\n\nIf so, then the calculation of mean_a & mean_b should be like\n\nmean_a = np.sum(a * w) / sum_w /**n**\nmean_b = np.sum(b * w) / sum_w / **n**\n\nwhere n = len(a) = len(b) = len(w)\n\nWhy there is no **n**?",
      "votes": null
    },
    {
      "id": "1668303",
      "postDate": "01/29/2022 14:12:45",
      "content": "<p>I think you might be muddling things a bit. Take the case where all of the weights are 1, i.e. that w is a vector with all (n) of its entries = 1. Then using the competition's definition of weighted mean:</p>\n<p>np.sum(a * w) = np.sum(a),<br>\nand<br>\nsum(w) = n,<br>\nso this reduces to the case:<br>\nmean_a = np.sum(a) / n<br>\nas desired.</p>\n<p>If we were to use your proposed normalisation and also divide by n then that would mean mean_a = np.sum(a), which is inconsistent with the standard definition of the mean.</p>",
      "rawMarkdown": "I think you might be muddling things a bit. Take the case where all of the weights are 1, i.e. that w is a vector with all (n) of its entries = 1. Then using the competition's definition of weighted mean:\n\nnp.sum(a * w) = np.sum(a),\nand\nsum(w) = n,\nso this reduces to the case:\nmean_a = np.sum(a) / n\nas desired.\n\nIf we were to use your proposed normalisation and also divide by n then that would mean mean_a = np.sum(a), which is inconsistent with the standard definition of the mean.",
      "votes": null
    },
    {
      "id": "1668413",
      "postDate": "01/29/2022 15:44:31",
      "content": "<p>Oh yes you are right! Thanks for replying.</p>",
      "rawMarkdown": "Oh yes you are right! Thanks for replying.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1668303,
      "author_name": "jagofc",
      "author_url": "",
      "post_date": "01/29/2022 14:12:45",
      "content": "<p>I think you might be muddling things a bit. Take the case where all of the weights are 1, i.e. that w is a vector with all (n) of its entries = 1. Then using the competition's definition of weighted mean:</p>\n<p>np.sum(a * w) = np.sum(a),<br>\nand<br>\nsum(w) = n,<br>\nso this reduces to the case:<br>\nmean_a = np.sum(a) / n<br>\nas desired.</p>\n<p>If we were to use your proposed normalisation and also divide by n then that would mean mean_a = np.sum(a), which is inconsistent with the standard definition of the mean.</p>",
      "votes": null,
      "replies": [
        {
          "id": 1668413,
          "author_name": "mohammadabdelwahab",
          "author_url": "",
          "post_date": "01/29/2022 15:44:31",
          "content": "<p>Oh yes you are right! Thanks for replying.</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "1668228": "I saw the post that describe the evaluation metric function (https://www.kaggle.com/c/g-research-crypto-forecasting/discussion/291845) but I noticed that the mean is calculated in a strange way:\n\n\n  mean_a = np.sum(a * w) / sum_w\n  mean_b = np.sum(b * w) / sum_w\n\n\nIs not the mean of x, for example, is : sum(x)/n , where n = len(x)\n\nand then if values in x are weighted by another vector w, then it becomes:\n\nsum(x*w) / sum_w / n\n\nwhere sum_w = sum(w), and sum(w/sum_w) = 1\n\nIf so, then the calculation of mean_a & mean_b should be like\n\nmean_a = np.sum(a * w) / sum_w /**n**\nmean_b = np.sum(b * w) / sum_w / **n**\n\nwhere n = len(a) = len(b) = len(w)\n\nWhy there is no **n**?",
    "1668303": "I think you might be muddling things a bit. Take the case where all of the weights are 1, i.e. that w is a vector with all (n) of its entries = 1. Then using the competition's definition of weighted mean:\n\nnp.sum(a * w) = np.sum(a),\nand\nsum(w) = n,\nso this reduces to the case:\nmean_a = np.sum(a) / n\nas desired.\n\nIf we were to use your proposed normalisation and also divide by n then that would mean mean_a = np.sum(a), which is inconsistent with the standard definition of the mean.",
    "1668413": "Oh yes you are right! Thanks for replying."
  },
  "source": "meta"
}