{
  "id": 418077,
  "title": "Submission Scoring Error",
  "url": "/competitions/benetech-making-graphs-accessible/discussion/418077",
  "author_name": "",
  "post_date": "2023-06-18T16:47:21.516125300Z",
  "votes": null,
  "comment_count": 8,
  "views": 0,
  "content": "<p>I sadly run out all my submissions today because of this error. I added an exception statement inside a loop in case there is any error, it will be replaced by empty list for both axes and empty string for chart type. Could anyone please take a look on the code below and also the image of the csv file generated from the test dataset (5 images) and tell me what I did wrong? I highly appreciate your time. </p>\n<pre><code>data = []\n\n image, label  image_pred_lbls:\n    :\n          \n         \n         \n          data.append({\n            : name[:-]+,\n            : x_values,\n            : mapping[lbl]\n             })\n\n           data.append({\n            : name[:-]+,\n            : y_values,\n            : mapping[lbl]\n           })\n     Exception  e: \n        traceback.print_exc()\n        data.append({\n                : name[:-]+,\n                : [],  \n                :    \n            })\n\n        data.append({\n                : name[:-]+,\n                : [],\n                : \n            })\n\n\n\npredictions = pd.DataFrame(data).set_index()\n\ndata = []\n\n index, row  predictions.iterrows():\n    data.append({\n        : index,\n        : .join((, row[])),\n        : row[]\n    })\n\ndf = pd.DataFrame(data)\ndf.to_csv(, index=)\n</code></pre>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F14946445%2Fa55fd122f77cf7f693682b654ac2cb37%2F1.PNG?generation=1687106893202884&amp;alt=media\" alt=\"image\"></p>",
  "messages": [
    {
      "id": "2308092",
      "postDate": "06/18/2023 16:47:21",
      "content": "<p>I sadly run out all my submissions today because of this error. I added an exception statement inside a loop in case there is any error, it will be replaced by empty list for both axes and empty string for chart type. Could anyone please take a look on the code below and also the image of the csv file generated from the test dataset (5 images) and tell me what I did wrong? I highly appreciate your time. </p>\n<pre><code>data = []\n\n image, label  image_pred_lbls:\n    :\n          \n         \n         \n          data.append({\n            : name[:-]+,\n            : x_values,\n            : mapping[lbl]\n             })\n\n           data.append({\n            : name[:-]+,\n            : y_values,\n            : mapping[lbl]\n           })\n     Exception  e: \n        traceback.print_exc()\n        data.append({\n                : name[:-]+,\n                : [],  \n                :    \n            })\n\n        data.append({\n                : name[:-]+,\n                : [],\n                : \n            })\n\n\n\npredictions = pd.DataFrame(data).set_index()\n\ndata = []\n\n index, row  predictions.iterrows():\n    data.append({\n        : index,\n        : .join((, row[])),\n        : row[]\n    })\n\ndf = pd.DataFrame(data)\ndf.to_csv(, index=)\n</code></pre>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F14946445%2Fa55fd122f77cf7f693682b654ac2cb37%2F1.PNG?generation=1687106893202884&amp;alt=media\" alt=\"image\"></p>",
      "rawMarkdown": "I sadly run out all my submissions today because of this error. I added an exception statement inside a loop in case there is any error, it will be replaced by empty list for both axes and empty string for chart type. Could anyone please take a look on the code below and also the image of the csv file generated from the test dataset (5 images) and tell me what I did wrong? I highly appreciate your time. \n\n\n```python\ndata = []\n\nfor image, label in image_pred_lbls:\n    try:\n          #...\n         # lines of code\n         #....\n          data.append({\n            'id': name[:-4]+'_x',\n            'data_series': x_values,\n            'chart_type': mapping[lbl]\n             })\n\n           data.append({\n            'id': name[:-4]+'_y',\n            'data_series': y_values,\n            'chart_type': mapping[lbl]\n           })\n    except Exception as e: # <------------- exception\n        traceback.print_exc()\n        data.append({\n                'id': name[:-4]+'_x',\n                'data_series': [],  #<---------- empty list\n                'chart_type': ' '   #<---------- empty string\n            })\n\n        data.append({\n                'id': name[:-4]+'_y',\n                'data_series': [],\n                'chart_type': ' '\n            })\n\n\n#------------------------- after the loop -------------\npredictions = pd.DataFrame(data).set_index('id')\n\ndata = []\n\nfor index, row in predictions.iterrows():\n    data.append({\n        'id': index,\n        'data_series': ';'.join(map(str, row['data_series'])),\n        'chart_type': row['chart_type']\n    })\n\ndf = pd.DataFrame(data)\ndf.to_csv('submission.csv', index=False)\n```\n\n![image](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F14946445%2Fa55fd122f77cf7f693682b654ac2cb37%2F1.PNG?generation=1687106893202884&alt=media)",
      "votes": null
    },
    {
      "id": "2308407",
      "postDate": "06/18/2023 22:51:51",
      "content": "<p>AFAIK, your lists can not be empty. Replace those with [0,0]</p>",
      "rawMarkdown": "AFAIK, your lists can not be empty. Replace those with [0,0]",
      "votes": null
    },
    {
      "id": "2308498",
      "postDate": "06/19/2023 02:58:54",
      "content": "<p>Instead of using an empty list for both axes in the exception statement, it might be better to use [0,0] for the y-axis and [a,b] for the x-axis. This is because even if you have a single prediction [1], using an empty list will return NaN while scoring.</p>",
      "rawMarkdown": "Instead of using an empty list for both axes in the exception statement, it might be better to use [0,0] for the y-axis and [a,b] for the x-axis. This is because even if you have a single prediction [1], using an empty list will return NaN while scoring.",
      "votes": null
    },
    {
      "id": "2308582",
      "postDate": "06/19/2023 04:58:56",
      "content": "<p>Based on the given values of x and y lists, I should set the chart-type to 'line' since x is ['a','b'] which is string and y is [0,0], right?</p>",
      "rawMarkdown": "Based on the given values of x and y lists, I should set the chart-type to 'line' since x is ['a','b'] which is string and y is [0,0], right?",
      "votes": null
    },
    {
      "id": "2308587",
      "postDate": "06/19/2023 05:02:22",
      "content": "<p>yes, that would work</p>",
      "rawMarkdown": "yes, that would work",
      "votes": null
    },
    {
      "id": "2308589",
      "postDate": "06/19/2023 05:05:16",
      "content": "<p>Thank you so much <a href=\"https://www.kaggle.com/aravind36\" target=\"_blank\">@aravind36</a> I wish you the best in this competition. </p>",
      "rawMarkdown": "Thank you so much @aravind36 I wish you the best in this competition.",
      "votes": null
    },
    {
      "id": "2308672",
      "postDate": "06/19/2023 06:14:37",
      "content": "<p>Thank you <a href=\"https://www.kaggle.com/mayukh18\" target=\"_blank\">@mayukh18</a> , I will replace them with zeros. </p>",
      "rawMarkdown": "Thank you @mayukh18 , I will replace them with zeros.",
      "votes": null
    },
    {
      "id": "2308678",
      "postDate": "06/19/2023 06:24:03",
      "content": "<p><a href=\"https://www.kaggle.com/mayukh18\" target=\"_blank\">@mayukh18</a> &amp; <a href=\"https://www.kaggle.com/aravind36\" target=\"_blank\">@aravind36</a> I have a follow-up question, please. Imagine your loop goes without any error but your algorithm returns an empty list of x-ticks because it could not read the x values or any other reason. What values should I fill the x list? Do you think I should fill it based on the chart type, e.g., if scatter, then x_list = [0,0], if dot, x_list=['0','0'].  Or it does not matter because at the end it will be stored in csv file and everything will be string. What do you think?</p>",
      "rawMarkdown": "mayukh18 & @aravind36 I have a follow-up question, please. Imagine your loop goes without any error but your algorithm returns an empty list of x-ticks because it could not read the x values or any other reason. What values should I fill the x list? Do you think I should fill it based on the chart type, e.g., if scatter, then x_list = [0,0], if dot, x_list=['0','0'].  Or it does not matter because at the end it will be stored in csv file and everything will be string. What do you think?",
      "votes": null
    },
    {
      "id": "2308736",
      "postDate": "06/19/2023 07:10:07",
      "content": "<p>Everything should ultimately be converted into string so you have to convert the [0,0] to the correct output string format at the end. Check the sample submission files for reference.</p>",
      "rawMarkdown": "Everything should ultimately be converted into string so you have to convert the [0,0] to the correct output string format at the end. Check the sample submission files for reference.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 2308407,
      "author_name": "mayukh18",
      "author_url": "",
      "post_date": "06/18/2023 22:51:51",
      "content": "<p>AFAIK, your lists can not be empty. Replace those with [0,0]</p>",
      "votes": null,
      "replies": [
        {
          "id": 2308672,
          "author_name": "hamzahabduljalil",
          "author_url": "",
          "post_date": "06/19/2023 06:14:37",
          "content": "<p>Thank you <a href=\"https://www.kaggle.com/mayukh18\" target=\"_blank\">@mayukh18</a> , I will replace them with zeros. </p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 2308678,
          "author_name": "hamzahabduljalil",
          "author_url": "",
          "post_date": "06/19/2023 06:24:03",
          "content": "<p><a href=\"https://www.kaggle.com/mayukh18\" target=\"_blank\">@mayukh18</a> &amp; <a href=\"https://www.kaggle.com/aravind36\" target=\"_blank\">@aravind36</a> I have a follow-up question, please. Imagine your loop goes without any error but your algorithm returns an empty list of x-ticks because it could not read the x values or any other reason. What values should I fill the x list? Do you think I should fill it based on the chart type, e.g., if scatter, then x_list = [0,0], if dot, x_list=['0','0'].  Or it does not matter because at the end it will be stored in csv file and everything will be string. What do you think?</p>",
          "votes": null,
          "replies": [
            {
              "id": 2308736,
              "author_name": "mayukh18",
              "author_url": "",
              "post_date": "06/19/2023 07:10:07",
              "content": "<p>Everything should ultimately be converted into string so you have to convert the [0,0] to the correct output string format at the end. Check the sample submission files for reference.</p>",
              "votes": null,
              "replies": []
            }
          ]
        }
      ]
    },
    {
      "id": 2308498,
      "author_name": "aravind36",
      "author_url": "",
      "post_date": "06/19/2023 02:58:54",
      "content": "<p>Instead of using an empty list for both axes in the exception statement, it might be better to use [0,0] for the y-axis and [a,b] for the x-axis. This is because even if you have a single prediction [1], using an empty list will return NaN while scoring.</p>",
      "votes": null,
      "replies": [
        {
          "id": 2308582,
          "author_name": "hamzahabduljalil",
          "author_url": "",
          "post_date": "06/19/2023 04:58:56",
          "content": "<p>Based on the given values of x and y lists, I should set the chart-type to 'line' since x is ['a','b'] which is string and y is [0,0], right?</p>",
          "votes": null,
          "replies": [
            {
              "id": 2308587,
              "author_name": "aravind36",
              "author_url": "",
              "post_date": "06/19/2023 05:02:22",
              "content": "<p>yes, that would work</p>",
              "votes": null,
              "replies": [
                {
                  "id": 2308589,
                  "author_name": "hamzahabduljalil",
                  "author_url": "",
                  "post_date": "06/19/2023 05:05:16",
                  "content": "<p>Thank you so much <a href=\"https://www.kaggle.com/aravind36\" target=\"_blank\">@aravind36</a> I wish you the best in this competition. </p>",
                  "votes": null,
                  "replies": []
                }
              ]
            }
          ]
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "2308092": "I sadly run out all my submissions today because of this error. I added an exception statement inside a loop in case there is any error, it will be replaced by empty list for both axes and empty string for chart type. Could anyone please take a look on the code below and also the image of the csv file generated from the test dataset (5 images) and tell me what I did wrong? I highly appreciate your time. \n\n\n```python\ndata = []\n\nfor image, label in image_pred_lbls:\n    try:\n          #...\n         # lines of code\n         #....\n          data.append({\n            'id': name[:-4]+'_x',\n            'data_series': x_values,\n            'chart_type': mapping[lbl]\n             })\n\n           data.append({\n            'id': name[:-4]+'_y',\n            'data_series': y_values,\n            'chart_type': mapping[lbl]\n           })\n    except Exception as e: # <------------- exception\n        traceback.print_exc()\n        data.append({\n                'id': name[:-4]+'_x',\n                'data_series': [],  #<---------- empty list\n                'chart_type': ' '   #<---------- empty string\n            })\n\n        data.append({\n                'id': name[:-4]+'_y',\n                'data_series': [],\n                'chart_type': ' '\n            })\n\n\n#------------------------- after the loop -------------\npredictions = pd.DataFrame(data).set_index('id')\n\ndata = []\n\nfor index, row in predictions.iterrows():\n    data.append({\n        'id': index,\n        'data_series': ';'.join(map(str, row['data_series'])),\n        'chart_type': row['chart_type']\n    })\n\ndf = pd.DataFrame(data)\ndf.to_csv('submission.csv', index=False)\n```\n\n![image](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F14946445%2Fa55fd122f77cf7f693682b654ac2cb37%2F1.PNG?generation=1687106893202884&alt=media)",
    "2308407": "AFAIK, your lists can not be empty. Replace those with [0,0]",
    "2308498": "Instead of using an empty list for both axes in the exception statement, it might be better to use [0,0] for the y-axis and [a,b] for the x-axis. This is because even if you have a single prediction [1], using an empty list will return NaN while scoring.",
    "2308582": "Based on the given values of x and y lists, I should set the chart-type to 'line' since x is ['a','b'] which is string and y is [0,0], right?",
    "2308587": "yes, that would work",
    "2308589": "Thank you so much @aravind36 I wish you the best in this competition.",
    "2308672": "Thank you @mayukh18 , I will replace them with zeros.",
    "2308678": "mayukh18 & @aravind36 I have a follow-up question, please. Imagine your loop goes without any error but your algorithm returns an empty list of x-ticks because it could not read the x values or any other reason. What values should I fill the x list? Do you think I should fill it based on the chart type, e.g., if scatter, then x_list = [0,0], if dot, x_list=['0','0'].  Or it does not matter because at the end it will be stored in csv file and everything will be string. What do you think?",
    "2308736": "Everything should ultimately be converted into string so you have to convert the [0,0] to the correct output string format at the end. Check the sample submission files for reference."
  },
  "source": "meta"
}