{
  "id": 262074,
  "title": "8th place solution",
  "url": "/competitions/google-smartphone-decimeter-challenge/writeups/micha-stolarczyk-8th-place-solution",
  "author_name": "",
  "post_date": "2021-08-05T18:01:03.893Z",
  "votes": 20,
  "comment_count": 1,
  "views": 0,
  "content": "<h2>Reproduced baseline</h2>\n<p>As my initial predictions I used approach similar to the one described <a href=\"https://www.kaggle.com/c/google-smartphone-decimeter-challenge/discussion/238583\" target=\"_blank\">in this discussion</a> with one additional trick. I fitted WLS a few times, each time removing measurements with the biggest residuals. My reproduced baseline had slightly better CV score than the one provided by the host.</p>\n<h2>Improving baseline using relative positions</h2>\n<p>This part consisted of three steps:</p>\n<ul>\n<li>I computed velocities in ENU coordinate system between consecutive timestamps using Acummulated Delta Range, pseudoragnes, sattelite positions and reproduced baseline. After that, I removed outliers and applied smoothing to predictions</li>\n<li>Then I trained convolutional neural network using velocities from previous step, IMU data and baseline, which also predicted velocities in ENU coordinates. Model achieved mean absolute error around 0.25m/s .</li>\n<li>As a last step, I applied Weighted Least Squares to combine relative predictions with data from derived files. For each timestamp it solved the following optimization problem</li>\n</ul>\n<p>$$  argmin_{x, b_{-k}, …, b_k}  \\sum_{i=-k}^k \\sum_{j=1}^{n_i} w_{ij} (|| s_{ij} - \\Delta x_i - x|| + b_i -p_{ij})^2 $$</p>\n<p>where </p>\n<ul>\n<li>\\( k \\) - parameter controlling size of the window. </li>\n<li>\\( x \\) - phone position at timestamp \\( t \\)</li>\n<li>\\( b_i \\) - phone clock bias at timestamp \\( t + i \\)</li>\n<li>\\( n_i \\) - number of pseudorange measurements at timestamp \\( t + i \\)</li>\n<li>\\( w_{ij} \\) - inverse of \\( j \\)-th pseudorange measurement uncertainty multiplied by \\( 1 + 0.25|i| \\) </li>\n<li>\\( s_{ij} \\) - \\( j \\)-th satellite position at timestamp \\( t + i \\) </li>\n<li>\\( \\Delta x_{i} \\) - model's prediction of relative position between timestamp  \\( t + i \\) and \\( t \\) </li>\n<li>\\( p_{ij} \\) - corrected \\( j \\)-th pseudorange measurement at timestamp \\( t + i \\)</li>\n</ul>\n<p>Parameter \\( k = 10 \\) worked best for me, so the window size was 21. This model had 24 unknowns - 3 for position and 1 for clock bias for each timestamp.  It had 6 times more parameters than WLS for single timestamp, but 21 times more measurements. The downside was, that any errors in relative positions affected performance of this solution.</p>\n<h2>Improving baseline in downtown area</h2>\n<p>As all the road segments from downtown areas in the test data were also present in ground truth data, I applied the following algorithm for each timestamp:</p>\n<ul>\n<li>select all points from ground truth file closer to the baseline prediction than 30 meters - let's call them candidate points</li>\n<li>for each candidate point \\( x_j \\) estimate clock bias: \\( b_j = \\mathrm{median}_i ( || s_i - x_j || - p_i ) \\)</li>\n<li>find \\( k \\) points with the lowest values of <br>\n$$  \\sum_{i=1}^{n} w_i | || s_i - x_j || - b_i - p_i | $$<br>\nand return their medoid.</li>\n</ul>\n<p>It was important to use median instead of mean to compute clock bias and to use absolute value of residuals instead of squares, because it helped with very noisy measurements in downtown area.</p>\n<h2>Postprocessing</h2>\n<p>After that, I applied the following steps to improve predictions:</p>\n<ul>\n<li>Error correction model - it predicted the difference between current predictions and ground truth. It was simple 1D Conv Neural Network. Features for this model were based on current predictions and imu.</li>\n<li>Aggregating predictions when speed is zero.</li>\n<li>Aggregating predictions from different phones.</li>\n</ul>",
  "messages": [
    {
      "id": "1452691",
      "postDate": "08/05/2021 17:08:42",
      "content": "<h2>Reproduced baseline</h2>\n<p>As my initial predictions I used approach similar to the one described <a href=\"https://www.kaggle.com/c/google-smartphone-decimeter-challenge/discussion/238583\" target=\"_blank\">in this discussion</a> with one additional trick. I fitted WLS a few times, each time removing measurements with the biggest residuals. My reproduced baseline had slightly better CV score than the one provided by the host.</p>\n<h2>Improving baseline using relative positions</h2>\n<p>This part consisted of three steps:</p>\n<ul>\n<li>I computed velocities in ENU coordinate system between consecutive timestamps using Acummulated Delta Range, pseudoragnes, sattelite positions and reproduced baseline. After that, I removed outliers and applied smoothing to predictions</li>\n<li>Then I trained convolutional neural network using velocities from previous step, IMU data and baseline, which also predicted velocities in ENU coordinates. Model achieved mean absolute error around 0.25m/s .</li>\n<li>As a last step, I applied Weighted Least Squares to combine relative predictions with data from derived files. For each timestamp it solved the following optimization problem</li>\n</ul>\n<p>$$  argmin_{x, b_{-k}, …, b_k}  \\sum_{i=-k}^k \\sum_{j=1}^{n_i} w_{ij} (|| s_{ij} - \\Delta x_i - x|| + b_i -p_{ij})^2 $$</p>\n<p>where </p>\n<ul>\n<li>\\( k \\) - parameter controlling size of the window. </li>\n<li>\\( x \\) - phone position at timestamp \\( t \\)</li>\n<li>\\( b_i \\) - phone clock bias at timestamp \\( t + i \\)</li>\n<li>\\( n_i \\) - number of pseudorange measurements at timestamp \\( t + i \\)</li>\n<li>\\( w_{ij} \\) - inverse of \\( j \\)-th pseudorange measurement uncertainty multiplied by \\( 1 + 0.25|i| \\) </li>\n<li>\\( s_{ij} \\) - \\( j \\)-th satellite position at timestamp \\( t + i \\) </li>\n<li>\\( \\Delta x_{i} \\) - model's prediction of relative position between timestamp  \\( t + i \\) and \\( t \\) </li>\n<li>\\( p_{ij} \\) - corrected \\( j \\)-th pseudorange measurement at timestamp \\( t + i \\)</li>\n</ul>\n<p>Parameter \\( k = 10 \\) worked best for me, so the window size was 21. This model had 24 unknowns - 3 for position and 1 for clock bias for each timestamp.  It had 6 times more parameters than WLS for single timestamp, but 21 times more measurements. The downside was, that any errors in relative positions affected performance of this solution.</p>\n<h2>Improving baseline in downtown area</h2>\n<p>As all the road segments from downtown areas in the test data were also present in ground truth data, I applied the following algorithm for each timestamp:</p>\n<ul>\n<li>select all points from ground truth file closer to the baseline prediction than 30 meters - let's call them candidate points</li>\n<li>for each candidate point \\( x_j \\) estimate clock bias: \\( b_j = \\mathrm{median}_i ( || s_i - x_j || - p_i ) \\)</li>\n<li>find \\( k \\) points with the lowest values of <br>\n$$  \\sum_{i=1}^{n} w_i | || s_i - x_j || - b_i - p_i | $$<br>\nand return their medoid.</li>\n</ul>\n<p>It was important to use median instead of mean to compute clock bias and to use absolute value of residuals instead of squares, because it helped with very noisy measurements in downtown area.</p>\n<h2>Postprocessing</h2>\n<p>After that, I applied the following steps to improve predictions:</p>\n<ul>\n<li>Error correction model - it predicted the difference between current predictions and ground truth. It was simple 1D Conv Neural Network. Features for this model were based on current predictions and imu.</li>\n<li>Aggregating predictions when speed is zero.</li>\n<li>Aggregating predictions from different phones.</li>\n</ul>",
      "rawMarkdown": "##  Reproduced baseline\n\nAs my initial predictions I used approach similar to the one described [in this discussion](https://www.kaggle.com/c/google-smartphone-decimeter-challenge/discussion/238583) with one additional trick. I fitted WLS a few times, each time removing measurements with the biggest residuals. My reproduced baseline had slightly better CV score than the one provided by the host.\n\n## Improving baseline using relative positions\n\nThis part consisted of three steps:\n* I computed velocities in ENU coordinate system between consecutive timestamps using Acummulated Delta Range, pseudoragnes, sattelite positions and reproduced baseline. After that, I removed outliers and applied smoothing to predictions\n*  Then I trained convolutional neural network using velocities from previous step, IMU data and baseline, which also predicted velocities in ENU coordinates. Model achieved mean absolute error around 0.25m/s .\n* As a last step, I applied Weighted Least Squares to combine relative predictions with data from derived files. For each timestamp it solved the following optimization problem\n\n$$  argmin_{x, b_{-k}, ..., b_k}  \\sum_{i=-k}^k \\sum_{j=1}^{n_i} w_{ij} (|| s_{ij} - \\Delta x_i - x|| + b_i -p_{ij})^2 $$\n\nwhere \n* \\\\( k \\\\) - parameter controlling size of the window. \n* \\\\( x \\\\) - phone position at timestamp \\\\( t \\\\)\n* \\\\( b_i \\\\) - phone clock bias at timestamp \\\\( t + i \\\\)\n* \\\\( n_i \\\\) - number of pseudorange measurements at timestamp \\\\( t + i \\\\)\n* \\\\( w_{ij} \\\\) - inverse of \\\\( j \\\\)-th pseudorange measurement uncertainty multiplied by \\\\( 1 + 0.25|i| \\\\) \n* \\\\( s_{ij} \\\\) - \\\\( j \\\\)-th satellite position at timestamp \\\\( t + i \\\\) \n* \\\\( \\Delta x_{i} \\\\) - model's prediction of relative position between timestamp  \\\\( t + i \\\\) and \\\\( t \\\\) \n* \\\\( p_{ij} \\\\) - corrected \\\\( j \\\\)-th pseudorange measurement at timestamp \\\\( t + i \\\\)\n\nParameter \\\\( k = 10 \\\\) worked best for me, so the window size was 21. This model had 24 unknowns - 3 for position and 1 for clock bias for each timestamp.  It had 6 times more parameters than WLS for single timestamp, but 21 times more measurements. The downside was, that any errors in relative positions affected performance of this solution.\n\n## Improving baseline in downtown area\n\nAs all the road segments from downtown areas in the test data were also present in ground truth data, I applied the following algorithm for each timestamp:\n* select all points from ground truth file closer to the baseline prediction than 30 meters - let's call them candidate points\n* for each candidate point \\\\( x_j \\\\) estimate clock bias: \\\\( b_j = \\mathrm{median}_i ( || s_i - x_j || - p_i ) \\\\)\n* find \\\\( k \\\\) points with the lowest values of \n$$  \\sum_{i=1}^{n} w_i | || s_i - x_j || - b_i - p_i | $$\nand return their medoid.\n\nIt was important to use median instead of mean to compute clock bias and to use absolute value of residuals instead of squares, because it helped with very noisy measurements in downtown area.\n\n\n## Postprocessing\n\nAfter that, I applied the following steps to improve predictions:\n* Error correction model - it predicted the difference between current predictions and ground truth. It was simple 1D Conv Neural Network. Features for this model were based on current predictions and imu.\n* Aggregating predictions when speed is zero.\n* Aggregating predictions from different phones.",
      "votes": null
    },
    {
      "id": "1458777",
      "postDate": "08/08/2021 04:30:02",
      "content": "<p>Thanks for sharing your approach <a href=\"https://www.kaggle.com/michalstolarczyk\" target=\"_blank\">@michalstolarczyk</a> </p>",
      "rawMarkdown": "Thanks for sharing your approach @michalstolarczyk",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1458777,
      "author_name": "jarupula",
      "author_url": "",
      "post_date": "08/08/2021 04:30:02",
      "content": "<p>Thanks for sharing your approach <a href=\"https://www.kaggle.com/michalstolarczyk\" target=\"_blank\">@michalstolarczyk</a> </p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1452691": "##  Reproduced baseline\n\nAs my initial predictions I used approach similar to the one described [in this discussion](https://www.kaggle.com/c/google-smartphone-decimeter-challenge/discussion/238583) with one additional trick. I fitted WLS a few times, each time removing measurements with the biggest residuals. My reproduced baseline had slightly better CV score than the one provided by the host.\n\n## Improving baseline using relative positions\n\nThis part consisted of three steps:\n* I computed velocities in ENU coordinate system between consecutive timestamps using Acummulated Delta Range, pseudoragnes, sattelite positions and reproduced baseline. After that, I removed outliers and applied smoothing to predictions\n*  Then I trained convolutional neural network using velocities from previous step, IMU data and baseline, which also predicted velocities in ENU coordinates. Model achieved mean absolute error around 0.25m/s .\n* As a last step, I applied Weighted Least Squares to combine relative predictions with data from derived files. For each timestamp it solved the following optimization problem\n\n$$  argmin_{x, b_{-k}, ..., b_k}  \\sum_{i=-k}^k \\sum_{j=1}^{n_i} w_{ij} (|| s_{ij} - \\Delta x_i - x|| + b_i -p_{ij})^2 $$\n\nwhere \n* \\\\( k \\\\) - parameter controlling size of the window. \n* \\\\( x \\\\) - phone position at timestamp \\\\( t \\\\)\n* \\\\( b_i \\\\) - phone clock bias at timestamp \\\\( t + i \\\\)\n* \\\\( n_i \\\\) - number of pseudorange measurements at timestamp \\\\( t + i \\\\)\n* \\\\( w_{ij} \\\\) - inverse of \\\\( j \\\\)-th pseudorange measurement uncertainty multiplied by \\\\( 1 + 0.25|i| \\\\) \n* \\\\( s_{ij} \\\\) - \\\\( j \\\\)-th satellite position at timestamp \\\\( t + i \\\\) \n* \\\\( \\Delta x_{i} \\\\) - model's prediction of relative position between timestamp  \\\\( t + i \\\\) and \\\\( t \\\\) \n* \\\\( p_{ij} \\\\) - corrected \\\\( j \\\\)-th pseudorange measurement at timestamp \\\\( t + i \\\\)\n\nParameter \\\\( k = 10 \\\\) worked best for me, so the window size was 21. This model had 24 unknowns - 3 for position and 1 for clock bias for each timestamp.  It had 6 times more parameters than WLS for single timestamp, but 21 times more measurements. The downside was, that any errors in relative positions affected performance of this solution.\n\n## Improving baseline in downtown area\n\nAs all the road segments from downtown areas in the test data were also present in ground truth data, I applied the following algorithm for each timestamp:\n* select all points from ground truth file closer to the baseline prediction than 30 meters - let's call them candidate points\n* for each candidate point \\\\( x_j \\\\) estimate clock bias: \\\\( b_j = \\mathrm{median}_i ( || s_i - x_j || - p_i ) \\\\)\n* find \\\\( k \\\\) points with the lowest values of \n$$  \\sum_{i=1}^{n} w_i | || s_i - x_j || - b_i - p_i | $$\nand return their medoid.\n\nIt was important to use median instead of mean to compute clock bias and to use absolute value of residuals instead of squares, because it helped with very noisy measurements in downtown area.\n\n\n## Postprocessing\n\nAfter that, I applied the following steps to improve predictions:\n* Error correction model - it predicted the difference between current predictions and ground truth. It was simple 1D Conv Neural Network. Features for this model were based on current predictions and imu.\n* Aggregating predictions when speed is zero.\n* Aggregating predictions from different phones.",
    "1458777": "Thanks for sharing your approach @michalstolarczyk"
  },
  "source": "meta"
}