{
  "id": 239905,
  "title": "10th Place Rapids cuML Solution Quick Writeup",
  "url": "/competitions/indoor-location-navigation/writeups/cuml-10th-place-rapids-cuml-solution-quick-writeup",
  "author_name": "",
  "post_date": "2021-05-18T02:19:51.659393500Z",
  "votes": 39,
  "comment_count": 4,
  "views": 0,
  "content": "<p>This is a long and hard competition! I'd like to congratulate all the teams who stick to it till the end. I am looking forward to the sharing of winning solutions.</p>\n<p>My main goal of this competition is to experiment with <a href=\"https://rapids.ai/start.html\" target=\"_blank\">Rapids.ai</a> tools to accelerate the pre-processing and post-processing of deep learning models. </p>\n<p>Pre-processing:</p>\n<ul>\n<li>use <code>dask</code> to process raw data, convert them to dataframes and save them as <code>parquets</code>.</li>\n<li>use <code>dask-cudf</code> to engineer features from many small <code>parquets</code>. </li>\n<li>use <code>cuml LabelEncoder, TargetEncoder, Nearest Neighbor</code> and <code>Xgboost</code> to create simple models and explore the dataset.</li>\n</ul>\n<p>Model:<br>\nI built two RNNs using PyTorch Lightning:</p>\n<ul>\n<li>use wifi features to predict the waypoints directly. </li>\n<li>use IMU features to predict the shift of waypoints, <code>delta x &amp; y</code>. similar to <a href=\"https://www.kaggle.com/c/indoor-location-navigation/discussion/239884\" target=\"_blank\">Olaf's approach</a></li>\n</ul>\n<p>Post-processing:<br>\nThe approach is to interleave <a href=\"https://www.kaggle.com/saitodevel01/indoor-post-processing-by-cost-minimization\" target=\"_blank\">cost minimization</a>, <a href=\"https://www.kaggle.com/rafaelcartenet/scaled-floors-geojsons-new-dataset\" target=\"_blank\">snap to corridor</a> and <a href=\"https://www.kaggle.com/robikscube/indoor-navigation-snap-to-grid-post-processing\" target=\"_blank\">snap to grid</a> and run them iteratively. Hyperparameters such as <code>alpha</code> in <code>cost minimization</code>, <code>threshold</code> in <code>snap grid</code> are tuned for each iteration. I rewrote these functions with <code>cupy</code> and <code>cudf</code> and they were very fast. My best submission is done with 30 iterations and 90 post-processing functions in total, which only took less than 10 minutes. I didn't do the exact measurements but that could be 100x faster than the original implementation. The speedup is very important for searching for the best hyperparameters. The post-processing improves the score by 1.1~1.2, which is quite significant.</p>\n<p>Other notes:<br>\nI didn't use the start/end points leak and the hand-labeled waypoints. I spent a lot of time creating an end-to-end neural network that incorporates <code>cost minimization</code> and <code>snap to grids</code> in the training process but it didn't go anywhere in the end. I'm looking forward to the approach of the 1st place team who successfully built an end-to-end model.</p>\n<p>Unfortunately, I am way behind in my other workloads so I apologize that my solution and source code will be shared later when I find the time. I'll update this thread when it's done.</p>",
  "messages": [
    {
      "id": "1312356",
      "postDate": "05/18/2021 02:19:51",
      "content": "<p>This is a long and hard competition! I'd like to congratulate all the teams who stick to it till the end. I am looking forward to the sharing of winning solutions.</p>\n<p>My main goal of this competition is to experiment with <a href=\"https://rapids.ai/start.html\" target=\"_blank\">Rapids.ai</a> tools to accelerate the pre-processing and post-processing of deep learning models. </p>\n<p>Pre-processing:</p>\n<ul>\n<li>use <code>dask</code> to process raw data, convert them to dataframes and save them as <code>parquets</code>.</li>\n<li>use <code>dask-cudf</code> to engineer features from many small <code>parquets</code>. </li>\n<li>use <code>cuml LabelEncoder, TargetEncoder, Nearest Neighbor</code> and <code>Xgboost</code> to create simple models and explore the dataset.</li>\n</ul>\n<p>Model:<br>\nI built two RNNs using PyTorch Lightning:</p>\n<ul>\n<li>use wifi features to predict the waypoints directly. </li>\n<li>use IMU features to predict the shift of waypoints, <code>delta x &amp; y</code>. similar to <a href=\"https://www.kaggle.com/c/indoor-location-navigation/discussion/239884\" target=\"_blank\">Olaf's approach</a></li>\n</ul>\n<p>Post-processing:<br>\nThe approach is to interleave <a href=\"https://www.kaggle.com/saitodevel01/indoor-post-processing-by-cost-minimization\" target=\"_blank\">cost minimization</a>, <a href=\"https://www.kaggle.com/rafaelcartenet/scaled-floors-geojsons-new-dataset\" target=\"_blank\">snap to corridor</a> and <a href=\"https://www.kaggle.com/robikscube/indoor-navigation-snap-to-grid-post-processing\" target=\"_blank\">snap to grid</a> and run them iteratively. Hyperparameters such as <code>alpha</code> in <code>cost minimization</code>, <code>threshold</code> in <code>snap grid</code> are tuned for each iteration. I rewrote these functions with <code>cupy</code> and <code>cudf</code> and they were very fast. My best submission is done with 30 iterations and 90 post-processing functions in total, which only took less than 10 minutes. I didn't do the exact measurements but that could be 100x faster than the original implementation. The speedup is very important for searching for the best hyperparameters. The post-processing improves the score by 1.1~1.2, which is quite significant.</p>\n<p>Other notes:<br>\nI didn't use the start/end points leak and the hand-labeled waypoints. I spent a lot of time creating an end-to-end neural network that incorporates <code>cost minimization</code> and <code>snap to grids</code> in the training process but it didn't go anywhere in the end. I'm looking forward to the approach of the 1st place team who successfully built an end-to-end model.</p>\n<p>Unfortunately, I am way behind in my other workloads so I apologize that my solution and source code will be shared later when I find the time. I'll update this thread when it's done.</p>",
      "rawMarkdown": "This is a long and hard competition! I'd like to congratulate all the teams who stick to it till the end. I am looking forward to the sharing of winning solutions.\n\nMy main goal of this competition is to experiment with [Rapids.ai](https://rapids.ai/start.html) tools to accelerate the pre-processing and post-processing of deep learning models. \n\nPre-processing:\n- use `dask` to process raw data, convert them to dataframes and save them as `parquets`.\n- use `dask-cudf` to engineer features from many small `parquets`. \n- use `cuml LabelEncoder, TargetEncoder, Nearest Neighbor` and `Xgboost` to create simple models and explore the dataset.\n\nModel:\nI built two RNNs using PyTorch Lightning:\n- use wifi features to predict the waypoints directly. \n- use IMU features to predict the shift of waypoints, `delta x & y`. similar to [Olaf's approach](https://www.kaggle.com/c/indoor-location-navigation/discussion/239884)\n\nPost-processing:\nThe approach is to interleave [cost minimization](https://www.kaggle.com/saitodevel01/indoor-post-processing-by-cost-minimization), [snap to corridor] (https://www.kaggle.com/rafaelcartenet/scaled-floors-geojsons-new-dataset) and [snap to grid](https://www.kaggle.com/robikscube/indoor-navigation-snap-to-grid-post-processing) and run them iteratively. Hyperparameters such as `alpha` in `cost minimization`, `threshold` in `snap grid` are tuned for each iteration. I rewrote these functions with `cupy` and `cudf` and they were very fast. My best submission is done with 30 iterations and 90 post-processing functions in total, which only took less than 10 minutes. I didn't do the exact measurements but that could be 100x faster than the original implementation. The speedup is very important for searching for the best hyperparameters. The post-processing improves the score by 1.1~1.2, which is quite significant.\n\nOther notes:\nI didn't use the start/end points leak and the hand-labeled waypoints. I spent a lot of time creating an end-to-end neural network that incorporates `cost minimization` and `snap to grids` in the training process but it didn't go anywhere in the end. I'm looking forward to the approach of the 1st place team who successfully built an end-to-end model.\n\nUnfortunately, I am way behind in my other workloads so I apologize that my solution and source code will be shared later when I find the time. I'll update this thread when it's done.",
      "votes": null
    },
    {
      "id": "1314125",
      "postDate": "05/19/2021 01:03:11",
      "content": "<p>Awesome work <a href=\"https://www.kaggle.com/jiweiliu\" target=\"_blank\">@jiweiliu</a> - you were a strong competitor in the competition from day 1, it was fun seeing you consistently at the top of the leaderboard.</p>\n<blockquote>\n  <p>I rewrote these functions with cupy and cudf and they were very fast. My best submission is done with 30 iterations and 90 post-processing functions in total, which only took less than 10 minutes.</p>\n</blockquote>\n<p>That is very impressive. Will you be sharing the code?</p>",
      "rawMarkdown": "Awesome work @jiweiliu - you were a strong competitor in the competition from day 1, it was fun seeing you consistently at the top of the leaderboard.\n\n> I rewrote these functions with cupy and cudf and they were very fast. My best submission is done with 30 iterations and 90 post-processing functions in total, which only took less than 10 minutes.\n\nThat is very impressive. Will you be sharing the code?",
      "votes": null
    },
    {
      "id": "1314538",
      "postDate": "05/19/2021 08:11:24",
      "content": "<p>yes, I will. Please give me some time to clean the code (and I might be able to make it even faster) and measure the speedup. I'll update this thread :)</p>",
      "rawMarkdown": "yes, I will. Please give me some time to clean the code (and I might be able to make it even faster) and measure the speedup. I'll update this thread :)",
      "votes": null
    },
    {
      "id": "1314541",
      "postDate": "05/19/2021 08:14:24",
      "content": "<p>A quick tip is to avoid using python <code>for</code> loops as much as possible. For snap-to-grid we can calculate all-to-all distances using numpy/cupy broadcast in one shot. For cost-minimization, we can connect paths into one long sequence and set the <code>beta</code> at the boundaries to zero. I'd like to do some further optimization to remove <code>for</code> loops completely for these two functions. </p>",
      "rawMarkdown": "A quick tip is to avoid using python `for` loops as much as possible. For snap-to-grid we can calculate all-to-all distances using numpy/cupy broadcast in one shot. For cost-minimization, we can connect paths into one long sequence and set the `beta` at the boundaries to zero. I'd like to do some further optimization to remove `for` loops completely for these two functions.",
      "votes": null
    },
    {
      "id": "1314544",
      "postDate": "05/19/2021 08:15:21",
      "content": "<p>Thank you again for posting the great kernel. It's elegant and so insightful.</p>",
      "rawMarkdown": "Thank you again for posting the great kernel. It's elegant and so insightful.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1314125,
      "author_name": "robikscube",
      "author_url": "",
      "post_date": "05/19/2021 01:03:11",
      "content": "<p>Awesome work <a href=\"https://www.kaggle.com/jiweiliu\" target=\"_blank\">@jiweiliu</a> - you were a strong competitor in the competition from day 1, it was fun seeing you consistently at the top of the leaderboard.</p>\n<blockquote>\n  <p>I rewrote these functions with cupy and cudf and they were very fast. My best submission is done with 30 iterations and 90 post-processing functions in total, which only took less than 10 minutes.</p>\n</blockquote>\n<p>That is very impressive. Will you be sharing the code?</p>",
      "votes": null,
      "replies": [
        {
          "id": 1314538,
          "author_name": "jiweiliu",
          "author_url": "",
          "post_date": "05/19/2021 08:11:24",
          "content": "<p>yes, I will. Please give me some time to clean the code (and I might be able to make it even faster) and measure the speedup. I'll update this thread :)</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1314541,
          "author_name": "jiweiliu",
          "author_url": "",
          "post_date": "05/19/2021 08:14:24",
          "content": "<p>A quick tip is to avoid using python <code>for</code> loops as much as possible. For snap-to-grid we can calculate all-to-all distances using numpy/cupy broadcast in one shot. For cost-minimization, we can connect paths into one long sequence and set the <code>beta</code> at the boundaries to zero. I'd like to do some further optimization to remove <code>for</code> loops completely for these two functions. </p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1314544,
          "author_name": "jiweiliu",
          "author_url": "",
          "post_date": "05/19/2021 08:15:21",
          "content": "<p>Thank you again for posting the great kernel. It's elegant and so insightful.</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "1312356": "This is a long and hard competition! I'd like to congratulate all the teams who stick to it till the end. I am looking forward to the sharing of winning solutions.\n\nMy main goal of this competition is to experiment with [Rapids.ai](https://rapids.ai/start.html) tools to accelerate the pre-processing and post-processing of deep learning models. \n\nPre-processing:\n- use `dask` to process raw data, convert them to dataframes and save them as `parquets`.\n- use `dask-cudf` to engineer features from many small `parquets`. \n- use `cuml LabelEncoder, TargetEncoder, Nearest Neighbor` and `Xgboost` to create simple models and explore the dataset.\n\nModel:\nI built two RNNs using PyTorch Lightning:\n- use wifi features to predict the waypoints directly. \n- use IMU features to predict the shift of waypoints, `delta x & y`. similar to [Olaf's approach](https://www.kaggle.com/c/indoor-location-navigation/discussion/239884)\n\nPost-processing:\nThe approach is to interleave [cost minimization](https://www.kaggle.com/saitodevel01/indoor-post-processing-by-cost-minimization), [snap to corridor] (https://www.kaggle.com/rafaelcartenet/scaled-floors-geojsons-new-dataset) and [snap to grid](https://www.kaggle.com/robikscube/indoor-navigation-snap-to-grid-post-processing) and run them iteratively. Hyperparameters such as `alpha` in `cost minimization`, `threshold` in `snap grid` are tuned for each iteration. I rewrote these functions with `cupy` and `cudf` and they were very fast. My best submission is done with 30 iterations and 90 post-processing functions in total, which only took less than 10 minutes. I didn't do the exact measurements but that could be 100x faster than the original implementation. The speedup is very important for searching for the best hyperparameters. The post-processing improves the score by 1.1~1.2, which is quite significant.\n\nOther notes:\nI didn't use the start/end points leak and the hand-labeled waypoints. I spent a lot of time creating an end-to-end neural network that incorporates `cost minimization` and `snap to grids` in the training process but it didn't go anywhere in the end. I'm looking forward to the approach of the 1st place team who successfully built an end-to-end model.\n\nUnfortunately, I am way behind in my other workloads so I apologize that my solution and source code will be shared later when I find the time. I'll update this thread when it's done.",
    "1314125": "Awesome work @jiweiliu - you were a strong competitor in the competition from day 1, it was fun seeing you consistently at the top of the leaderboard.\n\n> I rewrote these functions with cupy and cudf and they were very fast. My best submission is done with 30 iterations and 90 post-processing functions in total, which only took less than 10 minutes.\n\nThat is very impressive. Will you be sharing the code?",
    "1314538": "yes, I will. Please give me some time to clean the code (and I might be able to make it even faster) and measure the speedup. I'll update this thread :)",
    "1314541": "A quick tip is to avoid using python `for` loops as much as possible. For snap-to-grid we can calculate all-to-all distances using numpy/cupy broadcast in one shot. For cost-minimization, we can connect paths into one long sequence and set the `beta` at the boundaries to zero. I'd like to do some further optimization to remove `for` loops completely for these two functions.",
    "1314544": "Thank you again for posting the great kernel. It's elegant and so insightful."
  },
  "source": "meta"
}