{
  "id": 546103,
  "title": "Inconsistency Between MSE and R² Metrics",
  "url": "/competitions/jane-street-real-time-market-data-forecasting/discussion/546103",
  "author_name": "Ayman Allawi",
  "post_date": "2024-11-13T22:27:04.496000",
  "votes": 2,
  "comment_count": 6,
  "views": 0,
  "content": "<p>I was conducting some experiments and noticed a peculiar behavior when using MSE as my evaluation metric. Specifically, when I shuffled the features, the MSE only increased by around 15% at most. In contrast, R² dropped significantly, as expected. This small change in MSE didn’t make sense to me, so I thoroughly checked my code for bugs but found none.</p>\n<p>Could someone explain why MSE behaves this way? Why doesn't it reflect the significant drop in model performance as clearly as R²?</p>",
  "messages": [
    {
      "id": 3045244,
      "postDate": "2024-11-14T10:10:05.377Z",
      "content": "<p>Let's assume that all your predictions are very close to zero, i.e., the mean of the target. Assume then, sum(w*y^2)=1 and sum(w*(y-y')^2)=0.99, Then R^2 = 1-0.99/1 = 0.01.<br>\nBut sum(w*(y-y')^2)=0.99 is proportional to weighted MSE. So assume your MSE_new = 1.15*MSE_old (changed by 15%). So now new(sum(w*(y-y')^2)) = 1.15*0.99 = 1.1385. Leading to:<br>\nnew(R^2) = 1-1.1385/1 = -0.1385.<br>\nYour MSE changed only by 15%, but R^2 changed from 0.01 (1st place on public LB) to -0.1385. There.</p>",
      "rawMarkdown": "Let's assume that all your predictions are very close to zero, i.e., the mean of the target. Assume then, sum(w\\*y^2)=1 and sum(w\\*(y-y')^2)=0.99, Then R^2 = 1-0.99/1 = 0.01.\nBut sum(w\\*(y-y')^2)=0.99 is proportional to weighted MSE. So assume your MSE_new = 1.15\\*MSE_old (changed by 15%). So now new(sum(w\\*(y-y')^2)) = 1.15\\*0.99 = 1.1385. Leading to:\nnew(R^2) = 1-1.1385/1 = -0.1385.\nYour MSE changed only by 15%, but R^2 changed from 0.01 (1st place on public LB) to -0.1385. There.",
      "votes": 7
    },
    {
      "id": 3045043,
      "postDate": "2024-11-14T05:45:32.600Z",
      "content": "<p>The metric here is modified R2score, so I am unsure if trying to optimize anything else is the right approach <a href=\"https://www.kaggle.com/aymanallawi\" target=\"_blank\">@aymanallawi</a> </p>",
      "rawMarkdown": "The metric here is modified R2score, so I am unsure if trying to optimize anything else is the right approach @aymanallawi ",
      "votes": 1,
      "replies": [
        {
          "id": 3045105,
          "postDate": "2024-11-14T07:08:02.700Z",
          "content": "<p>You're totally right it isn't the right approach but I'm just curious why MSE is unrepresentative here. So, I just want to know for the sake of knowledge </p>",
          "rawMarkdown": "You're totally right it isn't the right approach but I'm just curious why MSE is unrepresentative here. So, I just want to know for the sake of knowledge ",
          "votes": 1,
          "replies": [
            {
              "id": 3045119,
              "postDate": "2024-11-14T07:25:39.960Z",
              "content": "<p>MSE is not in scope for this competition, so discussing it is kind-of futile <a href=\"https://www.kaggle.com/aymanallawi\" target=\"_blank\">@aymanallawi</a> </p>",
              "rawMarkdown": "MSE is not in scope for this competition, so discussing it is kind-of futile @aymanallawi "
            }
          ]
        },
        {
          "id": 3045234,
          "postDate": "2024-11-14T09:49:01.500Z",
          "content": "<p><em>Trying</em> to optimize 'anything else' is always a right approach.<br>\nLEAP was with r-squared metric, and I won it thanks to optimizing MAE.<br>\nAlways try to tinker with the loss. You would be surprised how much it can be effective.</p>",
          "rawMarkdown": "*Trying* to optimize 'anything else' is always a right approach.\nLEAP was with r-squared metric, and I won it thanks to optimizing MAE.\nAlways try to tinker with the loss. You would be surprised how much it can be effective.",
          "votes": 5
        }
      ]
    },
    {
      "id": 3044851,
      "postDate": "2024-11-13T22:27:04.497Z",
      "content": "<p>I was conducting some experiments and noticed a peculiar behavior when using MSE as my evaluation metric. Specifically, when I shuffled the features, the MSE only increased by around 15% at most. In contrast, R² dropped significantly, as expected. This small change in MSE didn’t make sense to me, so I thoroughly checked my code for bugs but found none.</p>\n<p>Could someone explain why MSE behaves this way? Why doesn't it reflect the significant drop in model performance as clearly as R²?</p>",
      "rawMarkdown": "I was conducting some experiments and noticed a peculiar behavior when using MSE as my evaluation metric. Specifically, when I shuffled the features, the MSE only increased by around 15% at most. In contrast, R² dropped significantly, as expected. This small change in MSE didn’t make sense to me, so I thoroughly checked my code for bugs but found none.\n\nCould someone explain why MSE behaves this way? Why doesn't it reflect the significant drop in model performance as clearly as R²?",
      "votes": 2
    },
    {
      "id": 3044921,
      "postDate": "2024-11-14T01:16:39.147Z",
      "rawMarkdown": "",
      "isDeleted": true
    }
  ],
  "comments": [
    {
      "id": 3045244,
      "author_name": "greySnow",
      "author_url": "",
      "post_date": "2024-11-14T10:10:05.377000",
      "content": "<p>Let's assume that all your predictions are very close to zero, i.e., the mean of the target. Assume then, sum(w*y^2)=1 and sum(w*(y-y')^2)=0.99, Then R^2 = 1-0.99/1 = 0.01.<br>\nBut sum(w*(y-y')^2)=0.99 is proportional to weighted MSE. So assume your MSE_new = 1.15*MSE_old (changed by 15%). So now new(sum(w*(y-y')^2)) = 1.15*0.99 = 1.1385. Leading to:<br>\nnew(R^2) = 1-1.1385/1 = -0.1385.<br>\nYour MSE changed only by 15%, but R^2 changed from 0.01 (1st place on public LB) to -0.1385. There.</p>",
      "votes": 7,
      "replies": []
    },
    {
      "id": 3045043,
      "author_name": "Ravi Ramakrishnan",
      "author_url": "",
      "post_date": "2024-11-14T05:45:32.600000",
      "content": "<p>The metric here is modified R2score, so I am unsure if trying to optimize anything else is the right approach <a href=\"https://www.kaggle.com/aymanallawi\" target=\"_blank\">@aymanallawi</a> </p>",
      "votes": 1,
      "replies": [
        {
          "id": 3045105,
          "author_name": "Ayman Allawi",
          "author_url": "",
          "post_date": "2024-11-14T07:08:02.700000",
          "content": "<p>You're totally right it isn't the right approach but I'm just curious why MSE is unrepresentative here. So, I just want to know for the sake of knowledge </p>",
          "votes": 1,
          "replies": [
            {
              "id": 3045119,
              "author_name": "Ravi Ramakrishnan",
              "author_url": "",
              "post_date": "2024-11-14T07:25:39.960000",
              "content": "<p>MSE is not in scope for this competition, so discussing it is kind-of futile <a href=\"https://www.kaggle.com/aymanallawi\" target=\"_blank\">@aymanallawi</a> </p>",
              "votes": 0,
              "replies": []
            }
          ]
        },
        {
          "id": 3045234,
          "author_name": "greySnow",
          "author_url": "",
          "post_date": "2024-11-14T09:49:01.500000",
          "content": "<p><em>Trying</em> to optimize 'anything else' is always a right approach.<br>\nLEAP was with r-squared metric, and I won it thanks to optimizing MAE.<br>\nAlways try to tinker with the loss. You would be surprised how much it can be effective.</p>",
          "votes": 5,
          "replies": []
        }
      ]
    },
    {
      "id": 3044921,
      "author_name": "",
      "author_url": "",
      "post_date": "2024-11-14T01:16:39.147000",
      "content": "",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "3045244": "Let's assume that all your predictions are very close to zero, i.e., the mean of the target. Assume then, sum(w\\*y^2)=1 and sum(w\\*(y-y')^2)=0.99, Then R^2 = 1-0.99/1 = 0.01.\nBut sum(w\\*(y-y')^2)=0.99 is proportional to weighted MSE. So assume your MSE_new = 1.15\\*MSE_old (changed by 15%). So now new(sum(w\\*(y-y')^2)) = 1.15\\*0.99 = 1.1385. Leading to:\nnew(R^2) = 1-1.1385/1 = -0.1385.\nYour MSE changed only by 15%, but R^2 changed from 0.01 (1st place on public LB) to -0.1385. There.",
    "3045043": "The metric here is modified R2score, so I am unsure if trying to optimize anything else is the right approach @aymanallawi ",
    "3044851": "I was conducting some experiments and noticed a peculiar behavior when using MSE as my evaluation metric. Specifically, when I shuffled the features, the MSE only increased by around 15% at most. In contrast, R² dropped significantly, as expected. This small change in MSE didn’t make sense to me, so I thoroughly checked my code for bugs but found none.\n\nCould someone explain why MSE behaves this way? Why doesn't it reflect the significant drop in model performance as clearly as R²?",
    "3044921": ""
  }
}