@@ -135,8 +135,9 @@ function _dbs_expand_cluster!(D::AbstractMatrix{T}, # distance matrix
135
135
end
136
136
137
137
"""
138
- dbscan(points::AbstractMatrix, radius::Real,
139
- [leafsize], [min_neighbors], [min_cluster_size]) -> Vector{DbscanCluster}
138
+ dbscan(points::AbstractMatrix, radius::Real;
139
+ [min_neighbors], [min_cluster_size],
140
+ [nntree_kwargs...]) -> Vector{DbscanCluster}
140
141
141
142
Cluster `points` using the DBSCAN (density-based spatial clustering of
142
143
applications with noise) algorithm.
@@ -147,15 +148,14 @@ applications with noise) algorithm.
147
148
- `radius::Real`: query radius
148
149
149
150
Optional keyword arguments to control the algorithm:
150
- - `leafsize::Int` (defaults to 20): the number of points binned in each
151
- leaf node in the `KDTree`
152
- - `min_neighbors::Int` (defaults to 1): the minimum number of a *core* point
151
+ - `min_neighbors::Integer` (defaults to 1): the minimum number of a *core* point
153
152
neighbors
154
- - `min_cluster_size::Int ` (defaults to 1): the minimum number of points in
153
+ - `min_cluster_size::Integer ` (defaults to 1): the minimum number of points in
155
154
a valid cluster
155
+ - `nntree_kwargs`: parameters (like `leafsize`) for the `KDTree` contructor
156
156
157
- # Example
158
- ``` julia
157
+ ## Example
158
+ ```julia
159
159
points = randn(3, 10000)
160
160
# DBSCAN clustering, clusters with less than 20 points will be discarded:
161
161
clusters = dbscan(points, 0.05, min_neighbors = 3, min_cluster_size = 20)
@@ -171,15 +171,19 @@ clusters = dbscan(points, 0.05, min_neighbors = 3, min_cluster_size = 20)
171
171
(Still) Use DBSCAN"*, ACM Transactions on Database Systems,
172
172
Vol.42(3)3, pp. 1--21, https://doi.org/10.1145/3068335
173
173
"""
174
- function dbscan (points:: AbstractMatrix , radius:: Real ; leafsize:: Int = 20 , kwargs ... )
175
- kdtree = KDTree (points; leafsize= leafsize)
176
- return _dbscan (kdtree, points, radius; kwargs ... )
174
+ function dbscan (points:: AbstractMatrix , radius:: Real ;
175
+ min_neighbors:: Integer = 1 , min_cluster_size:: Integer = 1 ,
176
+ nntree_kwargs... )
177
+ kdtree = KDTree (points; nntree_kwargs... )
178
+ return _dbscan (kdtree, points, radius;
179
+ min_neighbors= min_neighbors,
180
+ min_cluster_size= min_cluster_size)
177
181
end
178
182
179
183
180
184
# An implementation of DBSCAN algorithm that keeps track of both the core and boundary points
181
185
function _dbscan (kdtree:: KDTree , points:: AbstractMatrix , radius:: Real ;
182
- min_neighbors:: Int = 1 , min_cluster_size:: Int = 1 )
186
+ min_neighbors:: Integer = 1 , min_cluster_size:: Integer = 1 )
183
187
dim, num_points = size (points)
184
188
num_points <= dim && throw (ArgumentError (" points has $dim rows and $num_points columns. Must be a D x N matric with D < N" ))
185
189
0 <= radius || throw (ArgumentError (" radius $radius must be ≥ 0" ))
0 commit comments