-
Notifications
You must be signed in to change notification settings - Fork 3
/
segmentml_test.go
49 lines (37 loc) · 1.26 KB
/
segmentml_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
38
39
40
41
42
43
44
45
46
47
48
49
package lytics
import (
"testing"
"github.com/bmizerany/assert"
"github.com/jarcoal/httpmock"
"github.com/lytics/go-lytics/mock"
)
func TestGetSegmentMLModel(t *testing.T) {
httpmock.Activate()
defer httpmock.DeactivateAndReset()
mock.RegisterSegmentMLMocks()
client := NewLytics(mock.MockApiKey, nil)
model, err := client.GetSegmentMLModel(mock.MockSegmentMLID)
assert.Equal(t, err, nil)
assert.Equal(t, model.Name, mock.MockSegmentMLID)
assert.Equal(t, model.Features[0].Importance, 0.1671249745886582)
assert.Equal(t, model.Summary.Conf.FalseNegative, 0)
}
func TestGetSegmentMLModels(t *testing.T) {
httpmock.Activate()
defer httpmock.DeactivateAndReset()
mock.RegisterSegmentMLMocks()
client := NewLytics(mock.MockApiKey, nil)
models, err := client.GetSegmentMLModels()
assert.Equal(t, err, nil)
assert.Equal(t, len(models), 2)
first := models[0]
// assert.T(t, ok)
second := models[1]
// assert.T(t, ok)
assert.Equal(t, first.Name, "all::ly_binge_user")
assert.Equal(t, first.Features[0].Importance, 0.03761499492078325)
assert.Equal(t, first.Summary.Mse, 0.002072189145635414)
assert.Equal(t, second.Name, "all::ly_infrequent_user")
assert.Equal(t, second.Features[0].Type, "numeric")
assert.Equal(t, second.Summary.Rsq, 0.9389252943819426)
}