8000 FIX Updated hdbscan stability calculation to avoid implicit casting by Micky774 · Pull Request #26546 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

FIX Updated hdbscan stability calculation to avoid implicit casting #26546

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

Merged
merged 2 commits into from
Jun 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions sklearn/cluster/_hdbscan/_tree.pyx
83E7
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,13 @@ cdef dict _compute_stability(
cnp.float64_t[::1] result, births
cnp.intp_t[:] parents = condensed_tree['parent']

cnp.intp_t parent, cluster_size, result_index
cnp.intp_t parent, cluster_size, result_index, idx
cnp.float64_t lambda_val
CONDENSED_t condensed_node
cnp.float64_t[:, :] result_pre_dict
cnp.intp_t largest_child = condensed_tree['child'].max()
cnp.intp_t smallest_cluster = np.min(parents)
cnp.intp_t num_clusters = np.max(parents) - smallest_cluster + 1
dict stability_dict = {}

largest_child = max(largest_child, smallest_cluster)
births = np.full(largest_child + 1, np.nan, dtype=np.float64)
Expand All @@ -266,14 +266,10 @@ cdef dict _compute_stability(
result_index = parent - smallest_cluster
result[result_index] += (lambda_val - births[parent]) * cluster_size

result_pre_dict = np.vstack(
(
np.arange(smallest_cluster, np.max(parents) + 1),
result
)
).T
for idx in range(num_clusters):
stability_dict[idx + smallest_cluster] = result[idx]

return dict(result_pre_dict)
return stability_dict


cdef list bfs_from_cluster_tree(
Expand Down
0