Repository navigation
FIX HDBSCAN crash with cluster_selection_epsilon on tied distances - #33276
Closed
Mr-Neutr0n wants to merge 1 commit into
Closed
Mr-Neutr0n wants to merge 1 commit into
Mr-Neutr0n wants to merge 1 commit into
Conversation
When the condensed tree contains duplicate child entries (caused by tied distances in the input data), filtering by child id can return multiple rows instead of a single row. The traverse_upwards function assumed a scalar result from these lookups, which raised a TypeError when an array was returned. Index into the first match with [0] for both the parent lookup and the parent_eps computation, since all duplicate entries share the same parent and lambda value. Adds a non-regression test with the exact data from the issue report. Closes #33219
❌ Linting issuesThis PR is introducing linting issues. Here's a summary of the issues. Note that you can avoid having linting issues by enabling You can see the details of the linting issues under the
|
Author
|
closing. check comment in parent issue! |
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.
Fixes #33219
What does this implement/fix?
HDBSCAN.fit_predict()raisesTypeError: only 0-dimensional arrays can be converted to Python scalarswhencluster_selection_epsilonis set and the input data contains tied distances.The root cause is in
traverse_upwardsin_tree.pyx. Tied distances produce duplicate entries in the condensed tree, so filtering by child id can return multiple rows instead of one. The code assumed a scalar result from these lookups, which blows up when it gets an array instead.The fix indexes
[0]on both the parent lookup and theparent_epscomputation. All duplicate entries for a given child share the same parent and lambda value, so taking the first match is correct.How has this been tested?
Added a non-regression test
test_hdbscan_cluster_selection_epsilon_tied_distancesusing both: