Skip to content

Commit 6643e90

Browse files
committed
Add basic test for KMedoids
1 parent 087c96e commit 6643e90

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/transforms/kmedoids.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
@testset "KMedoids" begin
22
@test !isrevertible(KMedoids(3))
33
@test TT.parameters(KMedoids(3)) == (k=3,)
4+
5+
a = [randn(100); 10 .+ randn(100)]
6+
b = [randn(100); 10 .+ randn(100)]
7+
t = Table(; a, b)
8+
9+
c = t |> KMedoids(2; rng)
10+
i1 = findall(isequal(1), c.cluster)
11+
i2 = findall(isequal(2), c.cluster)
12+
@test mean(t.a[i1]) > 5
13+
@test mean(t.b[i1]) > 5
14+
@test mean(t.a[i2]) < 5
15+
@test mean(t.b[i2]) < 5
416
end

0 commit comments

Comments
 (0)