{
  "id": 329824,
  "title": "Tricks Used By The Winners Of Last Year's Competition",
  "url": "/competitions/smartphone-decimeter-2022/discussion/329824",
  "author_name": "The Devastator",
  "post_date": "2022-06-09T00:42:40.456000",
  "votes": 22,
  "comment_count": 0,
  "views": 0,
  "content": "<h1>Tricks Used By The Winners Of Last Year's Competition</h1>\n<h3><a href=\"https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/262406\" target=\"_blank\">1st place solution</a></h3>\n<p><strong>Key points of the solution:</strong></p>\n<ul>\n<li>Global optimization of position and velocity by Factor Graph Optimization Technique</li>\n<li>Velocity constraint by accumulated delta range（ADR）</li>\n<li>Absolute position constraint by differential pseudorange between a base station</li>\n<li>No machine learning</li>\n</ul>\n<p><strong>Input Data</strong></p>\n<ul>\n<li>Phone_Gnsslog.txt</li>\n<li>RINEX files of GNSS base station (I used Verizon base station data from here）</li>\n<li>Ground Truth（Downtown area only）</li>\n</ul>\n<p>Did not use Phone_derived.csv. There were some missing data in Phone_derived.csv files. So the author calculated the satellite position and velocity directly from the RINEX navigation file. Baseline position and IMU data are also not used.</p>\n<p><strong>Factor Graph Optimization</strong><br>\nFactor graphs are a class of graphical models in which there are variables and factors. The variables represent unknown quantities in the problem, and the factors represent functions on subsets of the variables. Edges in the factor graph are always between factors and variables, and indicate that a particular factor depends on a particular variable.<a href=\"https://gtsam.org/2020/06/01/factor-graphs.html\" target=\"_blank\">here</a></p>\n<p>The core of the approach was to use a global optimization method based on Factor Graph. Several optimization methods have been used, with good results. Factor graph optimization is a method that can apply a variety of complex nonlinear constraints and simultaneously optimize all state variables（the entire driving trajectory）. There are many outliers in the various constraints（edges in the graph）, but a robust optimization technique eliminates the need to manually set the outlier threshold parameters.</p>\n<p><strong>Factor Graph Structure</strong><br>\nThe author tried many different graph structures and finally performed Graph optimization using the following Factor graph.</p>\n<p><img src=\"https://user-images.githubusercontent.com/7933764/128525861-3b529b21-e5bb-49ca-8ca6-60229b4ade32.png\" alt=\"\"></p>\n<p>The graph node𝑋𝑖 presents the state variable of different moments, and the edge connecting two nodes presents the error function 𝑒(⋅); each edge corresponds to a single observation 𝑍𝑖. In the graph, error function 𝑒(⋅) represents probabilistic constraints applied to the state at the specified time-step. Optimization factor graph can be written as follows.</p>\n<p><img src=\"https://user-images.githubusercontent.com/7933764/128522724-ad708687-61ec-4416-b622-c972b451a8a0.png\" alt=\"\"></p>\n<p>Here, Ω𝑖 is the information matrix（inverse of covariance matrix）which determines the accuracy of the observation 𝑍𝑖. We defined the following as nodes（estimated states）of the graph.</p>\n<p><img src=\"https://user-images.githubusercontent.com/7933764/128524196-b6843c78-dfe3-4850-88ed-9fada7becea2.png\" alt=\"\"></p>\n<p><img src=\"https://user-images.githubusercontent.com/7933764/128524319-f1c6a8fe-0f7e-4417-b702-a9cf815aa466.png\" alt=\"\"></p>\n<p>where 𝑟 and 𝑟˙ is 3D position/velocity in earth-centered earth-fixed（ECEF）coordinate. 𝑡 and 𝑡˙ represent the receive clock bias and drift in each GNSS signals.</p>\n<p>Here, 𝑠 in the graph is a <a href=\"https://nikosuenderhauf.github.io/assets/papers/IROS12-switchableConstraints.pdf\" target=\"_blank\">switchable constraint</a>, which is a state that takes a variable between 0 and 1. The value of switchable constraint is estimated simultaneously by optimization. On the edge of an outlier, the switchable constraint is automatically optimized to 0 and acts like a weight for the observed value. The optimization problem can be described as follows.</p>\n<p><img src=\"https://user-images.githubusercontent.com/7933764/128525345-2cb74f7a-5a74-4fa4-8c30-1d73a0828ecf.png\" alt=\"\"></p>\n<p>where the last term in the above equation is the anchor factor of the switch to prevent the switch state from going to all zeros.</p>\n<p><strong>Pseudorange Factor</strong><br>\nIn the Pseudorange Factor, the observation is the difference between the pseudorange and the reference station's pseudorange, which removes the all bias error component in GNSS measurements（excluding multipath errors）. Theoretically, the residuals of the single differenced pseudorange have a Gaussian distribution with zero mean value if receiver clock error is compensated. This single-difference pseudorange improves the absolute position accuracy. Using this differential GNSS technique, the aurhor did not need any bias correction for the final position.</p>\n<p><strong>Doppler/ADR Factor</strong><br>\nThe pseudorange rate（Doppler shift）of the smartphone was noisier than the aurhor expected. Doppler factor is used instead only when the ADR factor is not available.</p>\n<p><strong>Motion Factor</strong><br>\nThe motion factor uses the estimated velocity and clock drift to add constraints between neighboring nodes. It simply adds a constraint so that the integral of the velocity and clock drift is equal to the difference between the neighboring states.</p>\n<p><strong>Pseudo-Position Factor</strong><br>\nThe pseudo-position factor was used only for the downtown area, and since the ground truth was traveling along the same path as the test data, the points on the ground truth path closest to the estimated trajectory were extracted and added to the graph as pseudo position constraints with appropriate covariance.</p>\n<h3><a href=\"https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/262355\" target=\"_blank\">3rd place solution</a></h3>\n<ul>\n<li>Have not used any complex algorithms.</li>\n<li>All the author used from the data is pseudo-ranges and deltas.</li>\n<li>In order to filter out the deltas, the author calculated the position offset to the next epoch, and left only those epochs that gave enough consistent satellites</li>\n<li>The main idea of the algorithm was that the positions that they get on the track must be in good agreement with the psevdoranges and deltas, in addition, they must satisfy certain physical laws.</li>\n<li>To do this, they built a tensorflow model that contained positions and time offsets as weights. Then they minimized the loss, which consisted of the sum satellite distance errors and the delta changes errors. Plus, they add penalty for unnecessary acceleration - to avoid trajectory wobbling.</li>\n</ul>\n<h3><a href=\"https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/262074\" target=\"_blank\">8th place solution</a></h3>\n<p><strong>Baseline Improvement</strong></p>\n<p>They computed velocities in ENU coordinate system between consecutive timestamps using Acummulated Delta Range, pseudoragnes, sattelite positions and reproduced baseline. After that, they removed outliers and applied smoothing to predictions<br>\nThen they 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 .<br>\nAs a last step, they applied Weighted Least Squares to combine relative predictions with data from derived files. For each timestamp it solved the following optimization problem<br>\nargmin_{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<br>\nwhere</p>\n<p>k - parameter controlling size of the window.<br>\nx - phone position at timestamp t<br>\nb_i - phone clock bias at timestamp t + i<br>\nn_i - number of pseudorange measurements at timestamp t + i<br>\nw_{ij} - inverse of j-th pseudorange measurement uncertainty multiplied by 1 + 0.25|i|<br>\ns_{ij} - j-th satellite position at timestamp t + i<br>\n\\Delta x_{i} - model's prediction of relative position between timestamp t + i and t<br>\np_{ij} - corrected j-th pseudorange measurement at timestamp t + i<br>\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.</p>\n<p><strong>Baseline Improvement in Downtown Area</strong><br>\nAs all the road segments from downtown areas in the test data were also present in ground truth data, they applied the following algorithm for each timestamp:</p>\n<p>select all points from ground truth file closer to the baseline prediction than 30 meters - let's call them candidate points<br>\nfor each candidate point x_j estimate clock bias: b_j = \\mathrm{median}<em>i ( || s_i - x_j || - p_i )\nfind k points with the lowest values of\n\\sum</em>{i=1}^{n} w_i | || s_i - x_j || - b_i - p_i |</p>\n<p>and return their medoid.<br>\nIt was important to use median instead of mean to compute clock bias and to use the absolute value of residuals instead of squares because it helped with very noisy measurements in the downtown area.</p>\n<p><strong>Postprocessing</strong><br>\nAfter that, they applied the following steps to improve predictions:</p>\n<p>Error correction model - it predicted the difference between current predictions and ground truth. It was a simple 1D Conv Neural Network. Features for this model were based on current predictions and imu.<br>\nAggregating predictions when speed is zero.<br>\nAggregating predictions from different phones.</p>\n<h3><a href=\"https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/261959\" target=\"_blank\">5th place solution</a></h3>\n<p><strong>Use of sensor data</strong><br>\nBased on acceleration, gyro, and geomagnetic sensors, I estimated vehicle orientation and acceleration and added acceleration and lateral velocity terms to the cost function of subsequent optimizations. This idea may have had a little effect after the introduction of velocity estimates.</p>\n<p><strong>Velocity estimation using doppler shift</strong><br>\nThe vehicle speed was estimated from the pseudo-range rate by the least-squares method and used for subsequent optimization-based smoothing.</p>\n<p><strong>Optimization-based smoothing</strong></p>\n<p>First, the dynamics of the vehicle is expressed by the following state equation.</p>\n<p><img src=\"https://user-images.githubusercontent.com/309785/128366897-369cc75b-46e9-419b-8f35-d0e884e9ff27.png\" alt=\"\"></p>\n<p>where 𝜙 and 𝜓 are latitude and longitude, respectively.</p>\n<p>Then, by vertically arranging the states 𝑋 and inputs, jerks, 𝑈 at each time, the equality constraints on state transitions can be described as follows,</p>\n<p>$$A X + B U = 0$$</p>\n<p>In addition, by determining the observation matrix 𝐶 according to the observation time based on Hermitian interpolation, the vector 𝑌, which is a vertical sequence of latitude and longitude at each observation time, can be written as follows,</p>\n<p>$$Y = C X$$</p>\n<p>The optimization evaluation function 𝐽 is set as the sum of the squares of the jerk 𝑈 and the position estimation error, as follows,</p>\n<p>$$J = U^T R U + (\\hat{Y} - C X)^T L (\\hat{Y} - C X)$$</p>\n<p>Finally, the position estimation is formulated as the following quadratic programming problem.</p>\n<p><img src=\"https://user-images.githubusercontent.com/309785/128366891-08f79ee0-881e-4a6a-b9a5-887270cc83fb.png\" alt=\"\"></p>\n<p>Based on this method, various information can be integrated by adding velocity error, acceleration error, cost related to lateral velocity, etc. to the cost function.</p>\n<p>The important point is to perform the above optimization by using the positions of all smartphones in one driving data at the same time. This method is clearly more accurate than the method of making estimates for each smartphone and calculating their average.</p>\n<h3><a href=\"https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/261904\" target=\"_blank\">6th Place Solution</a></h3>\n<p><strong>Preprocess</strong><br>\nThe author predicted anomalies (distance from ground truth) and speed from IMU data and lightGBM then replaced anomalies above a threshold with linearly interpolated values.</p>\n<p><strong>Kalman smoothing</strong><br>\nApplied two patterns of Linear Kalman Smoothing:</p>\n<ul>\n<li>Takes into account velocity, and the other takes into account acceleration (i.e. 4D and 6D).</li>\n<li>Since the interval of the observed values was not constant, replaced delta_t in the state transition matrix for each update step.</li>\n</ul>\n<p><strong>AccumulatedDeltaRange</strong></p>\n<p>Using the GNSS Analysis app from google, the author was able to obtain observations using the AccumulatedDeltaRange for some of the data.</p>\n<p>Implemented a forward hatch filter and a backward hatch filter and averaged them after applying Kaman smoothing.</p>\n<pre><code>   prev_smooth = lat_lngs[0]\n   res = [prev_smooth]\n   for raw, delta_adr, delta_t in zip(lat_lngs[1:, :], delta_adrs[1:, :], delta_ts[1:]):\n       if not all(np.isnan(delta_adr)):\n           smooth = 1 / M * raw + (M - 1) / M * (prev_smooth + delta_adr * delta_t)\n       else:\n           smooth = raw\n       prev_smooth = smooth\n       res.append(prev_smooth)\n  res = np.array(res)\n</code></pre>\n<ul>\n<li>The author then optimized the parameter M using GroupKFold for each area.</li>\n<li>There were many missing delta_adr values for some phones, so the authors filled them with values from other phones.</li>\n</ul>\n<p><strong>Weighted Phone Mean</strong><br>\nAfter applying the hatch filter, they weighted average latitude and longitude using the weights of the phone optimized by GroupKFold as well as M.<br>\nSome of the millisSinceGpsEpoch had a little gap depending on the phone, so the authors used linear interpolation to fill it.</p>\n<p><strong>Snap2grid</strong><br>\nIn the downtown area, the authors performed a discrete optimization using linearly interpolated ground truth.<br>\nTo prevent overfitting, the ground truth in itself was not included in the target to be snapped.<br>\nThe objective function is as follows, and they used a greedy search to find the optimal path.</p>\n<p>cost = distance2cur + distance2prev * alpha</p>\n<p><strong>Stay point mean</strong><br>\nUsing the predicted value of the speed of LightGBM, they took the average for points below the threshold.</p>\n<h3><a href=\"https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/261876\" target=\"_blank\">2nd place solution</a></h3>\n<p><strong>XGBoost stacked ensemble</strong><br>\nCorrected the PrMs using other device data, gives about 10-40 cm improved baseline. Used the trick: the amount of correction of PrM was used as weights in WLS algorithm</p>\n<p><strong>Computing Velocity</strong><br>\nTranslated WlsPvt.m from gps-measurement google tool in python using PseudorangeRateMetersPerSecond and the results was 0.08Mps mean average accurate. When the translation algorithm failed the author used the baseline speedMps</p>\n<p><strong>ADR relative position</strong><br>\nUsed derived files public version Android GPS tools.</p>\n<p><strong>Remove outliers</strong><br>\nUsed some outlier removal methods from public notebooks but also included: If there were two or more consecutive outliers remove and interpolate it.</p>\n<p><strong>Mixing signals from multiple devices</strong><br>\nIt turns out then median averaging is better than mean, also variance among all epochs was pretty similar so the author windowed signal (10-30 epochs adjusted by speed Category and region).</p>\n<p><strong>Mean By Stop</strong><br>\nUsed velocity Mps with threshold adjusted about 0.5-1.</p>\n<h3><a href=\"https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/261739\" target=\"_blank\">5th Place Solution</a></h3>\n<p><strong>kNNHeight</strong><br>\nThe author mapped the latitude and longitude from the ground truth to the correct altitude using KNN.</p>\n<p><strong>Outlier Detection</strong><br>\nThe author estimated what point to consider as an outlier using the relative coordinates of the surrounding about 50 seconds as a feature.</p>\n<p><strong>Postprocesses</strong></p>\n<p><strong>Relpos Outlier Detection</strong><br>\nDetects relative position outliers as well as absolute coordinates to improve accuracy.</p>\n<p><strong>KalmanFilter</strong><br>\nKalman filter considers relative and absolute positions.</p>\n<p><strong>SateliteMean</strong><br>\nAveraging phone with 1/(psuedorangesigma)**2 as weights</p>\n<p><strong>Snap to Grid</strong><br>\nIn SJC, the authors snap the prediction to the nearest neighbor of ground_truth.</p>\n<h3><a href=\"https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/261732\" target=\"_blank\">7th place solution</a></h3>\n<ol>\n<li>Baseline Improving<br>\nI have rebuilt the baseline based on this notebook.<br>\nFor isrbm, I used the median value for each phone-sat.</li>\n</ol>\n<p><strong>Satellite Selection</strong><br>\nExcluding satellites that were a source of error, from the least-squares calculation.<br>\nUse the elevation angle for filter condition: Signals from satellites with low elevation angles are excluded because they are strongly affected by various errors.</p>\n<p><strong>Carrier Smoothing</strong><br>\nPseudorange smoothing with Accumulated Delta Range (ADR).</p>\n<p><strong>Relative Position Estimation</strong></p>\n<p><strong>IMU Data</strong><br>\nRelative positions were missing in some places the author combined IMU sensor data and author used lightGBM with lag and rolling features of the IMU and vehicle velocity.</p>\n<p><strong>Excluding high-speed points</strong><br>\nExclude points that have a very large distance from the previous and next point.</p>\n<p>** Post-processing using Kalman Smoothing**<br>\nWas done in a public notebook, the author used it also.</p>\n<p><strong>Area Grouping</strong><br>\nThe author usewd KNN and implemented grouping based on the degree of path matching with the train where each collection was divided into five groups, and the hyperparameters and order of processing were adjusted for each group.</p>\n<h3><a href=\"https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/261774\" target=\"_blank\">18th Place Solution</a></h3>\n<ul>\n<li>Area Classification<br>\nThey automatically classified the collection into three categories as in the public version, and also defined a difficult area.<br>\nThe difficult area was defined as the area like the following.</li>\n</ul>\n<p><strong>Outlier Correction</strong><br>\n<a href=\"https://www.kaggle.com/dehokanta/baseline-post-processing-by-outlier-correction\" target=\"_blank\">notebook</a></p>\n<p><strong>Kalman Smoothing</strong><br>\nApplied linear interpolation to keep epoch width constant: <a href=\"https://www.kaggle.com/emaerthin/demonstration-of-the-kalman-filter\" target=\"_blank\">notebook</a></p>\n<p><strong>Phone Mean</strong><br>\n<a href=\"https://www.kaggle.com/t88take/gsdc-phones-mean-prediction\" target=\"_blank\">notebook 1</a><br>\n<a href=\"https://www.kaggle.com/bpetrb/adaptive-gauss-phone-mean\" target=\"_blank\">notebook 2</a></p>\n<p><strong>Phones Removal</strong><br>\n<a href=\"https://www.kaggle.com/columbia2131/device-eda-interpolate-by-removing-device-en-ja\" target=\"_blank\">notebook</a></p>\n<p><strong>Snap to Grid</strong><br>\nThey applied to snap to grid only downtown area and the difficult areas.</p>\n<p><strong>Position estimation by imu data</strong><br>\nRelative position correction was performed using IMU data for the only downtown area using LightGBM with GroupKFold(group=\"phone\") CV and the features(shift range is -30~30) &amp; aggregate features(mean, std, max, min, median, skew, kart).</p>",
  "messages": [
    {
      "id": 1815356,
      "postDate": "2022-06-09T00:42:40.457Z",
      "content": "<h1>Tricks Used By The Winners Of Last Year's Competition</h1>\n<h3><a href=\"https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/262406\" target=\"_blank\">1st place solution</a></h3>\n<p><strong>Key points of the solution:</strong></p>\n<ul>\n<li>Global optimization of position and velocity by Factor Graph Optimization Technique</li>\n<li>Velocity constraint by accumulated delta range（ADR）</li>\n<li>Absolute position constraint by differential pseudorange between a base station</li>\n<li>No machine learning</li>\n</ul>\n<p><strong>Input Data</strong></p>\n<ul>\n<li>Phone_Gnsslog.txt</li>\n<li>RINEX files of GNSS base station (I used Verizon base station data from here）</li>\n<li>Ground Truth（Downtown area only）</li>\n</ul>\n<p>Did not use Phone_derived.csv. There were some missing data in Phone_derived.csv files. So the author calculated the satellite position and velocity directly from the RINEX navigation file. Baseline position and IMU data are also not used.</p>\n<p><strong>Factor Graph Optimization</strong><br>\nFactor graphs are a class of graphical models in which there are variables and factors. The variables represent unknown quantities in the problem, and the factors represent functions on subsets of the variables. Edges in the factor graph are always between factors and variables, and indicate that a particular factor depends on a particular variable.<a href=\"https://gtsam.org/2020/06/01/factor-graphs.html\" target=\"_blank\">here</a></p>\n<p>The core of the approach was to use a global optimization method based on Factor Graph. Several optimization methods have been used, with good results. Factor graph optimization is a method that can apply a variety of complex nonlinear constraints and simultaneously optimize all state variables（the entire driving trajectory）. There are many outliers in the various constraints（edges in the graph）, but a robust optimization technique eliminates the need to manually set the outlier threshold parameters.</p>\n<p><strong>Factor Graph Structure</strong><br>\nThe author tried many different graph structures and finally performed Graph optimization using the following Factor graph.</p>\n<p><img src=\"https://user-images.githubusercontent.com/7933764/128525861-3b529b21-e5bb-49ca-8ca6-60229b4ade32.png\" alt=\"\"></p>\n<p>The graph node𝑋𝑖 presents the state variable of different moments, and the edge connecting two nodes presents the error function 𝑒(⋅); each edge corresponds to a single observation 𝑍𝑖. In the graph, error function 𝑒(⋅) represents probabilistic constraints applied to the state at the specified time-step. Optimization factor graph can be written as follows.</p>\n<p><img src=\"https://user-images.githubusercontent.com/7933764/128522724-ad708687-61ec-4416-b622-c972b451a8a0.png\" alt=\"\"></p>\n<p>Here, Ω𝑖 is the information matrix（inverse of covariance matrix）which determines the accuracy of the observation 𝑍𝑖. We defined the following as nodes（estimated states）of the graph.</p>\n<p><img src=\"https://user-images.githubusercontent.com/7933764/128524196-b6843c78-dfe3-4850-88ed-9fada7becea2.png\" alt=\"\"></p>\n<p><img src=\"https://user-images.githubusercontent.com/7933764/128524319-f1c6a8fe-0f7e-4417-b702-a9cf815aa466.png\" alt=\"\"></p>\n<p>where 𝑟 and 𝑟˙ is 3D position/velocity in earth-centered earth-fixed（ECEF）coordinate. 𝑡 and 𝑡˙ represent the receive clock bias and drift in each GNSS signals.</p>\n<p>Here, 𝑠 in the graph is a <a href=\"https://nikosuenderhauf.github.io/assets/papers/IROS12-switchableConstraints.pdf\" target=\"_blank\">switchable constraint</a>, which is a state that takes a variable between 0 and 1. The value of switchable constraint is estimated simultaneously by optimization. On the edge of an outlier, the switchable constraint is automatically optimized to 0 and acts like a weight for the observed value. The optimization problem can be described as follows.</p>\n<p><img src=\"https://user-images.githubusercontent.com/7933764/128525345-2cb74f7a-5a74-4fa4-8c30-1d73a0828ecf.png\" alt=\"\"></p>\n<p>where the last term in the above equation is the anchor factor of the switch to prevent the switch state from going to all zeros.</p>\n<p><strong>Pseudorange Factor</strong><br>\nIn the Pseudorange Factor, the observation is the difference between the pseudorange and the reference station's pseudorange, which removes the all bias error component in GNSS measurements（excluding multipath errors）. Theoretically, the residuals of the single differenced pseudorange have a Gaussian distribution with zero mean value if receiver clock error is compensated. This single-difference pseudorange improves the absolute position accuracy. Using this differential GNSS technique, the aurhor did not need any bias correction for the final position.</p>\n<p><strong>Doppler/ADR Factor</strong><br>\nThe pseudorange rate（Doppler shift）of the smartphone was noisier than the aurhor expected. Doppler factor is used instead only when the ADR factor is not available.</p>\n<p><strong>Motion Factor</strong><br>\nThe motion factor uses the estimated velocity and clock drift to add constraints between neighboring nodes. It simply adds a constraint so that the integral of the velocity and clock drift is equal to the difference between the neighboring states.</p>\n<p><strong>Pseudo-Position Factor</strong><br>\nThe pseudo-position factor was used only for the downtown area, and since the ground truth was traveling along the same path as the test data, the points on the ground truth path closest to the estimated trajectory were extracted and added to the graph as pseudo position constraints with appropriate covariance.</p>\n<h3><a href=\"https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/262355\" target=\"_blank\">3rd place solution</a></h3>\n<ul>\n<li>Have not used any complex algorithms.</li>\n<li>All the author used from the data is pseudo-ranges and deltas.</li>\n<li>In order to filter out the deltas, the author calculated the position offset to the next epoch, and left only those epochs that gave enough consistent satellites</li>\n<li>The main idea of the algorithm was that the positions that they get on the track must be in good agreement with the psevdoranges and deltas, in addition, they must satisfy certain physical laws.</li>\n<li>To do this, they built a tensorflow model that contained positions and time offsets as weights. Then they minimized the loss, which consisted of the sum satellite distance errors and the delta changes errors. Plus, they add penalty for unnecessary acceleration - to avoid trajectory wobbling.</li>\n</ul>\n<h3><a href=\"https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/262074\" target=\"_blank\">8th place solution</a></h3>\n<p><strong>Baseline Improvement</strong></p>\n<p>They computed velocities in ENU coordinate system between consecutive timestamps using Acummulated Delta Range, pseudoragnes, sattelite positions and reproduced baseline. After that, they removed outliers and applied smoothing to predictions<br>\nThen they 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 .<br>\nAs a last step, they applied Weighted Least Squares to combine relative predictions with data from derived files. For each timestamp it solved the following optimization problem<br>\nargmin_{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<br>\nwhere</p>\n<p>k - parameter controlling size of the window.<br>\nx - phone position at timestamp t<br>\nb_i - phone clock bias at timestamp t + i<br>\nn_i - number of pseudorange measurements at timestamp t + i<br>\nw_{ij} - inverse of j-th pseudorange measurement uncertainty multiplied by 1 + 0.25|i|<br>\ns_{ij} - j-th satellite position at timestamp t + i<br>\n\\Delta x_{i} - model's prediction of relative position between timestamp t + i and t<br>\np_{ij} - corrected j-th pseudorange measurement at timestamp t + i<br>\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.</p>\n<p><strong>Baseline Improvement in Downtown Area</strong><br>\nAs all the road segments from downtown areas in the test data were also present in ground truth data, they applied the following algorithm for each timestamp:</p>\n<p>select all points from ground truth file closer to the baseline prediction than 30 meters - let's call them candidate points<br>\nfor each candidate point x_j estimate clock bias: b_j = \\mathrm{median}<em>i ( || s_i - x_j || - p_i )\nfind k points with the lowest values of\n\\sum</em>{i=1}^{n} w_i | || s_i - x_j || - b_i - p_i |</p>\n<p>and return their medoid.<br>\nIt was important to use median instead of mean to compute clock bias and to use the absolute value of residuals instead of squares because it helped with very noisy measurements in the downtown area.</p>\n<p><strong>Postprocessing</strong><br>\nAfter that, they applied the following steps to improve predictions:</p>\n<p>Error correction model - it predicted the difference between current predictions and ground truth. It was a simple 1D Conv Neural Network. Features for this model were based on current predictions and imu.<br>\nAggregating predictions when speed is zero.<br>\nAggregating predictions from different phones.</p>\n<h3><a href=\"https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/261959\" target=\"_blank\">5th place solution</a></h3>\n<p><strong>Use of sensor data</strong><br>\nBased on acceleration, gyro, and geomagnetic sensors, I estimated vehicle orientation and acceleration and added acceleration and lateral velocity terms to the cost function of subsequent optimizations. This idea may have had a little effect after the introduction of velocity estimates.</p>\n<p><strong>Velocity estimation using doppler shift</strong><br>\nThe vehicle speed was estimated from the pseudo-range rate by the least-squares method and used for subsequent optimization-based smoothing.</p>\n<p><strong>Optimization-based smoothing</strong></p>\n<p>First, the dynamics of the vehicle is expressed by the following state equation.</p>\n<p><img src=\"https://user-images.githubusercontent.com/309785/128366897-369cc75b-46e9-419b-8f35-d0e884e9ff27.png\" alt=\"\"></p>\n<p>where 𝜙 and 𝜓 are latitude and longitude, respectively.</p>\n<p>Then, by vertically arranging the states 𝑋 and inputs, jerks, 𝑈 at each time, the equality constraints on state transitions can be described as follows,</p>\n<p>$$A X + B U = 0$$</p>\n<p>In addition, by determining the observation matrix 𝐶 according to the observation time based on Hermitian interpolation, the vector 𝑌, which is a vertical sequence of latitude and longitude at each observation time, can be written as follows,</p>\n<p>$$Y = C X$$</p>\n<p>The optimization evaluation function 𝐽 is set as the sum of the squares of the jerk 𝑈 and the position estimation error, as follows,</p>\n<p>$$J = U^T R U + (\\hat{Y} - C X)^T L (\\hat{Y} - C X)$$</p>\n<p>Finally, the position estimation is formulated as the following quadratic programming problem.</p>\n<p><img src=\"https://user-images.githubusercontent.com/309785/128366891-08f79ee0-881e-4a6a-b9a5-887270cc83fb.png\" alt=\"\"></p>\n<p>Based on this method, various information can be integrated by adding velocity error, acceleration error, cost related to lateral velocity, etc. to the cost function.</p>\n<p>The important point is to perform the above optimization by using the positions of all smartphones in one driving data at the same time. This method is clearly more accurate than the method of making estimates for each smartphone and calculating their average.</p>\n<h3><a href=\"https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/261904\" target=\"_blank\">6th Place Solution</a></h3>\n<p><strong>Preprocess</strong><br>\nThe author predicted anomalies (distance from ground truth) and speed from IMU data and lightGBM then replaced anomalies above a threshold with linearly interpolated values.</p>\n<p><strong>Kalman smoothing</strong><br>\nApplied two patterns of Linear Kalman Smoothing:</p>\n<ul>\n<li>Takes into account velocity, and the other takes into account acceleration (i.e. 4D and 6D).</li>\n<li>Since the interval of the observed values was not constant, replaced delta_t in the state transition matrix for each update step.</li>\n</ul>\n<p><strong>AccumulatedDeltaRange</strong></p>\n<p>Using the GNSS Analysis app from google, the author was able to obtain observations using the AccumulatedDeltaRange for some of the data.</p>\n<p>Implemented a forward hatch filter and a backward hatch filter and averaged them after applying Kaman smoothing.</p>\n<pre><code>   prev_smooth = lat_lngs[0]\n   res = [prev_smooth]\n   for raw, delta_adr, delta_t in zip(lat_lngs[1:, :], delta_adrs[1:, :], delta_ts[1:]):\n       if not all(np.isnan(delta_adr)):\n           smooth = 1 / M * raw + (M - 1) / M * (prev_smooth + delta_adr * delta_t)\n       else:\n           smooth = raw\n       prev_smooth = smooth\n       res.append(prev_smooth)\n  res = np.array(res)\n</code></pre>\n<ul>\n<li>The author then optimized the parameter M using GroupKFold for each area.</li>\n<li>There were many missing delta_adr values for some phones, so the authors filled them with values from other phones.</li>\n</ul>\n<p><strong>Weighted Phone Mean</strong><br>\nAfter applying the hatch filter, they weighted average latitude and longitude using the weights of the phone optimized by GroupKFold as well as M.<br>\nSome of the millisSinceGpsEpoch had a little gap depending on the phone, so the authors used linear interpolation to fill it.</p>\n<p><strong>Snap2grid</strong><br>\nIn the downtown area, the authors performed a discrete optimization using linearly interpolated ground truth.<br>\nTo prevent overfitting, the ground truth in itself was not included in the target to be snapped.<br>\nThe objective function is as follows, and they used a greedy search to find the optimal path.</p>\n<p>cost = distance2cur + distance2prev * alpha</p>\n<p><strong>Stay point mean</strong><br>\nUsing the predicted value of the speed of LightGBM, they took the average for points below the threshold.</p>\n<h3><a href=\"https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/261876\" target=\"_blank\">2nd place solution</a></h3>\n<p><strong>XGBoost stacked ensemble</strong><br>\nCorrected the PrMs using other device data, gives about 10-40 cm improved baseline. Used the trick: the amount of correction of PrM was used as weights in WLS algorithm</p>\n<p><strong>Computing Velocity</strong><br>\nTranslated WlsPvt.m from gps-measurement google tool in python using PseudorangeRateMetersPerSecond and the results was 0.08Mps mean average accurate. When the translation algorithm failed the author used the baseline speedMps</p>\n<p><strong>ADR relative position</strong><br>\nUsed derived files public version Android GPS tools.</p>\n<p><strong>Remove outliers</strong><br>\nUsed some outlier removal methods from public notebooks but also included: If there were two or more consecutive outliers remove and interpolate it.</p>\n<p><strong>Mixing signals from multiple devices</strong><br>\nIt turns out then median averaging is better than mean, also variance among all epochs was pretty similar so the author windowed signal (10-30 epochs adjusted by speed Category and region).</p>\n<p><strong>Mean By Stop</strong><br>\nUsed velocity Mps with threshold adjusted about 0.5-1.</p>\n<h3><a href=\"https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/261739\" target=\"_blank\">5th Place Solution</a></h3>\n<p><strong>kNNHeight</strong><br>\nThe author mapped the latitude and longitude from the ground truth to the correct altitude using KNN.</p>\n<p><strong>Outlier Detection</strong><br>\nThe author estimated what point to consider as an outlier using the relative coordinates of the surrounding about 50 seconds as a feature.</p>\n<p><strong>Postprocesses</strong></p>\n<p><strong>Relpos Outlier Detection</strong><br>\nDetects relative position outliers as well as absolute coordinates to improve accuracy.</p>\n<p><strong>KalmanFilter</strong><br>\nKalman filter considers relative and absolute positions.</p>\n<p><strong>SateliteMean</strong><br>\nAveraging phone with 1/(psuedorangesigma)**2 as weights</p>\n<p><strong>Snap to Grid</strong><br>\nIn SJC, the authors snap the prediction to the nearest neighbor of ground_truth.</p>\n<h3><a href=\"https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/261732\" target=\"_blank\">7th place solution</a></h3>\n<ol>\n<li>Baseline Improving<br>\nI have rebuilt the baseline based on this notebook.<br>\nFor isrbm, I used the median value for each phone-sat.</li>\n</ol>\n<p><strong>Satellite Selection</strong><br>\nExcluding satellites that were a source of error, from the least-squares calculation.<br>\nUse the elevation angle for filter condition: Signals from satellites with low elevation angles are excluded because they are strongly affected by various errors.</p>\n<p><strong>Carrier Smoothing</strong><br>\nPseudorange smoothing with Accumulated Delta Range (ADR).</p>\n<p><strong>Relative Position Estimation</strong></p>\n<p><strong>IMU Data</strong><br>\nRelative positions were missing in some places the author combined IMU sensor data and author used lightGBM with lag and rolling features of the IMU and vehicle velocity.</p>\n<p><strong>Excluding high-speed points</strong><br>\nExclude points that have a very large distance from the previous and next point.</p>\n<p>** Post-processing using Kalman Smoothing**<br>\nWas done in a public notebook, the author used it also.</p>\n<p><strong>Area Grouping</strong><br>\nThe author usewd KNN and implemented grouping based on the degree of path matching with the train where each collection was divided into five groups, and the hyperparameters and order of processing were adjusted for each group.</p>\n<h3><a href=\"https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/261774\" target=\"_blank\">18th Place Solution</a></h3>\n<ul>\n<li>Area Classification<br>\nThey automatically classified the collection into three categories as in the public version, and also defined a difficult area.<br>\nThe difficult area was defined as the area like the following.</li>\n</ul>\n<p><strong>Outlier Correction</strong><br>\n<a href=\"https://www.kaggle.com/dehokanta/baseline-post-processing-by-outlier-correction\" target=\"_blank\">notebook</a></p>\n<p><strong>Kalman Smoothing</strong><br>\nApplied linear interpolation to keep epoch width constant: <a href=\"https://www.kaggle.com/emaerthin/demonstration-of-the-kalman-filter\" target=\"_blank\">notebook</a></p>\n<p><strong>Phone Mean</strong><br>\n<a href=\"https://www.kaggle.com/t88take/gsdc-phones-mean-prediction\" target=\"_blank\">notebook 1</a><br>\n<a href=\"https://www.kaggle.com/bpetrb/adaptive-gauss-phone-mean\" target=\"_blank\">notebook 2</a></p>\n<p><strong>Phones Removal</strong><br>\n<a href=\"https://www.kaggle.com/columbia2131/device-eda-interpolate-by-removing-device-en-ja\" target=\"_blank\">notebook</a></p>\n<p><strong>Snap to Grid</strong><br>\nThey applied to snap to grid only downtown area and the difficult areas.</p>\n<p><strong>Position estimation by imu data</strong><br>\nRelative position correction was performed using IMU data for the only downtown area using LightGBM with GroupKFold(group=\"phone\") CV and the features(shift range is -30~30) &amp; aggregate features(mean, std, max, min, median, skew, kart).</p>",
      "rawMarkdown": "# Tricks Used By The Winners Of Last Year's Competition\n\n\n### [1st place solution](https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/262406)\n\n**Key points of the solution:**\n\n- Global optimization of position and velocity by Factor Graph Optimization Technique\n- Velocity constraint by accumulated delta range（ADR）\n- Absolute position constraint by differential pseudorange between a base station\n- No machine learning\n\n**Input Data**\n- Phone_Gnsslog.txt\n- RINEX files of GNSS base station (I used Verizon base station data from here）\n- Ground Truth（Downtown area only）\n\nDid not use Phone_derived.csv. There were some missing data in Phone_derived.csv files. So the author calculated the satellite position and velocity directly from the RINEX navigation file. Baseline position and IMU data are also not used.\n\n**Factor Graph Optimization**\nFactor graphs are a class of graphical models in which there are variables and factors. The variables represent unknown quantities in the problem, and the factors represent functions on subsets of the variables. Edges in the factor graph are always between factors and variables, and indicate that a particular factor depends on a particular variable.[here](https://gtsam.org/2020/06/01/factor-graphs.html)\n\nThe core of the approach was to use a global optimization method based on Factor Graph. Several optimization methods have been used, with good results. Factor graph optimization is a method that can apply a variety of complex nonlinear constraints and simultaneously optimize all state variables（the entire driving trajectory）. There are many outliers in the various constraints（edges in the graph）, but a robust optimization technique eliminates the need to manually set the outlier threshold parameters.\n\n**Factor Graph Structure**\nThe author tried many different graph structures and finally performed Graph optimization using the following Factor graph.\n\n![](https://user-images.githubusercontent.com/7933764/128525861-3b529b21-e5bb-49ca-8ca6-60229b4ade32.png)\n\nThe graph node𝑋𝑖 presents the state variable of different moments, and the edge connecting two nodes presents the error function 𝑒(⋅); each edge corresponds to a single observation 𝑍𝑖. In the graph, error function 𝑒(⋅) represents probabilistic constraints applied to the state at the specified time-step. Optimization factor graph can be written as follows.\n\n\n![](https://user-images.githubusercontent.com/7933764/128522724-ad708687-61ec-4416-b622-c972b451a8a0.png)\n\nHere, Ω𝑖 is the information matrix（inverse of covariance matrix）which determines the accuracy of the observation 𝑍𝑖. We defined the following as nodes（estimated states）of the graph.\n\n\n![](https://user-images.githubusercontent.com/7933764/128524196-b6843c78-dfe3-4850-88ed-9fada7becea2.png)\n\n![](https://user-images.githubusercontent.com/7933764/128524319-f1c6a8fe-0f7e-4417-b702-a9cf815aa466.png)\n\nwhere 𝑟 and 𝑟˙ is 3D position/velocity in earth-centered earth-fixed（ECEF）coordinate. 𝑡 and 𝑡˙ represent the receive clock bias and drift in each GNSS signals.\n\nHere, 𝑠 in the graph is a [switchable constraint](https://nikosuenderhauf.github.io/assets/papers/IROS12-switchableConstraints.pdf), which is a state that takes a variable between 0 and 1. The value of switchable constraint is estimated simultaneously by optimization. On the edge of an outlier, the switchable constraint is automatically optimized to 0 and acts like a weight for the observed value. The optimization problem can be described as follows.\n\n![](https://user-images.githubusercontent.com/7933764/128525345-2cb74f7a-5a74-4fa4-8c30-1d73a0828ecf.png)\n\nwhere the last term in the above equation is the anchor factor of the switch to prevent the switch state from going to all zeros.\n\n**Pseudorange Factor**\nIn the Pseudorange Factor, the observation is the difference between the pseudorange and the reference station's pseudorange, which removes the all bias error component in GNSS measurements（excluding multipath errors）. Theoretically, the residuals of the single differenced pseudorange have a Gaussian distribution with zero mean value if receiver clock error is compensated. This single-difference pseudorange improves the absolute position accuracy. Using this differential GNSS technique, the aurhor did not need any bias correction for the final position.\n\n**Doppler/ADR Factor**\nThe pseudorange rate（Doppler shift）of the smartphone was noisier than the aurhor expected. Doppler factor is used instead only when the ADR factor is not available.\n\n**Motion Factor**\nThe motion factor uses the estimated velocity and clock drift to add constraints between neighboring nodes. It simply adds a constraint so that the integral of the velocity and clock drift is equal to the difference between the neighboring states.\n\n**Pseudo-Position Factor**\nThe pseudo-position factor was used only for the downtown area, and since the ground truth was traveling along the same path as the test data, the points on the ground truth path closest to the estimated trajectory were extracted and added to the graph as pseudo position constraints with appropriate covariance.\n\n### [3rd place solution](https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/262355)\n\n- Have not used any complex algorithms.\n- All the author used from the data is pseudo-ranges and deltas.\n- In order to filter out the deltas, the author calculated the position offset to the next epoch, and left only those epochs that gave enough consistent satellites\n- The main idea of the algorithm was that the positions that they get on the track must be in good agreement with the psevdoranges and deltas, in addition, they must satisfy certain physical laws.\n- To do this, they built a tensorflow model that contained positions and time offsets as weights. Then they minimized the loss, which consisted of the sum satellite distance errors and the delta changes errors. Plus, they add penalty for unnecessary acceleration - to avoid trajectory wobbling.\n\n\n\n### [8th place solution](https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/262074)\n\n**Baseline Improvement**\n\nThey computed velocities in ENU coordinate system between consecutive timestamps using Acummulated Delta Range, pseudoragnes, sattelite positions and reproduced baseline. After that, they removed outliers and applied smoothing to predictions\nThen they 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 .\nAs a last step, they applied Weighted Least Squares to combine relative predictions with data from derived files. For each timestamp it solved the following optimization problem\nargmin_{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\nwhere\n\nk - parameter controlling size of the window.\nx - phone position at timestamp t\nb_i - phone clock bias at timestamp t + i\nn_i - number of pseudorange measurements at timestamp t + i\nw_{ij} - inverse of j-th pseudorange measurement uncertainty multiplied by 1 + 0.25|i|\ns_{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\np_{ij} - corrected j-th pseudorange measurement at timestamp t + i\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**Baseline Improvement in Downtown Area**\nAs all the road segments from downtown areas in the test data were also present in ground truth data, they applied the following algorithm for each timestamp:\n\nselect all points from ground truth file closer to the baseline prediction than 30 meters - let's call them candidate points\nfor each candidate point x_j estimate clock bias: b_j = \\mathrm{median}_i ( || s_i - x_j || - p_i )\nfind k points with the lowest values of\n\\sum_{i=1}^{n} w_i | || s_i - x_j || - b_i - p_i |\n\nand return their medoid.\nIt was important to use median instead of mean to compute clock bias and to use the absolute value of residuals instead of squares because it helped with very noisy measurements in the downtown area.\n\n**Postprocessing**\nAfter that, they applied the following steps to improve predictions:\n\nError correction model - it predicted the difference between current predictions and ground truth. It was a simple 1D Conv Neural Network. Features for this model were based on current predictions and imu.\nAggregating predictions when speed is zero.\nAggregating predictions from different phones.\n\n### [5th place solution](https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/261959)\n\n**Use of sensor data**\nBased on acceleration, gyro, and geomagnetic sensors, I estimated vehicle orientation and acceleration and added acceleration and lateral velocity terms to the cost function of subsequent optimizations. This idea may have had a little effect after the introduction of velocity estimates.\n\n**Velocity estimation using doppler shift**\nThe vehicle speed was estimated from the pseudo-range rate by the least-squares method and used for subsequent optimization-based smoothing.\n\n**Optimization-based smoothing**\n\nFirst, the dynamics of the vehicle is expressed by the following state equation.\n\n![](https://user-images.githubusercontent.com/309785/128366897-369cc75b-46e9-419b-8f35-d0e884e9ff27.png)\n\nwhere 𝜙 and 𝜓 are latitude and longitude, respectively.\n\nThen, by vertically arranging the states 𝑋 and inputs, jerks, 𝑈 at each time, the equality constraints on state transitions can be described as follows,\n\n\n$$A X + B U = 0$$\n\n\nIn addition, by determining the observation matrix 𝐶 according to the observation time based on Hermitian interpolation, the vector 𝑌, which is a vertical sequence of latitude and longitude at each observation time, can be written as follows,\n\n$$Y = C X$$\n\nThe optimization evaluation function 𝐽 is set as the sum of the squares of the jerk 𝑈 and the position estimation error, as follows,\n\n$$J = U^T R U + (\\hat{Y} - C X)^T L (\\hat{Y} - C X)$$\n\nFinally, the position estimation is formulated as the following quadratic programming problem.\n\n![](https://user-images.githubusercontent.com/309785/128366891-08f79ee0-881e-4a6a-b9a5-887270cc83fb.png)\n\nBased on this method, various information can be integrated by adding velocity error, acceleration error, cost related to lateral velocity, etc. to the cost function.\n\nThe important point is to perform the above optimization by using the positions of all smartphones in one driving data at the same time. This method is clearly more accurate than the method of making estimates for each smartphone and calculating their average.\n\n\n### [6th Place Solution](https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/261904)\n\n**Preprocess**\nThe author predicted anomalies (distance from ground truth) and speed from IMU data and lightGBM then replaced anomalies above a threshold with linearly interpolated values.\n\n**Kalman smoothing**\nApplied two patterns of Linear Kalman Smoothing:\n- Takes into account velocity, and the other takes into account acceleration (i.e. 4D and 6D).\n- Since the interval of the observed values was not constant, replaced delta_t in the state transition matrix for each update step.\n\n**AccumulatedDeltaRange**\n\nUsing the GNSS Analysis app from google, the author was able to obtain observations using the AccumulatedDeltaRange for some of the data.\n\nImplemented a forward hatch filter and a backward hatch filter and averaged them after applying Kaman smoothing.\n\n```\n   prev_smooth = lat_lngs[0]\n   res = [prev_smooth]\n   for raw, delta_adr, delta_t in zip(lat_lngs[1:, :], delta_adrs[1:, :], delta_ts[1:]):\n       if not all(np.isnan(delta_adr)):\n           smooth = 1 / M * raw + (M - 1) / M * (prev_smooth + delta_adr * delta_t)\n       else:\n           smooth = raw\n       prev_smooth = smooth\n       res.append(prev_smooth)\n  res = np.array(res)\n```\n\n- The author then optimized the parameter M using GroupKFold for each area.\n- There were many missing delta_adr values for some phones, so the authors filled them with values from other phones.\n\n**Weighted Phone Mean**\nAfter applying the hatch filter, they weighted average latitude and longitude using the weights of the phone optimized by GroupKFold as well as M.\nSome of the millisSinceGpsEpoch had a little gap depending on the phone, so the authors used linear interpolation to fill it.\n\n**Snap2grid**\nIn the downtown area, the authors performed a discrete optimization using linearly interpolated ground truth.\nTo prevent overfitting, the ground truth in itself was not included in the target to be snapped.\nThe objective function is as follows, and they used a greedy search to find the optimal path.\n\ncost = distance2cur + distance2prev * alpha\n\n**Stay point mean**\nUsing the predicted value of the speed of LightGBM, they took the average for points below the threshold.\n\n\n### [2nd place solution](https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/261876)\n\n**XGBoost stacked ensemble**\nCorrected the PrMs using other device data, gives about 10-40 cm improved baseline. Used the trick: the amount of correction of PrM was used as weights in WLS algorithm\n\n**Computing Velocity**\nTranslated WlsPvt.m from gps-measurement google tool in python using PseudorangeRateMetersPerSecond and the results was 0.08Mps mean average accurate. When the translation algorithm failed the author used the baseline speedMps\n\n**ADR relative position**\nUsed derived files public version Android GPS tools.\n\n**Remove outliers**\nUsed some outlier removal methods from public notebooks but also included: If there were two or more consecutive outliers remove and interpolate it.\n\n**Mixing signals from multiple devices**\nIt turns out then median averaging is better than mean, also variance among all epochs was pretty similar so the author windowed signal (10-30 epochs adjusted by speed Category and region).\n\n**Mean By Stop**\nUsed velocity Mps with threshold adjusted about 0.5-1.\n\n### [5th Place Solution](https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/261739)\n\n**kNNHeight**\nThe author mapped the latitude and longitude from the ground truth to the correct altitude using KNN.\n\n**Outlier Detection**\nThe author estimated what point to consider as an outlier using the relative coordinates of the surrounding about 50 seconds as a feature.\n\n**Postprocesses**\n\n**Relpos Outlier Detection**\nDetects relative position outliers as well as absolute coordinates to improve accuracy.\n\n**KalmanFilter**\nKalman filter considers relative and absolute positions.\n\n**SateliteMean**\nAveraging phone with 1/(psuedorangesigma)**2 as weights\n\n**Snap to Grid**\nIn SJC, the authors snap the prediction to the nearest neighbor of ground_truth.\n\n### [7th place solution](https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/261732)\n\n1. Baseline Improving\nI have rebuilt the baseline based on this notebook.\nFor isrbm, I used the median value for each phone-sat.\n\n**Satellite Selection**\nExcluding satellites that were a source of error, from the least-squares calculation.\nUse the elevation angle for filter condition: Signals from satellites with low elevation angles are excluded because they are strongly affected by various errors.\n\n**Carrier Smoothing**\nPseudorange smoothing with Accumulated Delta Range (ADR).\n\n**Relative Position Estimation**\n\n**IMU Data**\nRelative positions were missing in some places the author combined IMU sensor data and author used lightGBM with lag and rolling features of the IMU and vehicle velocity.\n\n**Excluding high-speed points**\nExclude points that have a very large distance from the previous and next point.\n\n** Post-processing using Kalman Smoothing**\nWas done in a public notebook, the author used it also.\n\n**Area Grouping**\nThe author usewd KNN and implemented grouping based on the degree of path matching with the train where each collection was divided into five groups, and the hyperparameters and order of processing were adjusted for each group.\n\n### [18th Place Solution](https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/261774)\n\n- Area Classification\nThey automatically classified the collection into three categories as in the public version, and also defined a difficult area.\nThe difficult area was defined as the area like the following.\n\n**Outlier Correction**\n[notebook](https://www.kaggle.com/dehokanta/baseline-post-processing-by-outlier-correction)\n\n**Kalman Smoothing**\nApplied linear interpolation to keep epoch width constant: [notebook](https://www.kaggle.com/emaerthin/demonstration-of-the-kalman-filter)\n\n**Phone Mean**\n[notebook 1](https://www.kaggle.com/t88take/gsdc-phones-mean-prediction)\n[notebook 2](https://www.kaggle.com/bpetrb/adaptive-gauss-phone-mean)\n\n**Phones Removal**\n[notebook](https://www.kaggle.com/columbia2131/device-eda-interpolate-by-removing-device-en-ja)\n\n**Snap to Grid**\nThey applied to snap to grid only downtown area and the difficult areas.\n\n**Position estimation by imu data**\nRelative position correction was performed using IMU data for the only downtown area using LightGBM with GroupKFold(group=\"phone\") CV and the features(shift range is -30~30) & aggregate features(mean, std, max, min, median, skew, kart).",
      "votes": 21
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "1815356": "# Tricks Used By The Winners Of Last Year's Competition\n\n\n### [1st place solution](https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/262406)\n\n**Key points of the solution:**\n\n- Global optimization of position and velocity by Factor Graph Optimization Technique\n- Velocity constraint by accumulated delta range（ADR）\n- Absolute position constraint by differential pseudorange between a base station\n- No machine learning\n\n**Input Data**\n- Phone_Gnsslog.txt\n- RINEX files of GNSS base station (I used Verizon base station data from here）\n- Ground Truth（Downtown area only）\n\nDid not use Phone_derived.csv. There were some missing data in Phone_derived.csv files. So the author calculated the satellite position and velocity directly from the RINEX navigation file. Baseline position and IMU data are also not used.\n\n**Factor Graph Optimization**\nFactor graphs are a class of graphical models in which there are variables and factors. The variables represent unknown quantities in the problem, and the factors represent functions on subsets of the variables. Edges in the factor graph are always between factors and variables, and indicate that a particular factor depends on a particular variable.[here](https://gtsam.org/2020/06/01/factor-graphs.html)\n\nThe core of the approach was to use a global optimization method based on Factor Graph. Several optimization methods have been used, with good results. Factor graph optimization is a method that can apply a variety of complex nonlinear constraints and simultaneously optimize all state variables（the entire driving trajectory）. There are many outliers in the various constraints（edges in the graph）, but a robust optimization technique eliminates the need to manually set the outlier threshold parameters.\n\n**Factor Graph Structure**\nThe author tried many different graph structures and finally performed Graph optimization using the following Factor graph.\n\n![](https://user-images.githubusercontent.com/7933764/128525861-3b529b21-e5bb-49ca-8ca6-60229b4ade32.png)\n\nThe graph node𝑋𝑖 presents the state variable of different moments, and the edge connecting two nodes presents the error function 𝑒(⋅); each edge corresponds to a single observation 𝑍𝑖. In the graph, error function 𝑒(⋅) represents probabilistic constraints applied to the state at the specified time-step. Optimization factor graph can be written as follows.\n\n\n![](https://user-images.githubusercontent.com/7933764/128522724-ad708687-61ec-4416-b622-c972b451a8a0.png)\n\nHere, Ω𝑖 is the information matrix（inverse of covariance matrix）which determines the accuracy of the observation 𝑍𝑖. We defined the following as nodes（estimated states）of the graph.\n\n\n![](https://user-images.githubusercontent.com/7933764/128524196-b6843c78-dfe3-4850-88ed-9fada7becea2.png)\n\n![](https://user-images.githubusercontent.com/7933764/128524319-f1c6a8fe-0f7e-4417-b702-a9cf815aa466.png)\n\nwhere 𝑟 and 𝑟˙ is 3D position/velocity in earth-centered earth-fixed（ECEF）coordinate. 𝑡 and 𝑡˙ represent the receive clock bias and drift in each GNSS signals.\n\nHere, 𝑠 in the graph is a [switchable constraint](https://nikosuenderhauf.github.io/assets/papers/IROS12-switchableConstraints.pdf), which is a state that takes a variable between 0 and 1. The value of switchable constraint is estimated simultaneously by optimization. On the edge of an outlier, the switchable constraint is automatically optimized to 0 and acts like a weight for the observed value. The optimization problem can be described as follows.\n\n![](https://user-images.githubusercontent.com/7933764/128525345-2cb74f7a-5a74-4fa4-8c30-1d73a0828ecf.png)\n\nwhere the last term in the above equation is the anchor factor of the switch to prevent the switch state from going to all zeros.\n\n**Pseudorange Factor**\nIn the Pseudorange Factor, the observation is the difference between the pseudorange and the reference station's pseudorange, which removes the all bias error component in GNSS measurements（excluding multipath errors）. Theoretically, the residuals of the single differenced pseudorange have a Gaussian distribution with zero mean value if receiver clock error is compensated. This single-difference pseudorange improves the absolute position accuracy. Using this differential GNSS technique, the aurhor did not need any bias correction for the final position.\n\n**Doppler/ADR Factor**\nThe pseudorange rate（Doppler shift）of the smartphone was noisier than the aurhor expected. Doppler factor is used instead only when the ADR factor is not available.\n\n**Motion Factor**\nThe motion factor uses the estimated velocity and clock drift to add constraints between neighboring nodes. It simply adds a constraint so that the integral of the velocity and clock drift is equal to the difference between the neighboring states.\n\n**Pseudo-Position Factor**\nThe pseudo-position factor was used only for the downtown area, and since the ground truth was traveling along the same path as the test data, the points on the ground truth path closest to the estimated trajectory were extracted and added to the graph as pseudo position constraints with appropriate covariance.\n\n### [3rd place solution](https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/262355)\n\n- Have not used any complex algorithms.\n- All the author used from the data is pseudo-ranges and deltas.\n- In order to filter out the deltas, the author calculated the position offset to the next epoch, and left only those epochs that gave enough consistent satellites\n- The main idea of the algorithm was that the positions that they get on the track must be in good agreement with the psevdoranges and deltas, in addition, they must satisfy certain physical laws.\n- To do this, they built a tensorflow model that contained positions and time offsets as weights. Then they minimized the loss, which consisted of the sum satellite distance errors and the delta changes errors. Plus, they add penalty for unnecessary acceleration - to avoid trajectory wobbling.\n\n\n\n### [8th place solution](https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/262074)\n\n**Baseline Improvement**\n\nThey computed velocities in ENU coordinate system between consecutive timestamps using Acummulated Delta Range, pseudoragnes, sattelite positions and reproduced baseline. After that, they removed outliers and applied smoothing to predictions\nThen they 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 .\nAs a last step, they applied Weighted Least Squares to combine relative predictions with data from derived files. For each timestamp it solved the following optimization problem\nargmin_{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\nwhere\n\nk - parameter controlling size of the window.\nx - phone position at timestamp t\nb_i - phone clock bias at timestamp t + i\nn_i - number of pseudorange measurements at timestamp t + i\nw_{ij} - inverse of j-th pseudorange measurement uncertainty multiplied by 1 + 0.25|i|\ns_{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\np_{ij} - corrected j-th pseudorange measurement at timestamp t + i\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**Baseline Improvement in Downtown Area**\nAs all the road segments from downtown areas in the test data were also present in ground truth data, they applied the following algorithm for each timestamp:\n\nselect all points from ground truth file closer to the baseline prediction than 30 meters - let's call them candidate points\nfor each candidate point x_j estimate clock bias: b_j = \\mathrm{median}_i ( || s_i - x_j || - p_i )\nfind k points with the lowest values of\n\\sum_{i=1}^{n} w_i | || s_i - x_j || - b_i - p_i |\n\nand return their medoid.\nIt was important to use median instead of mean to compute clock bias and to use the absolute value of residuals instead of squares because it helped with very noisy measurements in the downtown area.\n\n**Postprocessing**\nAfter that, they applied the following steps to improve predictions:\n\nError correction model - it predicted the difference between current predictions and ground truth. It was a simple 1D Conv Neural Network. Features for this model were based on current predictions and imu.\nAggregating predictions when speed is zero.\nAggregating predictions from different phones.\n\n### [5th place solution](https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/261959)\n\n**Use of sensor data**\nBased on acceleration, gyro, and geomagnetic sensors, I estimated vehicle orientation and acceleration and added acceleration and lateral velocity terms to the cost function of subsequent optimizations. This idea may have had a little effect after the introduction of velocity estimates.\n\n**Velocity estimation using doppler shift**\nThe vehicle speed was estimated from the pseudo-range rate by the least-squares method and used for subsequent optimization-based smoothing.\n\n**Optimization-based smoothing**\n\nFirst, the dynamics of the vehicle is expressed by the following state equation.\n\n![](https://user-images.githubusercontent.com/309785/128366897-369cc75b-46e9-419b-8f35-d0e884e9ff27.png)\n\nwhere 𝜙 and 𝜓 are latitude and longitude, respectively.\n\nThen, by vertically arranging the states 𝑋 and inputs, jerks, 𝑈 at each time, the equality constraints on state transitions can be described as follows,\n\n\n$$A X + B U = 0$$\n\n\nIn addition, by determining the observation matrix 𝐶 according to the observation time based on Hermitian interpolation, the vector 𝑌, which is a vertical sequence of latitude and longitude at each observation time, can be written as follows,\n\n$$Y = C X$$\n\nThe optimization evaluation function 𝐽 is set as the sum of the squares of the jerk 𝑈 and the position estimation error, as follows,\n\n$$J = U^T R U + (\\hat{Y} - C X)^T L (\\hat{Y} - C X)$$\n\nFinally, the position estimation is formulated as the following quadratic programming problem.\n\n![](https://user-images.githubusercontent.com/309785/128366891-08f79ee0-881e-4a6a-b9a5-887270cc83fb.png)\n\nBased on this method, various information can be integrated by adding velocity error, acceleration error, cost related to lateral velocity, etc. to the cost function.\n\nThe important point is to perform the above optimization by using the positions of all smartphones in one driving data at the same time. This method is clearly more accurate than the method of making estimates for each smartphone and calculating their average.\n\n\n### [6th Place Solution](https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/261904)\n\n**Preprocess**\nThe author predicted anomalies (distance from ground truth) and speed from IMU data and lightGBM then replaced anomalies above a threshold with linearly interpolated values.\n\n**Kalman smoothing**\nApplied two patterns of Linear Kalman Smoothing:\n- Takes into account velocity, and the other takes into account acceleration (i.e. 4D and 6D).\n- Since the interval of the observed values was not constant, replaced delta_t in the state transition matrix for each update step.\n\n**AccumulatedDeltaRange**\n\nUsing the GNSS Analysis app from google, the author was able to obtain observations using the AccumulatedDeltaRange for some of the data.\n\nImplemented a forward hatch filter and a backward hatch filter and averaged them after applying Kaman smoothing.\n\n```\n   prev_smooth = lat_lngs[0]\n   res = [prev_smooth]\n   for raw, delta_adr, delta_t in zip(lat_lngs[1:, :], delta_adrs[1:, :], delta_ts[1:]):\n       if not all(np.isnan(delta_adr)):\n           smooth = 1 / M * raw + (M - 1) / M * (prev_smooth + delta_adr * delta_t)\n       else:\n           smooth = raw\n       prev_smooth = smooth\n       res.append(prev_smooth)\n  res = np.array(res)\n```\n\n- The author then optimized the parameter M using GroupKFold for each area.\n- There were many missing delta_adr values for some phones, so the authors filled them with values from other phones.\n\n**Weighted Phone Mean**\nAfter applying the hatch filter, they weighted average latitude and longitude using the weights of the phone optimized by GroupKFold as well as M.\nSome of the millisSinceGpsEpoch had a little gap depending on the phone, so the authors used linear interpolation to fill it.\n\n**Snap2grid**\nIn the downtown area, the authors performed a discrete optimization using linearly interpolated ground truth.\nTo prevent overfitting, the ground truth in itself was not included in the target to be snapped.\nThe objective function is as follows, and they used a greedy search to find the optimal path.\n\ncost = distance2cur + distance2prev * alpha\n\n**Stay point mean**\nUsing the predicted value of the speed of LightGBM, they took the average for points below the threshold.\n\n\n### [2nd place solution](https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/261876)\n\n**XGBoost stacked ensemble**\nCorrected the PrMs using other device data, gives about 10-40 cm improved baseline. Used the trick: the amount of correction of PrM was used as weights in WLS algorithm\n\n**Computing Velocity**\nTranslated WlsPvt.m from gps-measurement google tool in python using PseudorangeRateMetersPerSecond and the results was 0.08Mps mean average accurate. When the translation algorithm failed the author used the baseline speedMps\n\n**ADR relative position**\nUsed derived files public version Android GPS tools.\n\n**Remove outliers**\nUsed some outlier removal methods from public notebooks but also included: If there were two or more consecutive outliers remove and interpolate it.\n\n**Mixing signals from multiple devices**\nIt turns out then median averaging is better than mean, also variance among all epochs was pretty similar so the author windowed signal (10-30 epochs adjusted by speed Category and region).\n\n**Mean By Stop**\nUsed velocity Mps with threshold adjusted about 0.5-1.\n\n### [5th Place Solution](https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/261739)\n\n**kNNHeight**\nThe author mapped the latitude and longitude from the ground truth to the correct altitude using KNN.\n\n**Outlier Detection**\nThe author estimated what point to consider as an outlier using the relative coordinates of the surrounding about 50 seconds as a feature.\n\n**Postprocesses**\n\n**Relpos Outlier Detection**\nDetects relative position outliers as well as absolute coordinates to improve accuracy.\n\n**KalmanFilter**\nKalman filter considers relative and absolute positions.\n\n**SateliteMean**\nAveraging phone with 1/(psuedorangesigma)**2 as weights\n\n**Snap to Grid**\nIn SJC, the authors snap the prediction to the nearest neighbor of ground_truth.\n\n### [7th place solution](https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/261732)\n\n1. Baseline Improving\nI have rebuilt the baseline based on this notebook.\nFor isrbm, I used the median value for each phone-sat.\n\n**Satellite Selection**\nExcluding satellites that were a source of error, from the least-squares calculation.\nUse the elevation angle for filter condition: Signals from satellites with low elevation angles are excluded because they are strongly affected by various errors.\n\n**Carrier Smoothing**\nPseudorange smoothing with Accumulated Delta Range (ADR).\n\n**Relative Position Estimation**\n\n**IMU Data**\nRelative positions were missing in some places the author combined IMU sensor data and author used lightGBM with lag and rolling features of the IMU and vehicle velocity.\n\n**Excluding high-speed points**\nExclude points that have a very large distance from the previous and next point.\n\n** Post-processing using Kalman Smoothing**\nWas done in a public notebook, the author used it also.\n\n**Area Grouping**\nThe author usewd KNN and implemented grouping based on the degree of path matching with the train where each collection was divided into five groups, and the hyperparameters and order of processing were adjusted for each group.\n\n### [18th Place Solution](https://www.kaggle.com/competitions/google-smartphone-decimeter-challenge/discussion/261774)\n\n- Area Classification\nThey automatically classified the collection into three categories as in the public version, and also defined a difficult area.\nThe difficult area was defined as the area like the following.\n\n**Outlier Correction**\n[notebook](https://www.kaggle.com/dehokanta/baseline-post-processing-by-outlier-correction)\n\n**Kalman Smoothing**\nApplied linear interpolation to keep epoch width constant: [notebook](https://www.kaggle.com/emaerthin/demonstration-of-the-kalman-filter)\n\n**Phone Mean**\n[notebook 1](https://www.kaggle.com/t88take/gsdc-phones-mean-prediction)\n[notebook 2](https://www.kaggle.com/bpetrb/adaptive-gauss-phone-mean)\n\n**Phones Removal**\n[notebook](https://www.kaggle.com/columbia2131/device-eda-interpolate-by-removing-device-en-ja)\n\n**Snap to Grid**\nThey applied to snap to grid only downtown area and the difficult areas.\n\n**Position estimation by imu data**\nRelative position correction was performed using IMU data for the only downtown area using LightGBM with GroupKFold(group=\"phone\") CV and the features(shift range is -30~30) & aggregate features(mean, std, max, min, median, skew, kart)."
  }
}