{
  "id": 440857,
  "title": "Validation strategy",
  "url": "/competitions/child-mind-institute-detect-sleep-states/discussion/440857",
  "author_name": "",
  "post_date": "2023-09-16T13:02:48.407195100Z",
  "votes": 4,
  "comment_count": 5,
  "views": 0,
  "content": "<p>Hello everyone, what is your validation strategy?</p>\n<p>I have gone through this <a href=\"https://www.kaggle.com/code/carlmcbrideellis/zzzs-playing-with-the-competition-metric\" target=\"_blank\">notebook</a> by <a href=\"https://www.kaggle.com/carlmcbrideellis\" target=\"_blank\">@carlmcbrideellis</a> and tried something like this</p>\n<blockquote>\n  <p>solution = pd.read_parquet(TR_FILE, columns=[\"series_id\", \"step\", \"awake\"],filters=[(\"series_id\", \"in\", test_series)])<br>\n  solution = solution.rename(columns={\"awake\": \"event\"})<br>\n  solution[\"event\"] = solution[\"event\"].replace({1: \"onset\",0: \"wakeup\"})</p>\n  <p>tolerances = {<br>\n       \"onset\":  [12, 36, 60, 90, 120, 150, 180, 240, 300, 360],<br>\n       \"wakeup\": [12, 36, 60, 90, 120, 150, 180, 240, 300, 360],<br>\n  }</p>\n  <p>series_id_column_name = \"series_id\"<br>\n  time_column_name = \"step\"<br>\n  event_column_name = \"event\"<br>\n  score_column_name = \"score\"<br>\n  use_scoring_intervals = None</p>\n  <p>print(event_detection_ap(solution, sub, tolerances))</p>\n</blockquote>\n<p>where sub is my model predictions, I am getting less than 0.1 but public leaderboard score is around 0.25, is there something I am missing here?</p>",
  "messages": [
    {
      "id": "2441798",
      "postDate": "09/16/2023 13:02:48",
      "content": "<p>Hello everyone, what is your validation strategy?</p>\n<p>I have gone through this <a href=\"https://www.kaggle.com/code/carlmcbrideellis/zzzs-playing-with-the-competition-metric\" target=\"_blank\">notebook</a> by <a href=\"https://www.kaggle.com/carlmcbrideellis\" target=\"_blank\">@carlmcbrideellis</a> and tried something like this</p>\n<blockquote>\n  <p>solution = pd.read_parquet(TR_FILE, columns=[\"series_id\", \"step\", \"awake\"],filters=[(\"series_id\", \"in\", test_series)])<br>\n  solution = solution.rename(columns={\"awake\": \"event\"})<br>\n  solution[\"event\"] = solution[\"event\"].replace({1: \"onset\",0: \"wakeup\"})</p>\n  <p>tolerances = {<br>\n       \"onset\":  [12, 36, 60, 90, 120, 150, 180, 240, 300, 360],<br>\n       \"wakeup\": [12, 36, 60, 90, 120, 150, 180, 240, 300, 360],<br>\n  }</p>\n  <p>series_id_column_name = \"series_id\"<br>\n  time_column_name = \"step\"<br>\n  event_column_name = \"event\"<br>\n  score_column_name = \"score\"<br>\n  use_scoring_intervals = None</p>\n  <p>print(event_detection_ap(solution, sub, tolerances))</p>\n</blockquote>\n<p>where sub is my model predictions, I am getting less than 0.1 but public leaderboard score is around 0.25, is there something I am missing here?</p>",
      "rawMarkdown": "Hello everyone, what is your validation strategy?\n\nI have gone through this [notebook](https://www.kaggle.com/code/carlmcbrideellis/zzzs-playing-with-the-competition-metric) by @carlmcbrideellis and tried something like this\n\n>solution = pd.read_parquet(TR_FILE, columns=[\"series_id\", \"step\", \"awake\"],filters=[(\"series_id\", \"in\", test_series)])\nsolution = solution.rename(columns={\"awake\": \"event\"})\nsolution[\"event\"] = solution[\"event\"].replace({1: \"onset\",0: \"wakeup\"})\n\n> tolerances = {\n     \"onset\":  [12, 36, 60, 90, 120, 150, 180, 240, 300, 360],\n     \"wakeup\": [12, 36, 60, 90, 120, 150, 180, 240, 300, 360],\n}\n\n>series_id_column_name = \"series_id\"\ntime_column_name = \"step\"\nevent_column_name = \"event\"\nscore_column_name = \"score\"\nuse_scoring_intervals = None\n\n>print(event_detection_ap(solution, sub, tolerances))\n\nwhere sub is my model predictions, I am getting less than 0.1 but public leaderboard score is around 0.25, is there something I am missing here?",
      "votes": null
    },
    {
      "id": "2442360",
      "postDate": "09/17/2023 00:25:51",
      "content": "<p>Hi <a href=\"https://www.kaggle.com/anilreddyvv\" target=\"_blank\">@anilreddyvv</a> , what is <code>TR_FILE</code> in your code? Is it the path of the train series?</p>\n<p>If so, please note that the score we get in public LB is evaluated with the hidden test set, not the train set or dummy test set one.</p>",
      "rawMarkdown": "Hi @anilreddyvv , what is `TR_FILE` in your code? Is it the path of the train series?\n\nIf so, please note that the score we get in public LB is evaluated with the hidden test set, not the train set or dummy test set one.",
      "votes": null
    },
    {
      "id": "2442549",
      "postDate": "09/17/2023 05:37:15",
      "content": "<p>Yes, I am aware that scoring is on hidden test data. But the question is why is model score on validation data (used some series purely for validating the model) is very less compared to hidden test data? Am I using the scoring function incorrectly or is there an actual problem in the model?</p>",
      "rawMarkdown": "Yes, I am aware that scoring is on hidden test data. But the question is why is model score on validation data (used some series purely for validating the model) is very less compared to hidden test data? Am I using the scoring function incorrectly or is there an actual problem in the model?",
      "votes": null
    },
    {
      "id": "2443327",
      "postDate": "09/17/2023 16:49:21",
      "content": "<p>Since the data is actually a time series, could it be better if we take the last T-steps window for each series as the validation data? Just like how the time-series CV split is done</p>",
      "rawMarkdown": "Since the data is actually a time series, could it be better if we take the last T-steps window for each series as the validation data? Just like how the time-series CV split is done",
      "votes": null
    },
    {
      "id": "2443342",
      "postDate": "09/17/2023 16:54:06",
      "content": "<p>I mean, something like this, but done in each series ID</p>\n<p><img src=\"https://i.stack.imgur.com/Q37Bn.png\" alt=\"Time series CV\"></p>",
      "rawMarkdown": "I mean, something like this, but done in each series ID\n\n![Time series CV](https://i.stack.imgur.com/Q37Bn.png)",
      "votes": null
    },
    {
      "id": "2444516",
      "postDate": "09/18/2023 10:07:11",
      "content": "<p>It might be useful in  a way, but I feel measuring performance on completely new series_id (on which model is not trained) would be more appropriate</p>",
      "rawMarkdown": "It might be useful in  a way, but I feel measuring performance on completely new series_id (on which model is not trained) would be more appropriate",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 2442360,
      "author_name": "rimbax",
      "author_url": "",
      "post_date": "09/17/2023 00:25:51",
      "content": "<p>Hi <a href=\"https://www.kaggle.com/anilreddyvv\" target=\"_blank\">@anilreddyvv</a> , what is <code>TR_FILE</code> in your code? Is it the path of the train series?</p>\n<p>If so, please note that the score we get in public LB is evaluated with the hidden test set, not the train set or dummy test set one.</p>",
      "votes": null,
      "replies": [
        {
          "id": 2442549,
          "author_name": "anilreddyvv",
          "author_url": "",
          "post_date": "09/17/2023 05:37:15",
          "content": "<p>Yes, I am aware that scoring is on hidden test data. But the question is why is model score on validation data (used some series purely for validating the model) is very less compared to hidden test data? Am I using the scoring function incorrectly or is there an actual problem in the model?</p>",
          "votes": null,
          "replies": [
            {
              "id": 2443327,
              "author_name": "rimbax",
              "author_url": "",
              "post_date": "09/17/2023 16:49:21",
              "content": "<p>Since the data is actually a time series, could it be better if we take the last T-steps window for each series as the validation data? Just like how the time-series CV split is done</p>",
              "votes": null,
              "replies": []
            },
            {
              "id": 2443342,
              "author_name": "rimbax",
              "author_url": "",
              "post_date": "09/17/2023 16:54:06",
              "content": "<p>I mean, something like this, but done in each series ID</p>\n<p><img src=\"https://i.stack.imgur.com/Q37Bn.png\" alt=\"Time series CV\"></p>",
              "votes": null,
              "replies": [
                {
                  "id": 2444516,
                  "author_name": "anilreddyvv",
                  "author_url": "",
                  "post_date": "09/18/2023 10:07:11",
                  "content": "<p>It might be useful in  a way, but I feel measuring performance on completely new series_id (on which model is not trained) would be more appropriate</p>",
                  "votes": null,
                  "replies": []
                }
              ]
            }
          ]
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "2441798": "Hello everyone, what is your validation strategy?\n\nI have gone through this [notebook](https://www.kaggle.com/code/carlmcbrideellis/zzzs-playing-with-the-competition-metric) by @carlmcbrideellis and tried something like this\n\n>solution = pd.read_parquet(TR_FILE, columns=[\"series_id\", \"step\", \"awake\"],filters=[(\"series_id\", \"in\", test_series)])\nsolution = solution.rename(columns={\"awake\": \"event\"})\nsolution[\"event\"] = solution[\"event\"].replace({1: \"onset\",0: \"wakeup\"})\n\n> tolerances = {\n     \"onset\":  [12, 36, 60, 90, 120, 150, 180, 240, 300, 360],\n     \"wakeup\": [12, 36, 60, 90, 120, 150, 180, 240, 300, 360],\n}\n\n>series_id_column_name = \"series_id\"\ntime_column_name = \"step\"\nevent_column_name = \"event\"\nscore_column_name = \"score\"\nuse_scoring_intervals = None\n\n>print(event_detection_ap(solution, sub, tolerances))\n\nwhere sub is my model predictions, I am getting less than 0.1 but public leaderboard score is around 0.25, is there something I am missing here?",
    "2442360": "Hi @anilreddyvv , what is `TR_FILE` in your code? Is it the path of the train series?\n\nIf so, please note that the score we get in public LB is evaluated with the hidden test set, not the train set or dummy test set one.",
    "2442549": "Yes, I am aware that scoring is on hidden test data. But the question is why is model score on validation data (used some series purely for validating the model) is very less compared to hidden test data? Am I using the scoring function incorrectly or is there an actual problem in the model?",
    "2443327": "Since the data is actually a time series, could it be better if we take the last T-steps window for each series as the validation data? Just like how the time-series CV split is done",
    "2443342": "I mean, something like this, but done in each series ID\n\n![Time series CV](https://i.stack.imgur.com/Q37Bn.png)",
    "2444516": "It might be useful in  a way, but I feel measuring performance on completely new series_id (on which model is not trained) would be more appropriate"
  },
  "source": "meta"
}