|
60 | 60 | end
|
61 | 61 | end
|
62 | 62 |
|
| 63 | +@testset "detecting outliers (#190)" begin |
| 64 | + v = vcat([.828 .134 .821 .630 .784 .674 .436 .089 .777 .526 .200 .908 .929 .835 .553 .647 .672 .234 .536 .617]) |
| 65 | + r = @inferred(dbscan(v, 0.075, min_cluster_size=3)) |
| 66 | + @test nclusters(r) == 3 |
| 67 | + @test findall(==(0), r.assignments) == [7] |
| 68 | + @test r.clusters[1].core_indices == [1, 3, 5, 9, 12, 13, 14] |
| 69 | + @test isempty(r.clusters[1].boundary_indices) |
| 70 | + @test r.clusters[2].core_indices == [2, 8, 11, 18] |
| 71 | + @test isempty(r.clusters[2].boundary_indices) |
| 72 | + @test r.clusters[3].core_indices == [4, 6, 10, 15, 16, 17, 19, 20] |
| 73 | + @test isempty(r.clusters[3].boundary_indices) |
| 74 | + |
| 75 | + # outlier pt #7 assigned to a 3rd cluster when bigger radius is used |
| 76 | + r2 = @inferred(dbscan(v, 0.1, min_cluster_size=3)) |
| 77 | + @test r2.assignments == setindex!(copy(r.assignments), 3, 7) |
| 78 | +end |
| 79 | + |
63 | 80 | @testset "normal points" begin
|
64 | 81 | p0 = randn(StableRNG(0), 3, 1000)
|
65 | 82 | p1 = randn(StableRNG(1), 3, 1000) .+ [3.0, 3.0, 0.0]
|
|
0 commit comments