{
  "id": 398528,
  "title": "Does the submitted data series need to be the correct data type?",
  "url": "/competitions/benetech-making-graphs-accessible/discussion/398528",
  "author_name": "Nicholas Broad",
  "post_date": "2023-03-30T13:51:12.872000",
  "votes": 8,
  "comment_count": 15,
  "views": 0,
  "content": "<p>If I use a generative model like Donut, it could generate anything as an answer. For example it could insert an \"o\" instead of a 0. If the data series is numerical, and the scoring function does something like this: <code>list(map(float, data_series.split(\";\")))</code>, then it will get a value error when doing <code>float(\"1o\")</code>. Will this cause a submission error or will the score for the row just be 0? </p>\n<p>I am facing scoring errors now, and I have a feeling it is because my model is generating text when it should be generating numbers. </p>\n<p>I can come up with a way to filter out bad characters, but I am anticipating that my approach will not be 100% correct.</p>\n<p><a href=\"https://www.kaggle.com/ryanholbrook\" target=\"_blank\">@ryanholbrook</a></p>",
  "messages": [
    {
      "id": 2203079,
      "postDate": "2023-03-30T13:51:12.873Z",
      "content": "<p>If I use a generative model like Donut, it could generate anything as an answer. For example it could insert an \"o\" instead of a 0. If the data series is numerical, and the scoring function does something like this: <code>list(map(float, data_series.split(\";\")))</code>, then it will get a value error when doing <code>float(\"1o\")</code>. Will this cause a submission error or will the score for the row just be 0? </p>\n<p>I am facing scoring errors now, and I have a feeling it is because my model is generating text when it should be generating numbers. </p>\n<p>I can come up with a way to filter out bad characters, but I am anticipating that my approach will not be 100% correct.</p>\n<p><a href=\"https://www.kaggle.com/ryanholbrook\" target=\"_blank\">@ryanholbrook</a></p>",
      "rawMarkdown": "If I use a generative model like Donut, it could generate anything as an answer. For example it could insert an \"o\" instead of a 0. If the data series is numerical, and the scoring function does something like this: `list(map(float, data_series.split(\";\")))`, then it will get a value error when doing `float(\"1o\")`. Will this cause a submission error or will the score for the row just be 0? \n\nI am facing scoring errors now, and I have a feeling it is because my model is generating text when it should be generating numbers. \n\nI can come up with a way to filter out bad characters, but I am anticipating that my approach will not be 100% correct.\n\n@ryanholbrook",
      "votes": 8
    },
    {
      "id": 2203085,
      "postDate": "2023-03-30T13:55:54.130Z",
      "content": "<p>Hey <a href=\"https://www.kaggle.com/nbroad\" target=\"_blank\">@nbroad</a>, I actually just deployed a change to the metric that will score a 0.0 for an incorrect data type instead of failing. (You beat me to the announcement. 😅) I'll run a rescore on submissions so far, so you won't need to resubmit.</p>\n<p>EDIT: Okay, rescore is finished. Let me know if it's not what you're expecting.</p>",
      "rawMarkdown": "Hey @nbroad, I actually just deployed a change to the metric that will score a 0.0 for an incorrect data type instead of failing. (You beat me to the announcement. 😅) I'll run a rescore on submissions so far, so you won't need to resubmit.\n\nEDIT: Okay, rescore is finished. Let me know if it's not what you're expecting.",
      "votes": 4,
      "replies": [
        {
          "id": 2203089,
          "postDate": "2023-03-30T14:00:42.197Z",
          "content": "<p>Lol it jumped from 0 to 0.42 😂</p>\n<p>Thank you! </p>",
          "rawMarkdown": "Lol it jumped from 0 to 0.42 😂\n\nThank you! ",
          "votes": 3,
          "replies": [
            {
              "id": 2211023,
              "postDate": "2023-04-05T18:52:04.587Z",
              "content": "<p><a href=\"https://www.kaggle.com/ryanholbrook\" target=\"_blank\">@ryanholbrook</a> </p>\n<p>Is my understanding correct?</p>\n<ol>\n<li><p>when GT is \"categorical\"<br>\nEven if the predicted value is of numeric type, it is converted to string and the score is calculated. In this case, the conversion never fails.</p></li>\n<li><p>When GT is \"numerical\"<br>\nThe predicted value is converted to numeric type by float() and the score is calculated. If the conversion fails, the score is 0.</p></li>\n</ol>",
              "rawMarkdown": "@ryanholbrook \n\nIs my understanding correct?\n\n1. when GT is \"categorical\"\nEven if the predicted value is of numeric type, it is converted to string and the score is calculated. In this case, the conversion never fails.\n\n2. When GT is \"numerical\"\nThe predicted value is converted to numeric type by float() and the score is calculated. If the conversion fails, the score is 0.\n",
              "votes": 4
            },
            {
              "id": 2212003,
              "postDate": "2023-04-06T12:42:41.373Z",
              "content": "<p>Yes, that's correct!</p>",
              "rawMarkdown": "Yes, that's correct!",
              "votes": 3
            }
          ]
        }
      ]
    },
    {
      "id": 2263807,
      "postDate": "2023-05-18T00:11:30.850Z",
      "content": "<p>Here are a few lines I added to the end of the benetech_score function to set up local cv.</p>\n<pre><code>     (gt_series, gt_type), (pred_series, pred_type)  pairs:\n        \n         (gt_series[], ):\n            pred_series = [(x)  x  pred_series]\n        \n         (gt_series[], ) ==   (pred_series[], ) == :\n            scores.append()\n            \n\n         gt_type != pred_type:  \n            scores.append()\n        :  \n            scores.append(score_series(gt_series, pred_series))\n</code></pre>",
      "rawMarkdown": "Here are a few lines I added to the end of the benetech_score function to set up local cv.\n\n```python\n    for (gt_series, gt_type), (pred_series, pred_type) in pairs:\n        # Convert ground predicted series to strings\n        if isinstance(gt_series[0], str):\n            pred_series = [str(x) for x in pred_series]\n        # Return if pred_series is str and ground truth is not\n        if isinstance(gt_series[0], str) == False and isinstance(pred_series[0], str) == True:\n            scores.append(0)\n            continue\n        \n        if gt_type != pred_type:  # Check chart_type condition\n            scores.append(0.0)\n        else:  # Score with RMSE or Levenshtein as appropriate\n            scores.append(score_series(gt_series, pred_series))\n```",
      "votes": 2,
      "replies": [
        {
          "id": 2275063,
          "postDate": "2023-05-26T13:13:31.430Z",
          "content": "<p>How did you solve if lists are empty</p>",
          "rawMarkdown": "How did you solve if lists are empty",
          "replies": [
            {
              "id": 2275105,
              "postDate": "2023-05-26T14:04:45.787Z",
              "content": "<p>You could add something like this as the first condition.</p>\n<pre><code>if len(pred_series) == 0:\n    scores.append(0)\n</code></pre>",
              "rawMarkdown": "You could add something like this as the first condition.\n\n```\nif len(pred_series) == 0:\n    scores.append(0)\n```"
            },
            {
              "id": 2275109,
              "postDate": "2023-05-26T14:10:42.347Z",
              "content": "<p>thanks for your reply.you try to use pix2struct to get cv score?</p>",
              "rawMarkdown": "thanks for your reply.you try to use pix2struct to get cv score?",
              "votes": 1
            },
            {
              "id": 2275116,
              "postDate": "2023-05-26T14:18:19.137Z",
              "content": "<p>Yes. I tested out the code with pix2struct and it gets 0.47-0.49 CV when trained on the generated data, and validated on the extracted data.</p>",
              "rawMarkdown": "Yes. I tested out the code with pix2struct and it gets 0.47-0.49 CV when trained on the generated data, and validated on the extracted data."
            },
            {
              "id": 2276162,
              "postDate": "2023-05-26T14:51:21.320Z",
              "content": "<p>Your results look pretty good. I modify benetech_score and still get 0</p>",
              "rawMarkdown": "Your results look pretty good. I modify benetech_score and still get 0"
            },
            {
              "id": 2276177,
              "postDate": "2023-05-26T14:57:51.920Z",
              "content": "<p>I found that writing all the model predictions to a TXT file and then scoring the results manually was useful for debugging. </p>\n<p>In my case, one prediction was somehow causing the <code>normalized_rmse()</code> function from the <a href=\"https://www.kaggle.com/code/ryanholbrook/competition-metric-benetech-mixed-match?scriptVersionId=123629556&amp;cellId=3\" target=\"_blank\">Benetech Mixed-Match</a> notebook to return NAN. This cause my score to be 0 as well.</p>\n<p>Not sure if this is the same as your error, but hope it helps :)</p>",
              "rawMarkdown": "I found that writing all the model predictions to a TXT file and then scoring the results manually was useful for debugging. \n\nIn my case, one prediction was somehow causing the `normalized_rmse()` function from the [Benetech Mixed-Match](https://www.kaggle.com/code/ryanholbrook/competition-metric-benetech-mixed-match?scriptVersionId=123629556&cellId=3) notebook to return NAN. This cause my score to be 0 as well.\n\nNot sure if this is the same as your error, but hope it helps :)"
            },
            {
              "id": 2276187,
              "postDate": "2023-05-26T15:08:19.560Z",
              "content": "<p>you solve this normalized_rmse problem?</p>",
              "rawMarkdown": "you solve this normalized_rmse problem?"
            },
            {
              "id": 2276197,
              "postDate": "2023-05-26T15:15:27.487Z",
              "content": "<p>Not sure if it is the right solution, but I solved by clipping the R2_score between 0-1. </p>\n<pre><code>    def normalized_rmse(self, y_true, y_pred):\n        # The argument to the sigmoid transform is equal to \n        # rmse(y_true, y_pred) / rmse(y_true, np.mean(y_true))\n        return self.sigmoid((1 - np.clip(r2_score(y_true, y_pred), 0, 1) ** 0.5))\n</code></pre>",
              "rawMarkdown": "Not sure if it is the right solution, but I solved by clipping the R2_score between 0-1. \n\n```\n    def normalized_rmse(self, y_true, y_pred):\n        # The argument to the sigmoid transform is equal to \n        # rmse(y_true, y_pred) / rmse(y_true, np.mean(y_true))\n        return self.sigmoid((1 - np.clip(r2_score(y_true, y_pred), 0, 1) ** 0.5))\n```"
            },
            {
              "id": 2276242,
              "postDate": "2023-05-26T15:48:01.517Z",
              "content": "<p>I modify my code,but still give me 0 cv score</p>",
              "rawMarkdown": "I modify my code,but still give me 0 cv score"
            }
          ]
        }
      ]
    },
    {
      "id": 2210441,
      "postDate": "2023-04-05T11:49:04.297Z",
      "rawMarkdown": "",
      "isDeleted": true
    }
  ],
  "comments": [
    {
      "id": 2203085,
      "author_name": "Ryan Holbrook",
      "author_url": "",
      "post_date": "2023-03-30T13:55:54.130000",
      "content": "<p>Hey <a href=\"https://www.kaggle.com/nbroad\" target=\"_blank\">@nbroad</a>, I actually just deployed a change to the metric that will score a 0.0 for an incorrect data type instead of failing. (You beat me to the announcement. 😅) I'll run a rescore on submissions so far, so you won't need to resubmit.</p>\n<p>EDIT: Okay, rescore is finished. Let me know if it's not what you're expecting.</p>",
      "votes": 4,
      "replies": [
        {
          "id": 2203089,
          "author_name": "Nicholas Broad",
          "author_url": "",
          "post_date": "2023-03-30T14:00:42.197000",
          "content": "<p>Lol it jumped from 0 to 0.42 😂</p>\n<p>Thank you! </p>",
          "votes": 3,
          "replies": [
            {
              "id": 2211023,
              "author_name": "penguin46",
              "author_url": "",
              "post_date": "2023-04-05T18:52:04.587000",
              "content": "<p><a href=\"https://www.kaggle.com/ryanholbrook\" target=\"_blank\">@ryanholbrook</a> </p>\n<p>Is my understanding correct?</p>\n<ol>\n<li><p>when GT is \"categorical\"<br>\nEven if the predicted value is of numeric type, it is converted to string and the score is calculated. In this case, the conversion never fails.</p></li>\n<li><p>When GT is \"numerical\"<br>\nThe predicted value is converted to numeric type by float() and the score is calculated. If the conversion fails, the score is 0.</p></li>\n</ol>",
              "votes": 4,
              "replies": []
            },
            {
              "id": 2212003,
              "author_name": "Ryan Holbrook",
              "author_url": "",
              "post_date": "2023-04-06T12:42:41.373000",
              "content": "<p>Yes, that's correct!</p>",
              "votes": 3,
              "replies": []
            }
          ]
        }
      ]
    },
    {
      "id": 2263807,
      "author_name": "Bartley",
      "author_url": "",
      "post_date": "2023-05-18T00:11:30.850000",
      "content": "<p>Here are a few lines I added to the end of the benetech_score function to set up local cv.</p>\n<pre><code>     (gt_series, gt_type), (pred_series, pred_type)  pairs:\n        \n         (gt_series[], ):\n            pred_series = [(x)  x  pred_series]\n        \n         (gt_series[], ) ==   (pred_series[], ) == :\n            scores.append()\n            \n\n         gt_type != pred_type:  \n            scores.append()\n        :  \n            scores.append(score_series(gt_series, pred_series))\n</code></pre>",
      "votes": 2,
      "replies": [
        {
          "id": 2275063,
          "author_name": "Catch_Bat",
          "author_url": "",
          "post_date": "2023-05-26T13:13:31.430000",
          "content": "<p>How did you solve if lists are empty</p>",
          "votes": 0,
          "replies": [
            {
              "id": 2275105,
              "author_name": "Bartley",
              "author_url": "",
              "post_date": "2023-05-26T14:04:45.787000",
              "content": "<p>You could add something like this as the first condition.</p>\n<pre><code>if len(pred_series) == 0:\n    scores.append(0)\n</code></pre>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2275109,
              "author_name": "Catch_Bat",
              "author_url": "",
              "post_date": "2023-05-26T14:10:42.347000",
              "content": "<p>thanks for your reply.you try to use pix2struct to get cv score?</p>",
              "votes": 1,
              "replies": []
            },
            {
              "id": 2275116,
              "author_name": "Bartley",
              "author_url": "",
              "post_date": "2023-05-26T14:18:19.137000",
              "content": "<p>Yes. I tested out the code with pix2struct and it gets 0.47-0.49 CV when trained on the generated data, and validated on the extracted data.</p>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2276162,
              "author_name": "Catch_Bat",
              "author_url": "",
              "post_date": "2023-05-26T14:51:21.320000",
              "content": "<p>Your results look pretty good. I modify benetech_score and still get 0</p>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2276177,
              "author_name": "Bartley",
              "author_url": "",
              "post_date": "2023-05-26T14:57:51.920000",
              "content": "<p>I found that writing all the model predictions to a TXT file and then scoring the results manually was useful for debugging. </p>\n<p>In my case, one prediction was somehow causing the <code>normalized_rmse()</code> function from the <a href=\"https://www.kaggle.com/code/ryanholbrook/competition-metric-benetech-mixed-match?scriptVersionId=123629556&amp;cellId=3\" target=\"_blank\">Benetech Mixed-Match</a> notebook to return NAN. This cause my score to be 0 as well.</p>\n<p>Not sure if this is the same as your error, but hope it helps :)</p>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2276187,
              "author_name": "Catch_Bat",
              "author_url": "",
              "post_date": "2023-05-26T15:08:19.560000",
              "content": "<p>you solve this normalized_rmse problem?</p>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2276197,
              "author_name": "Bartley",
              "author_url": "",
              "post_date": "2023-05-26T15:15:27.487000",
              "content": "<p>Not sure if it is the right solution, but I solved by clipping the R2_score between 0-1. </p>\n<pre><code>    def normalized_rmse(self, y_true, y_pred):\n        # The argument to the sigmoid transform is equal to \n        # rmse(y_true, y_pred) / rmse(y_true, np.mean(y_true))\n        return self.sigmoid((1 - np.clip(r2_score(y_true, y_pred), 0, 1) ** 0.5))\n</code></pre>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2276242,
              "author_name": "Catch_Bat",
              "author_url": "",
              "post_date": "2023-05-26T15:48:01.517000",
              "content": "<p>I modify my code,but still give me 0 cv score</p>",
              "votes": 0,
              "replies": []
            }
          ]
        }
      ]
    },
    {
      "id": 2210441,
      "author_name": "",
      "author_url": "",
      "post_date": "2023-04-05T11:49:04.297000",
      "content": "",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "2203079": "If I use a generative model like Donut, it could generate anything as an answer. For example it could insert an \"o\" instead of a 0. If the data series is numerical, and the scoring function does something like this: `list(map(float, data_series.split(\";\")))`, then it will get a value error when doing `float(\"1o\")`. Will this cause a submission error or will the score for the row just be 0? \n\nI am facing scoring errors now, and I have a feeling it is because my model is generating text when it should be generating numbers. \n\nI can come up with a way to filter out bad characters, but I am anticipating that my approach will not be 100% correct.\n\n@ryanholbrook",
    "2203085": "Hey @nbroad, I actually just deployed a change to the metric that will score a 0.0 for an incorrect data type instead of failing. (You beat me to the announcement. 😅) I'll run a rescore on submissions so far, so you won't need to resubmit.\n\nEDIT: Okay, rescore is finished. Let me know if it's not what you're expecting.",
    "2263807": "Here are a few lines I added to the end of the benetech_score function to set up local cv.\n\n```python\n    for (gt_series, gt_type), (pred_series, pred_type) in pairs:\n        # Convert ground predicted series to strings\n        if isinstance(gt_series[0], str):\n            pred_series = [str(x) for x in pred_series]\n        # Return if pred_series is str and ground truth is not\n        if isinstance(gt_series[0], str) == False and isinstance(pred_series[0], str) == True:\n            scores.append(0)\n            continue\n        \n        if gt_type != pred_type:  # Check chart_type condition\n            scores.append(0.0)\n        else:  # Score with RMSE or Levenshtein as appropriate\n            scores.append(score_series(gt_series, pred_series))\n```",
    "2210441": ""
  }
}