class Model(db.Document): name = db.StringField(max_length=128, required=True) oid = db.ObjectIdField(required=True) creator = db.ObjectIdField(required=True) positive_class = db.StringField(max_length=128, default='Positive') negative_class = db.StringField(max_length=128, default='Negative') @property def classes(self): return [self.positive_class, self.negative_class]
class User(db.Document): """User document stores information about a user.""" email = db.EmailField(required=True, unique=True) # What if user belongs to multiple organizations? oid = db.ObjectIdField() # Extra meta. first_name = db.StringField(max_length=NAME_MAX_LENGTH) last_name = db.StringField(max_length=NAME_MAX_LENGTH)
class Result(db.Document): mid = db.ObjectIdField(required=True) pid = db.ObjectIdField(required=True) identifier = db.StringField(max_length=128) value = db.StringField(max_length=128) @property def model(self): return Model.objects.get(id=self.mid) @property def prediction(self): return Prediction.objects.get(id=self.pid)
class Prediction(db.Document): mid = db.ObjectIdField(required=True) value = db.StringField(max_length=128) # User specified identifier of the persisted entity in the client code so # that a Result can be matched with a Prediction identifier = db.StringField(max_length=128) # Note that probability and threshold are both of the positive class. threshold = db.DecimalField(min_value=0, max_value=1, precision=2) probability = db.DecimalField(min_value=0, max_value=1, precision=2, required=True) @property def model(self): return Model.objects.get(id=self.mid)
class Organization(db.Document): """Organization document stores information about a company.""" name = db.StringField(required=True)