{
  "id": 105790,
  "title": "Help needed in doing K-fold CV right",
  "url": "/competitions/aptos2019-blindness-detection/discussion/105790",
  "author_name": "",
  "post_date": "2019-08-26T12:41:47.292141300Z",
  "votes": 1,
  "comment_count": 9,
  "views": 0,
  "content": "<p>Hi all,</p>\n\n<p>A beginner here.. Trying to understand how K-fold CV should be used in computer vision problems. Do you guys train a model with different folds just to evaluate the model and finally train with whole data to get final predictions? If yes, how would you fix number of epochs for the final training since we can't early stop/pick min loss since validation data is not there?</p>\n\n<p>Or is it like train with k folds and average predictions of k folds?</p>\n\n<p>Thanks in advance.</p>",
  "messages": [
    {
      "id": "608173",
      "postDate": "08/26/2019 12:41:47",
      "content": "<p>Hi all,</p>\n\n<p>A beginner here.. Trying to understand how K-fold CV should be used in computer vision problems. Do you guys train a model with different folds just to evaluate the model and finally train with whole data to get final predictions? If yes, how would you fix number of epochs for the final training since we can't early stop/pick min loss since validation data is not there?</p>\n\n<p>Or is it like train with k folds and average predictions of k folds?</p>\n\n<p>Thanks in advance.</p>",
      "rawMarkdown": "Hi all,\n\nA beginner here.. Trying to understand how K-fold CV should be used in computer vision problems. Do you guys train a model with different folds just to evaluate the model and finally train with whole data to get final predictions? If yes, how would you fix number of epochs for the final training since we can't early stop/pick min loss since validation data is not there?\n\nOr is it like train with k folds and average predictions of k folds?\n\nThanks in advance.",
      "votes": null
    },
    {
      "id": "608197",
      "postDate": "08/26/2019 13:36:28",
      "content": "<ol>\n<li></li>\n</ol>",
      "rawMarkdown": "2.",
      "votes": null
    },
    {
      "id": "608231",
      "postDate": "08/26/2019 14:13:45",
      "content": "<p><img src=\"https://scikit-learn.org/stable/_images/grid_search_cross_validation.png\" alt=\"K-fold\"></p>",
      "rawMarkdown": "![K-fold](https://scikit-learn.org/stable/_images/grid_search_cross_validation.png)",
      "votes": null
    },
    {
      "id": "608232",
      "postDate": "08/26/2019 14:17:46",
      "content": "<p>Thanks <a href=\"/simakov\">@simakov</a> .. So the first approach doesn't make sense in this case?</p>",
      "rawMarkdown": "Thanks @simakov .. So the first approach doesn't make sense in this case?",
      "votes": null
    },
    {
      "id": "608240",
      "postDate": "08/26/2019 14:32:11",
      "content": "<p>I think, early stopping and bagging are more important than the bigger training set in this case. </p>",
      "rawMarkdown": "I think, early stopping and bagging are more important than the bigger training set in this case.",
      "votes": null
    },
    {
      "id": "608314",
      "postDate": "08/26/2019 16:04:34",
      "content": "<p>Hi JM100, we continue with the same weights for the next split after we are done with the previous/current split right ?</p>",
      "rawMarkdown": "Hi JM100, we continue with the same weights for the next split after we are done with the previous/current split right ?",
      "votes": null
    },
    {
      "id": "608327",
      "postDate": "08/26/2019 16:20:42",
      "content": "<p><a href=\"/vaibhargava\">@vaibhargava</a>, no, this strategy leads to a target leak: your validation set in the current step have been used for training model in the previous step. So, the model is overfits and the validation score is higher than should be. So, you should reset weights for every split.</p>",
      "rawMarkdown": "vaibhargava, no, this strategy leads to a target leak: your validation set in the current step have been used for training model in the previous step. So, the model is overfits and the validation score is higher than should be. So, you should reset weights for every split.",
      "votes": null
    },
    {
      "id": "608360",
      "postDate": "08/26/2019 17:00:08",
      "content": "<p>Thank you. So, I should go with the parameters which had the best performance with regards to the validation set in anyone of the split of the k-fold ?</p>",
      "rawMarkdown": "Thank you. So, I should go with the parameters which had the best performance with regards to the validation set in anyone of the split of the k-fold ?",
      "votes": null
    },
    {
      "id": "610426",
      "postDate": "08/28/2019 19:36:59",
      "content": "<p>you should go with the parameters which give the best CV score. That means the parameters that make the model generalize better overall the (Splits) folds</p>",
      "rawMarkdown": "you should go with the parameters which give the best CV score. That means the parameters that make the model generalize better overall the (Splits) folds",
      "votes": null
    },
    {
      "id": "616313",
      "postDate": "09/03/2019 01:55:43",
      "content": "<p>Good ,  Also a beginner here. do you guys can share a K-fold code ,I have try other tricks on my model except K-fold.</p>",
      "rawMarkdown": "Good ,  Also a beginner here. do you guys can share a K-fold code ,I have try other tricks on my model except K-fold.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 608197,
      "author_name": "simakov",
      "author_url": "",
      "post_date": "08/26/2019 13:36:28",
      "content": "<ol>\n<li></li>\n</ol>",
      "votes": null,
      "replies": [
        {
          "id": 608232,
          "author_name": "jayasoo",
          "author_url": "",
          "post_date": "08/26/2019 14:17:46",
          "content": "<p>Thanks <a href=\"/simakov\">@simakov</a> .. So the first approach doesn't make sense in this case?</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 608240,
          "author_name": "simakov",
          "author_url": "",
          "post_date": "08/26/2019 14:32:11",
          "content": "<p>I think, early stopping and bagging are more important than the bigger training set in this case. </p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 608231,
      "author_name": "jmourad100",
      "author_url": "",
      "post_date": "08/26/2019 14:13:45",
      "content": "<p><img src=\"https://scikit-learn.org/stable/_images/grid_search_cross_validation.png\" alt=\"K-fold\"></p>",
      "votes": null,
      "replies": [
        {
          "id": 608314,
          "author_name": "vaibhargava",
          "author_url": "",
          "post_date": "08/26/2019 16:04:34",
          "content": "<p>Hi JM100, we continue with the same weights for the next split after we are done with the previous/current split right ?</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 608327,
          "author_name": "simakov",
          "author_url": "",
          "post_date": "08/26/2019 16:20:42",
          "content": "<p><a href=\"/vaibhargava\">@vaibhargava</a>, no, this strategy leads to a target leak: your validation set in the current step have been used for training model in the previous step. So, the model is overfits and the validation score is higher than should be. So, you should reset weights for every split.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 608360,
          "author_name": "vaibhargava",
          "author_url": "",
          "post_date": "08/26/2019 17:00:08",
          "content": "<p>Thank you. So, I should go with the parameters which had the best performance with regards to the validation set in anyone of the split of the k-fold ?</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 610426,
          "author_name": "jmourad100",
          "author_url": "",
          "post_date": "08/28/2019 19:36:59",
          "content": "<p>you should go with the parameters which give the best CV score. That means the parameters that make the model generalize better overall the (Splits) folds</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 616313,
          "author_name": "chopinforest1986",
          "author_url": "",
          "post_date": "09/03/2019 01:55:43",
          "content": "<p>Good ,  Also a beginner here. do you guys can share a K-fold code ,I have try other tricks on my model except K-fold.</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "608173": "Hi all,\n\nA beginner here.. Trying to understand how K-fold CV should be used in computer vision problems. Do you guys train a model with different folds just to evaluate the model and finally train with whole data to get final predictions? If yes, how would you fix number of epochs for the final training since we can't early stop/pick min loss since validation data is not there?\n\nOr is it like train with k folds and average predictions of k folds?\n\nThanks in advance.",
    "608197": "2.",
    "608231": "![K-fold](https://scikit-learn.org/stable/_images/grid_search_cross_validation.png)",
    "608232": "Thanks @simakov .. So the first approach doesn't make sense in this case?",
    "608240": "I think, early stopping and bagging are more important than the bigger training set in this case.",
    "608314": "Hi JM100, we continue with the same weights for the next split after we are done with the previous/current split right ?",
    "608327": "vaibhargava, no, this strategy leads to a target leak: your validation set in the current step have been used for training model in the previous step. So, the model is overfits and the validation score is higher than should be. So, you should reset weights for every split.",
    "608360": "Thank you. So, I should go with the parameters which had the best performance with regards to the validation set in anyone of the split of the k-fold ?",
    "610426": "you should go with the parameters which give the best CV score. That means the parameters that make the model generalize better overall the (Splits) folds",
    "616313": "Good ,  Also a beginner here. do you guys can share a K-fold code ,I have try other tricks on my model except K-fold."
  },
  "source": "meta"
}