{
  "id": 22026,
  "title": "Optimal Number of Neighbors",
  "url": "/competitions/facebook-v-predicting-check-ins/discussion/22026",
  "author_name": "",
  "post_date": "2016-07-04T02:23:29.433Z",
  "votes": null,
  "comment_count": 5,
  "views": 520,
  "content": "<p>If I find the optimal number of neighbors with a holdout set of 20%, should I scale this by 1.25 when submitting to the leaderboard similar to how number of rounds scales when using xgboost? Or is this parameter independent of the size of the dataset?</p>",
  "messages": [
    {
      "id": "125886",
      "postDate": "07/04/2016 02:23:29",
      "content": "<p>If I find the optimal number of neighbors with a holdout set of 20%, should I scale this by 1.25 when submitting to the leaderboard similar to how number of rounds scales when using xgboost? Or is this parameter independent of the size of the dataset?</p>",
      "rawMarkdown": "If I find the optimal number of neighbors with a holdout set of 20%, should I scale this by 1.25 when submitting to the leaderboard similar to how number of rounds scales when using xgboost? Or is this parameter independent of the size of the dataset?",
      "votes": null
    },
    {
      "id": "125889",
      "postDate": "07/04/2016 03:23:29",
      "content": "<p>Hi, Jared, I want to say yes on this if I guess you question correctly. I think you can split your train data to three pieces by time to validate you question.</p>",
      "rawMarkdown": "Hi, Jared, I want to say yes on this if I guess you question correctly. I think you can split your train data to three pieces by time to validate you question.",
      "votes": null
    },
    {
      "id": "125908",
      "postDate": "07/04/2016 09:14:14",
      "content": "<p>I would say that this does not have a straightforward answer (such as '1.25'), since most of times the correct value of the k parameter depends on the local density of the data - which is not necessarily the same as the amount of data you have.</p>\n\n<p>Validation should be your friend here.</p>",
      "rawMarkdown": "I would say that this does not have a straightforward answer (such as '1.25'), since most of times the correct value of the k parameter depends on the local density of the data - which is not necessarily the same as the amount of data you have.\r\n\r\nValidation should be your friend here.",
      "votes": null
    },
    {
      "id": "125922",
      "postDate": "07/04/2016 14:23:58",
      "content": "<p>@Jared:  An empirical rule-of-thumb popularized by the &quot;Pattern Classification&quot; book by Duda et al. K equal to the square root of the number of instances, so no, it is not independent of the size of the dataset.</p>",
      "rawMarkdown": "Jared:  An empirical rule-of-thumb popularized by the \"Pattern Classification\" book by Duda et al. K equal to the square root of the number of instances, so no, it is not independent of the size of the dataset.",
      "votes": null
    },
    {
      "id": "125950",
      "postDate": "07/04/2016 22:26:08",
      "content": "<p>[quote=Alex;125922]</p>\n\n<p>@Jared:  An empirical rule-of-thumb popularized by the &quot;Pattern Classification&quot; book by Duda et al. K equal to the square root of the number of instances, so no, it is not independent of the size of the dataset.</p>\n\n<p>[/quote]</p>\n\n<p>Thanks. It makes sense that it would scale but not linearly.</p>",
      "rawMarkdown": "[quote=Alex;125922]\r\n\r\n@Jared:  An empirical rule-of-thumb popularized by the \"Pattern Classification\" book by Duda et al. K equal to the square root of the number of instances, so no, it is not independent of the size of the dataset.\r\n\r\n[/quote]\r\n\r\nThanks. It makes sense that it would scale but not linearly.",
      "votes": null
    },
    {
      "id": "125976",
      "postDate": "07/05/2016 07:19:06",
      "content": "<p>I noticed the later versions of grid knn set K for each grid based on the number of observations:</p>\n\n<p>cte = 5.8\n    n_neighbors = int((y.size ** 0.5) / cte)</p>\n\n<p>So this has a scaling factor of 1/5.8 as a multiplier to the square root of the number of instances.  I don't know where the value for cte comes from.  If its just an optimized parameter, that may also need to be tweaked.</p>",
      "rawMarkdown": "I noticed the later versions of grid knn set K for each grid based on the number of observations:\r\n\r\ncte = 5.8\r\n    n_neighbors = int((y.size ** 0.5) / cte)\r\n\r\nSo this has a scaling factor of 1/5.8 as a multiplier to the square root of the number of instances.  I don't know where the value for cte comes from.  If its just an optimized parameter, that may also need to be tweaked.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 125889,
      "author_name": "weizhezhang",
      "author_url": "",
      "post_date": "07/04/2016 03:23:29",
      "content": "<p>Hi, Jared, I want to say yes on this if I guess you question correctly. I think you can split your train data to three pieces by time to validate you question.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 125908,
      "author_name": "carrdelling",
      "author_url": "",
      "post_date": "07/04/2016 09:14:14",
      "content": "<p>I would say that this does not have a straightforward answer (such as '1.25'), since most of times the correct value of the k parameter depends on the local density of the data - which is not necessarily the same as the amount of data you have.</p>\n\n<p>Validation should be your friend here.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 125922,
      "author_name": "drarfc",
      "author_url": "",
      "post_date": "07/04/2016 14:23:58",
      "content": "<p>@Jared:  An empirical rule-of-thumb popularized by the &quot;Pattern Classification&quot; book by Duda et al. K equal to the square root of the number of instances, so no, it is not independent of the size of the dataset.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 125950,
      "author_name": "jturkewitz",
      "author_url": "",
      "post_date": "07/04/2016 22:26:08",
      "content": "<p>[quote=Alex;125922]</p>\n\n<p>@Jared:  An empirical rule-of-thumb popularized by the &quot;Pattern Classification&quot; book by Duda et al. K equal to the square root of the number of instances, so no, it is not independent of the size of the dataset.</p>\n\n<p>[/quote]</p>\n\n<p>Thanks. It makes sense that it would scale but not linearly.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 125976,
      "author_name": "datadave",
      "author_url": "",
      "post_date": "07/05/2016 07:19:06",
      "content": "<p>I noticed the later versions of grid knn set K for each grid based on the number of observations:</p>\n\n<p>cte = 5.8\n    n_neighbors = int((y.size ** 0.5) / cte)</p>\n\n<p>So this has a scaling factor of 1/5.8 as a multiplier to the square root of the number of instances.  I don't know where the value for cte comes from.  If its just an optimized parameter, that may also need to be tweaked.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "125886": "If I find the optimal number of neighbors with a holdout set of 20%, should I scale this by 1.25 when submitting to the leaderboard similar to how number of rounds scales when using xgboost? Or is this parameter independent of the size of the dataset?",
    "125889": "Hi, Jared, I want to say yes on this if I guess you question correctly. I think you can split your train data to three pieces by time to validate you question.",
    "125908": "I would say that this does not have a straightforward answer (such as '1.25'), since most of times the correct value of the k parameter depends on the local density of the data - which is not necessarily the same as the amount of data you have.\r\n\r\nValidation should be your friend here.",
    "125922": "Jared:  An empirical rule-of-thumb popularized by the \"Pattern Classification\" book by Duda et al. K equal to the square root of the number of instances, so no, it is not independent of the size of the dataset.",
    "125950": "[quote=Alex;125922]\r\n\r\n@Jared:  An empirical rule-of-thumb popularized by the \"Pattern Classification\" book by Duda et al. K equal to the square root of the number of instances, so no, it is not independent of the size of the dataset.\r\n\r\n[/quote]\r\n\r\nThanks. It makes sense that it would scale but not linearly.",
    "125976": "I noticed the later versions of grid knn set K for each grid based on the number of observations:\r\n\r\ncte = 5.8\r\n    n_neighbors = int((y.size ** 0.5) / cte)\r\n\r\nSo this has a scaling factor of 1/5.8 as a multiplier to the square root of the number of instances.  I don't know where the value for cte comes from.  If its just an optimized parameter, that may also need to be tweaked."
  },
  "source": "meta"
}