Skip to content

Commit 743f16a

Browse files
authored
Merge pull request #294 from markopy/sparse_alpha
Add alpha parameter to sparse distance matrices
2 parents e40ccef + 7a5c32d commit 743f16a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

hdbscan/_hdbscan_reachability.pyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ cpdef sparse_mutual_reachability(object lil_matrix, np.intp_t min_points=5,
8181
else:
8282
core_distance[i] = np.infty
8383

84+
if alpha != 1.0:
85+
lil_matrix = lil_matrix / alpha
86+
8487
nz_row_data, nz_col_data = lil_matrix.nonzero()
8588

8689
for n in range(nz_row_data.shape[0]):

hdbscan/hdbscan_.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ def _hdbscan_sparse_distance_matrix(X, min_samples=5, alpha=1.0,
146146
max_dist = kwargs.get("max_dist", 0.)
147147
mutual_reachability_ = sparse_mutual_reachability(lil_matrix,
148148
min_points=min_samples,
149-
max_dist=max_dist)
149+
max_dist=max_dist,
150+
alpha=alpha)
150151
# Check connected component on mutual reachability
151152
# If more than one component, it means that even if the distance matrix X
152153
# has one component, there exists with less than `min_samples` neighbors

0 commit comments

Comments
 (0)