-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathLinearClassificationTest.scala
33 lines (26 loc) · 1.03 KB
/
LinearClassificationTest.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
// Wei Chen - Linear Classification Test
// 2016-06-04
import com.scalaml.TestData._
import com.scalaml.general.MatrixFunc._
import com.scalaml.algorithm.LinearClassification
import org.scalatest.funsuite.AnyFunSuite
class LinearClassificationSuite extends AnyFunSuite {
val linearC = new LinearClassification()
test("LinearClassification Test : Clear") {
assert(linearC.clear())
}
test("LinearClassification Test : Linear Data") {
assert(linearC.clear())
assert(linearC.config(Map[String, Double]()))
assert(linearC.train(LABELED_LINEAR_DATA))
val result = linearC.predict(UNLABELED_LINEAR_DATA)
assert(arrayequal(result, LABEL_LINEAR_DATA))
}
test("LinearClassification Test : Nonlinear Data - WRONG") {
assert(linearC.clear())
assert(linearC.config(Map[String, Double]()))
assert(linearC.train(LABELED_NONLINEAR_DATA))
val result = linearC.predict(UNLABELED_NONLINEAR_DATA)
assert(!arrayequal(result, LABEL_NONLINEAR_DATA))
}
}