-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add k-d tree tutorial and update tree sub-module #771
Conversation
update tree sub-module with kd tree and tpr tree mixins
# .. image:: ../../_static/kd_tree_fig_2.png | ||
# :width: 1200 | ||
# :height: 250 | ||
# :alt: Image showing diagrammatical representation of kd-tree in 2 dimensions, described further in figure 2 caption. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Figure 2B again.
Rather than saying move right because 8>5, it might be easier to follow if you show that you move right because abs(8-8) < abs(8-4) (Left descendant further from query node than right descendant in x dimension).
# Searching a :math:`k`-d tree with Nearest Neighbour | ||
# --------------------------------------------------- | ||
# Once the :math:`k`-d tree has been constructed from the detection set, it can then be used to search for the Nearest | ||
# Neighbour of a given track prediction (which is the query vector). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The query vector here would be the track prediction as seen in measurement space. I believe we refer to it as the measurement prediction.
…iption of traversing back up the kd tree during nearest neighbour search
…earch as requested in review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few minor changes - looks good
# :alt: Image showing diagrammatical representation of kd-tree in 2 dimensions, described further in figure 2 caption. | ||
# | ||
# Fig. 2a offers a graphical representation of the :math:`k`-d tree shown in 2b. 2a shows the prediction vector, | ||
# :math:`[8,2]`, in blue. 2b shows the first part of the search taking place down the :math:`k`-d tree. Current best |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the constructing a k-d tree section you state a vector space of [x, y]^T using :math:\begin{bmatrix} x \\ y \\\end{bmatrix}
. However for the rest of the document each vector is displayed as math:[x, y]
. It might be best for continuity/mathematical correctness to display each vector as math:[x, y]^T
to denote that each is a vector in the same form as previously stated. You could use :math:\begin{bmatrix} x \\ y \\\end{bmatrix}
throughout but it might make the lines break up a bit.
# :math:`[8,2]`, in blue. 2b shows the first part of the search taking place down the :math:`k`-d tree. Current best | |
# :math:`[8,2]^T`, in blue. 2b shows the first part of the search taking place down the :math:`k`-d tree. Current best |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have made a few suggestions... Please consider them more as points to consider rather than changes! Looks good - Explanation is much easier to follow now
# | ||
# All detections with :math:`x` coordinate :math:`\leq` the median are placed in the left subtree from the root node, | ||
# and all detections with :math:`x` coordinate :math:`>` median are placed in the right subtree from the root node. The | ||
# left and right subtrees are then split into two further subtrees in the same way, except this time using the values in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This explanation is so much better - really clear now
# units, which becomes the new best distance. We then traverse back up the tree again. There are no other subtrees in | ||
# the tree which can possibly contain detections that beat the current best distance, so the detection at :math:`[9,4]` | ||
# is selected as the nearest neighbour and the search is complete when we reach the root. | ||
# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One extra thought, what happens if both descendant nodes from the root node are an equal distance from the root node? Does the code account for this situation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have made a few suggestions... Please consider them more as points to consider rather than changes! Looks good - Explanation is much easier to follow now
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #771 +/- ##
==========================================
+ Coverage 94.80% 94.81% +0.01%
==========================================
Files 175 175
Lines 9456 9477 +21
Branches 1884 1884
==========================================
+ Hits 8965 8986 +21
Misses 350 350
Partials 141 141
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
update tree sub-module with kd tree and tpr tree mixins