Repository navigation
sd: efficient-set membership no longer depends on column order - #183
Closed
gitRasheed wants to merge 1 commit into
Closed
gitRasheed wants to merge 1 commit into
gitRasheed wants to merge 1 commit into
Conversation
…efficient-set-order)
Mirrors R NNS.SD.efficient.set (OVVO-Financial/NNS sd-efficient-set-order).
Columns were sorted by LPM(degree, tmax) and a column was kept unless an
earlier kept column dominated it. Continuous FSD does not follow that order:
for x = [-1, -1, 2], y = [-2, 1, 1], x dominates y but y sorts first, so the
set was [y, x] or [x] depending on the column order. Tolerance-level ties
can also make dominance cyclic, and the scan kept whichever cycle members
came first.
The efficient set is now every column in a strongly connected component of
the dominance graph that no column outside the component dominates, which
is "not dominated by any column" when there are no cycles. Output keeps the
LPM-at-tmax order. The degree-1 discrete path has the full matrix already.
The prefix path (SSD, TSD, continuous FSD) tests only the pairs it needs:
a column nothing dominates is efficient, one dominated by such a column is
not, and only the columns left over get the component check, so it costs
about what the old scan did. nns_sd_cluster shares the pair verdicts across
its peels.
Before -> after (= R main):
sd_efficient_set([y, x], 1, "continuous") [0, 1] -> [1]
nns_sd_cluster([y, x], 1, "continuous") {Cluster_1: [Y, X]}
-> {Cluster_1: [X], Cluster_2: [Y]}
A > B > C > A at tolerance level: every column order now gives all three
No cache entry moves.
Contributor
|
Incorporated through NNS R 14.0 integration #192, merged as |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
R's
NNS.SD.efficient.setsorted columns byLPM(degree, tmax)and kept a column unless an earlier kept column dominated it. Continuous FSD does not follow that order: for x = (-1, -1, 2) and y = (-2, 1, 1), x dominates y but y sorts first, so the set was (y, x) or (x) depending on column order. Tolerance-level ties can also make dominance cyclic, and the scan kept whichever cycle members came first. OVVO-Financial/NNS#127 (merged) keeps every column of a dominance-graph strongly connected component that no column outside it dominates. This slice mirrors it.Stacked on #182; merge with a merge commit.
Changes
_sd_efficient_active_indices_from_matrixnow takes the undominated strongly connected components of its active submatrix (scipy.sparse.csgraph.connected_components). The output keeps the LPM-at-tmax order.sd_efficient_seton 250 x 150 data 36x slower at degree 2 (0.02 s -> 0.73 s), so it now tests only the pairs it needs. A column that nothing dominates is efficient, one dominated by such a column is not, and only the leftover columns, which only dominated columns dominate, go through the component check. That costs about what the old scan did (0.03 s).nns_sd_clustershares the pair verdicts across peels, since a pair's verdict does not depend on the other columns.sd_efficient_set([y, x], 1, "continuous")[0, 1] -> [1],nns_sd_cluster([y, x], 1, "continuous"){Cluster_1: [Y, X]} -> {Cluster_1: [X], Cluster_2: [Y]}, and R's tolerance cycle A > B > C > A now returns all three in R main's order for each of R's four column orders.Tests
set.seed(s)samples, so mine draws from NumPy.NNS_DISABLE_NATIVE=1: 2913 passed, 29 skipped, 2 xpassed. The 3 xfails are mode: break tied discrete modes by gravity, not their mean (mirrors R #111) #178's strict ones and the 2 xpasses the existing non-strict live-R VAR xfails. tests/parity/test_practical_examples.py against the usual R library: 9 passed, 2 xfailed, as on mode: break tied discrete modes by gravity, not their mean (mirrors R #111) #178. ruff check is clean on every changed file.Review
GPT-6.1 Sol reviewed the #135, #127 and #126 mirrors together: SHIP. It matched R main on 1,050 efficient-set cases, 150 of them with cycles.
Mirrors OVVO-Financial/NNS#127