-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprediction.go
55 lines (44 loc) · 1.37 KB
/
prediction.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
50
51
52
53
54
55
package evaluation
import (
"time"
"github.com/rai-project/database"
"github.com/rai-project/database/mongodb"
"github.com/rai-project/dlframework"
"gopkg.in/mgo.v2/bson"
)
type InputPrediction struct {
ID bson.ObjectId `json:"id,omitempty" bson:"_id,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
InputID string `json:"input_id,omitempty"`
InputIndex int `json:"input_index,omitempty"`
ExpectedLabel string `json:"expected_label,omitempty"`
Features dlframework.Features `json:"features,omitempty"`
}
func (InputPrediction) TableName() string {
return "input_prediction"
}
type InputPredictionCollection struct {
*mongodb.MongoTable
}
func NewInputPredictionCollection(db database.Database) (*InputPredictionCollection, error) {
tbl, err := mongodb.NewTable(db, InputPrediction{}.TableName())
if err != nil {
return nil, err
}
tbl.Create(nil)
return &InputPredictionCollection{
MongoTable: tbl.(*mongodb.MongoTable),
}, nil
}
func (c *InputPredictionCollection) Find(as ...interface{}) ([]InputPrediction, error) {
preds := []InputPrediction{}
collection := c.Session.Collection(c.Name())
err := collection.Find(as...).All(&preds)
if err != nil {
return nil, err
}
return preds, nil
}
func (m *InputPredictionCollection) Close() error {
return nil
}