-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel_app.py
87 lines (58 loc) · 1.61 KB
/
model_app.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
77
78
79
80
81
82
83
84
85
86
87
from typing import Any
from pandas import DataFrame
from typing import Dict
from typing import List
from typing import Tuple
import os
import yaml
import src.model_classes as mc
package_dir = os.path.dirname(os.path.abspath(__file__))
config_fp = os.path.join(package_dir, "config_app.yaml")
with open(config_fp) as f:
config_app = yaml.safe_load(f)
class Model:
"""
"""
def __init__(
self,
df: DataFrame,
config: Dict[str, Any]
):
"""
"""
self.df = df
self.config = config
def prep(
self
) -> Tuple[DataFrame, List[float]]:
"""
"""
df = self.df
config = self.config
# ingest
prep = mc.Ingest(config)
df_prep: DataFrame = prep.run_harmonize(df)
# transform
trans = mc.Transform(df=df_prep)
tbl: List[float] = trans.run_build_cont_table()
return df_prep, tbl
def analysis(
self,
df_prep: DataFrame,
tbl: List[float]
) -> DataFrame:
"""
"""
config = self.config
combined_config = {**config, **config_app}
stats = mc.StatsTesting2x2Cont(
config=combined_config,
tbl=tbl,
df=df_prep
)
df_result: DataFrame = stats.run_testing()
return df_result
if __name__ == "__main__":
model = Model()
df_prep, tbl = model.prep()
df_result = model.analysis(df_prep.copy(), tbl)