-
Notifications
You must be signed in to change notification settings - Fork 9
/
EMClusterTest.scala
37 lines (31 loc) · 1.16 KB
/
EMClusterTest.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Wei Chen - Estimation Maximization Cluster Test
// 2016-06-04
import com.scalaml.TestData._
import com.scalaml.general.MatrixFunc._
import com.scalaml.algorithm.EMCluster
import org.scalatest.funsuite.AnyFunSuite
class EMClusterSuite extends AnyFunSuite {
val em = new EMCluster()
test("EMCluster Test : Clustering Tiny Data") {
assert(em.clear())
assert(em.config(Map("k" -> 2, "iter" -> 100)))
val result = em.cluster(UNLABELED_TINY_DATA)
assert(arrayequal(result, LABEL_TINY_DATA))
}
test("EMCluster Test : Clustering Small Data - WRONG") {
assert(em.clear())
assert(em.config(Map("k" -> 2, "iter" -> 100)))
val result = em.cluster(UNLABELED_SMALL_DATA)
assert(!arrayequal(result, LABEL_SMALL_DATA))
}
test("EMCluster Test : Clustering Large Data - WRONG") {
assert(em.clear())
assert(em.config(Map("k" -> 2, "iter" -> 100)))
val result = em.cluster(UNLABELED_LARGE_DATA)
assert(!arrayequal(result, LABEL_LARGE_DATA))
}
test("EMCluster Test : Invalid Config") {
assert(em.clear())
assert(!em.config(Map("k" -> "test")))
}
}