-
Notifications
You must be signed in to change notification settings - Fork 0
/
isotonic_test.go
37 lines (31 loc) · 1.11 KB
/
isotonic_test.go
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
package DragonBlood
import "testing"
// RocArea computes the area under the ROC curve
// score is any score that orders the data (e.g. a probability estimate)
// target contains the labels (True == positive; False == negative)
func TestIsotonic(test *testing.T) {
x, y := Isotonic(
[]float64{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0},
[]float64{1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0})
expectedX := []float64{1.0, 3.0, 7.0}
expectedY := []float64{0.5, 0.75, 5.0 / 6.0}
for i := range x {
if x[i] != expectedX[i] {
test.Errorf("x[%d] was %g; expected %g", i, x[i], expectedX[i])
}
if y[i] != expectedY[i] {
test.Errorf("y[%d] was %g; expected %g", i, y[i], expectedY[i])
}
}
x, y = Isotonic(
[]float64{12.0, 11.0, 10.0, 9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0},
[]float64{0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0})
for i := range x {
if x[i] != expectedX[i] {
test.Errorf("x[%d] was %g; expected %g", i, x[i], expectedX[i])
}
if y[i] != expectedY[i] {
test.Errorf("y[%d] was %g; expected %g", i, y[i], expectedY[i])
}
}
}