-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathIsolationTreeTest.scala
More file actions
30 lines (24 loc) · 924 Bytes
/
IsolationTreeTest.scala
File metadata and controls
30 lines (24 loc) · 924 Bytes
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
// Wei Chen - Isolation Tree Test
// 2022-03-05
import com.scalaml.TestData._
import com.scalaml.general.MatrixFunc._
import com.scalaml.algorithm.IsolationTree
import org.scalatest.funsuite.AnyFunSuite
class IsolationTreeSuite extends AnyFunSuite {
val itree = new IsolationTree()
test("IsolationTree Test : Clear") {
assert(itree.clear())
}
test("IsolationTree Test : Abnormal Large Data") {
assert(itree.clear())
assert(itree.config(Map[String, Double]()))
assert(itree.train(UNLABELED_LARGE_DATA))
val result = itree.predict(UNLABELED_LARGE_DATA)
assert(arraysimilar(result, UNLABELED_LARGE_DATA.map(_ => 1.0), UNLABELED_NONLINEAR_DATA.size))
}
test("IsolationTree Test : Invalid Data") {
assert(itree.clear())
assert(!itree.config(Map("maxLayer" -> "test")))
assert(!itree.train(Array(Array(1, 2), Array())))
}
}