This repository has been archived by the owner on Aug 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
76 lines (58 loc) · 1.84 KB
/
models.py
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
class Series():
id: int
name: str
class Run():
id: int
series_id: int
date: datetime.datetime
def partitioner(self) -> views_partitioning.DataPartitioner:
# ~~ infer partitioner from date + formula ~~ #
return partitioner
class Model():
id: int
name: str
level_of_analysis: str
outcome: str
queryset_name: str
train_start: int
train_end: int
training_date: datetime.datetime
author: str
retrain: bool
constituent_models: Dict[str,"Model"] # str is the name of indep. column
_model_object: scikit_learn_model
def publish(self):
# ~~ publish to object storage ~~ #
@property
def queryset(self) -> viewser.Queryset:
# ~~ get via viewser ~~ #
return queryset
@classmethod
def from_model_object(
cls,
name: str,
level_of_analysis: str,
outcome: str,
train_start: int,
train_end: int,
trained_at: datetime.datetime,
author: str,
constituent_models: Dict[str, "Model"],
model_object: scikit_learn_model) -> "Model":
# ~~ Instantiate new Model from model object ~~ #
return instance
@classmethod
def fetch(self, name) -> "Model"
# ~~ fetch via object storage / database (object + metadata) ~~ #
return instance
class RunResult():
id: int
run_id: int
model_id: int
def publish(self) -> None:
# ~~ Publish predictions to object storage under name ~~ #
name = self.run.series.name + run.series.date + self.model.name
@classmethod
def fetch(cls, name: str) -> "RunResult":
# ~~ Fetch results associated with name ~~ #
return instance