Repository navigation
Add mutual k-nearest neighbor graphs and require fastersom 0.5.0 - #33
Merged
Merged
Conversation
so.neighbor.mnn_graph.create connects two data points only if each is among the neighbor_count nearest neighbors of the other. Data points without mutual neighbors optionally keep the edge to their nearest neighbor (connect_isolated_nodes). Accepts arrays or a fitted SOM and uses the same neighbor finder as knn_graph and snn_graph. The removal of each data point from its own neighbor list is factored out of KnnGraph.get_edges into _exclude_self for reuse. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
fastersom 0.5.0 finds the best-matching units on Apple GPUs (MPS) with fused Metal kernels. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #33 +/- ##
==========================================
+ Coverage 82.22% 82.51% +0.28%
==========================================
Files 55 56 +1
Lines 1975 2007 +32
==========================================
+ Hits 1624 1656 +32
Misses 351 351 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Mutual k-nearest neighbor graphs
so.neighbor.mnn_graph.create(data, neighbor_count=20, connect_isolated_nodes=True, distance_metric=..., accuracy=..., job_count=..., use_gpu=...)connects two data points only if each is among theneighbor_countnearest neighbors of the other. The result is an undirected, unweightednx.Graphwith one node per data point, built with the same neighbor finder asknn_graphandsnn_graph. It accepts an array or a fitted SOM.neighbor_count. In the mutual graph it is not, because the rest of the data does not list the group's points among its own nearest neighbors.connect_isolated_nodes=True(the default), a data point without any mutual neighbor keeps the edge to its nearest neighbor, as insnn_graph.KnnGraph.get_edgesinto a private helper,_exclude_self, which both graphs use.knn_graphis unchanged.Tests (
test/neighbor/test_mnn_graph.py, 15):neighbor_count1, 5 and 15 under all four distance metrics.connect_isolated_nodeson and off.fastersom 0.5.0
pyproject.tomlanduv.lockrequire fastersom 0.5.0, which finds the best-matching units ofso.dimension.somon Apple GPUs (MPS) with fused Metal kernels.Release notes in
docs/source/release-notes/0.12.0.md; please rename the file if the next release gets another number.Checks
test/neighbor,test/cluster,test/dimensionandtest/test_public_api.pywith fastersom 0.5.0 on the CPU: 130 passed (-m "not gpu and not no_github_ci").-p spatiomic) and bandit clean.make unittest) was not run locally.🤖 Generated with Claude Code