File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change 1
1
@testset " KMedoids" begin
2
2
@test ! isrevertible (KMedoids (3 ))
3
- @test TT. parameters (KMedoids (3 )) == (k= 3 ,)
4
3
4
+ @test TT. parameters (KMedoids (3 )) == (; k= 3 )
5
+
6
+ # basic test with continuous variables
5
7
a = [randn (100 ); 10 .+ randn (100 )]
6
8
b = [randn (100 ); 10 .+ randn (100 )]
7
9
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)
10
+ n = t |> KMedoids (2 ; rng)
11
+ i1 = findall (isequal (1 ), n. cluster)
12
+ i2 = findall (isequal (2 ), n. cluster)
12
13
@test mean (t. a[i1]) > 5
13
14
@test mean (t. b[i1]) > 5
14
15
@test mean (t. a[i2]) < 5
15
16
@test mean (t. b[i2]) < 5
17
+
18
+ # test with mixed variables
19
+ a = [1 , 2 , 3 ]
20
+ b = [1.0 , 2.0 , 3.0 ]
21
+ c = [" a" , " b" , " c" ]
22
+ t = Table (; a, b, c)
23
+ n = t |> KMedoids (3 ; rng)
24
+ @test sort (n. cluster) == [1 , 2 , 3 ]
16
25
end
You can’t perform that action at this time.
0 commit comments