sdg-core-lib 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sdg_core_lib/NumericDataset.py +150 -0
- sdg_core_lib/__init__.py +0 -0
- sdg_core_lib/browser.py +73 -0
- sdg_core_lib/data_generator/__init__.py +0 -0
- sdg_core_lib/data_generator/model_factory.py +72 -0
- sdg_core_lib/data_generator/models/ModelInfo.py +42 -0
- sdg_core_lib/data_generator/models/TrainingInfo.py +40 -0
- sdg_core_lib/data_generator/models/UnspecializedModel.py +106 -0
- sdg_core_lib/data_generator/models/__init__.py +0 -0
- sdg_core_lib/data_generator/models/keras/KerasBaseVAE.py +172 -0
- sdg_core_lib/data_generator/models/keras/VAE.py +61 -0
- sdg_core_lib/data_generator/models/keras/__init__.py +0 -0
- sdg_core_lib/data_generator/models/keras/implementation/TabularVAE.py +96 -0
- sdg_core_lib/data_generator/models/keras/implementation/TimeSeriesVAE.py +156 -0
- sdg_core_lib/data_generator/models/keras/implementation/__init__.py +0 -0
- sdg_core_lib/evaluate/Metrics.py +48 -0
- sdg_core_lib/evaluate/TabularComparison.py +276 -0
- sdg_core_lib/evaluate/__init__.py +0 -0
- sdg_core_lib/job.py +56 -0
- sdg_core_lib/post_process/FunctionApplier.py +14 -0
- sdg_core_lib/post_process/__init__.py +0 -0
- sdg_core_lib/post_process/function_factory.py +41 -0
- sdg_core_lib/post_process/functions/FunctionInfo.py +25 -0
- sdg_core_lib/post_process/functions/FunctionResult.py +15 -0
- sdg_core_lib/post_process/functions/Parameter.py +33 -0
- sdg_core_lib/post_process/functions/UnspecializedFunction.py +42 -0
- sdg_core_lib/post_process/functions/__init__.py +0 -0
- sdg_core_lib/post_process/functions/distribution_evaluator/__init__.py +0 -0
- sdg_core_lib/post_process/functions/distribution_evaluator/implementation/NormalTester.py +65 -0
- sdg_core_lib/post_process/functions/distribution_evaluator/implementation/__init__.py +0 -0
- sdg_core_lib/post_process/functions/filter/IntervalThreshold.py +32 -0
- sdg_core_lib/post_process/functions/filter/MonoThreshold.py +28 -0
- sdg_core_lib/post_process/functions/filter/__init__.py +0 -0
- sdg_core_lib/post_process/functions/filter/implementation/InnerThreshold.py +43 -0
- sdg_core_lib/post_process/functions/filter/implementation/LowerThreshold.py +32 -0
- sdg_core_lib/post_process/functions/filter/implementation/OuterThreshold.py +42 -0
- sdg_core_lib/post_process/functions/filter/implementation/UpperThreshold.py +32 -0
- sdg_core_lib/post_process/functions/filter/implementation/__init__.py +0 -0
- sdg_core_lib/preprocess/__init__.py +0 -0
- sdg_core_lib/preprocess/scale.py +51 -0
- sdg_core_lib/test/__init__.py +0 -0
- sdg_core_lib/test/data_generator/__init__.py +0 -0
- sdg_core_lib/test/data_generator/models/__init__.py +0 -0
- sdg_core_lib/test/data_generator/models/keras/__init__.py +0 -0
- sdg_core_lib/test/data_generator/models/keras/implementation/__init__.py +0 -0
- sdg_core_lib/test/data_generator/models/keras/implementation/test_TabularVAE.py +120 -0
- sdg_core_lib/test/data_generator/models/keras/implementation/test_TimeSeriesVAE.py +110 -0
- sdg_core_lib/test/data_generator/models/keras/test_KerasBaseVAE.py +74 -0
- sdg_core_lib/test/data_generator/models/test_ModelInfo.py +27 -0
- sdg_core_lib/test/data_generator/models/test_TrainingInfo.py +30 -0
- sdg_core_lib/test/data_generator/models/test_UnspecializedModel.py +32 -0
- sdg_core_lib/test/data_generator/test_model_factory.py +52 -0
- sdg_core_lib/test/evaluate/__init__.py +0 -0
- sdg_core_lib/test/evaluate/test_Metrics.py +62 -0
- sdg_core_lib/test/evaluate/test_TabularComparisonEvaluator.py +75 -0
- sdg_core_lib/test/infer_test.json +168 -0
- sdg_core_lib/test/infer_test_nodata.json +77 -0
- sdg_core_lib/test/infer_test_nodata_wrong.json +11 -0
- sdg_core_lib/test/post_process/__init__.py +0 -0
- sdg_core_lib/test/post_process/functions/__init__.py +0 -0
- sdg_core_lib/test/post_process/functions/distribution_evaluator/__init__.py +0 -0
- sdg_core_lib/test/post_process/functions/distribution_evaluator/implementation/__init__.py +0 -0
- sdg_core_lib/test/post_process/functions/distribution_evaluator/implementation/test_NormalTester.py +55 -0
- sdg_core_lib/test/post_process/functions/filters/__init__.py +0 -0
- sdg_core_lib/test/post_process/functions/filters/implementation/__init__.py +0 -0
- sdg_core_lib/test/post_process/functions/filters/implementation/test_InnerThreshold.py +30 -0
- sdg_core_lib/test/pre_process/__init__.py +0 -0
- sdg_core_lib/test/pre_process/test_scaling.py +55 -0
- sdg_core_lib/test/test_browser.py +11 -0
- sdg_core_lib/test/test_dataset.py +149 -0
- sdg_core_lib/test/test_job.py +128 -0
- sdg_core_lib/test/train_test.json +166 -0
- sdg_core_lib/test/train_test_2.json +9 -0
- sdg_core_lib-0.1.0.dist-info/METADATA +9 -0
- sdg_core_lib-0.1.0.dist-info/RECORD +77 -0
- sdg_core_lib-0.1.0.dist-info/WHEEL +4 -0
- sdg_core_lib-0.1.0.dist-info/entry_points.txt +3 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import shutil
|
|
2
|
+
import pytest
|
|
3
|
+
from sdg_core_lib.job import job
|
|
4
|
+
import json
|
|
5
|
+
import os
|
|
6
|
+
|
|
7
|
+
current_folder = os.path.dirname(os.path.abspath(__file__))
|
|
8
|
+
train_request = json.load(open(os.path.join(current_folder, "train_test.json")))
|
|
9
|
+
train_request_2 = json.load(open(os.path.join(current_folder, "train_test_2.json")))
|
|
10
|
+
|
|
11
|
+
infer_request = json.load(open(os.path.join(current_folder, "infer_test.json")))
|
|
12
|
+
infer_nodata_request = json.load(
|
|
13
|
+
open(os.path.join(current_folder, "infer_test_nodata.json"))
|
|
14
|
+
)
|
|
15
|
+
infer_nodata_request_wrong = json.load(
|
|
16
|
+
open(os.path.join(current_folder, "infer_test_nodata_wrong.json"))
|
|
17
|
+
)
|
|
18
|
+
output_folder = os.path.join(current_folder, "outputs")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@pytest.fixture()
|
|
22
|
+
def setup():
|
|
23
|
+
if not os.path.isdir(output_folder):
|
|
24
|
+
os.mkdir(output_folder)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@pytest.fixture()
|
|
28
|
+
def teardown():
|
|
29
|
+
yield
|
|
30
|
+
if os.path.isdir(output_folder):
|
|
31
|
+
shutil.rmtree(output_folder)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_train_timeseries(setup):
|
|
35
|
+
model_info = train_request_2["model"]
|
|
36
|
+
dataset = train_request_2["dataset"]
|
|
37
|
+
n_rows = train_request_2["n_rows"]
|
|
38
|
+
save_filepath = output_folder
|
|
39
|
+
|
|
40
|
+
results, metrics, model, data = job(
|
|
41
|
+
model_info=model_info,
|
|
42
|
+
dataset=dataset,
|
|
43
|
+
n_rows=n_rows,
|
|
44
|
+
save_filepath=save_filepath,
|
|
45
|
+
train=True,
|
|
46
|
+
)
|
|
47
|
+
assert isinstance(results, list)
|
|
48
|
+
assert results is not None
|
|
49
|
+
assert model is not None
|
|
50
|
+
assert data is not None
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def test_train(setup):
|
|
54
|
+
model_info = train_request["model"]
|
|
55
|
+
dataset = train_request["dataset"]
|
|
56
|
+
n_rows = train_request["n_rows"]
|
|
57
|
+
save_filepath = output_folder
|
|
58
|
+
|
|
59
|
+
results, metrics, model, data = job(
|
|
60
|
+
model_info=model_info,
|
|
61
|
+
dataset=dataset,
|
|
62
|
+
n_rows=n_rows,
|
|
63
|
+
save_filepath=save_filepath,
|
|
64
|
+
train=True,
|
|
65
|
+
)
|
|
66
|
+
assert isinstance(results, list)
|
|
67
|
+
assert results is not None
|
|
68
|
+
assert metrics is not None
|
|
69
|
+
assert model is not None
|
|
70
|
+
assert data is not None
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def test_infer(setup):
|
|
74
|
+
model_info = infer_request["model"]
|
|
75
|
+
model_info["image"] = output_folder
|
|
76
|
+
dataset = infer_request["dataset"]
|
|
77
|
+
n_rows = infer_request["n_rows"]
|
|
78
|
+
save_filepath = output_folder
|
|
79
|
+
|
|
80
|
+
results, metrics, model, data = job(
|
|
81
|
+
model_info=model_info,
|
|
82
|
+
dataset=dataset,
|
|
83
|
+
n_rows=n_rows,
|
|
84
|
+
save_filepath=save_filepath,
|
|
85
|
+
train=False,
|
|
86
|
+
)
|
|
87
|
+
assert isinstance(results, list)
|
|
88
|
+
assert results is not None
|
|
89
|
+
assert metrics is not None
|
|
90
|
+
assert model is not None
|
|
91
|
+
assert data is not None
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def test_infer_nodata_wrong(setup):
|
|
95
|
+
model_info = infer_nodata_request_wrong["model"]
|
|
96
|
+
model_info["image"] = output_folder
|
|
97
|
+
n_rows = infer_nodata_request_wrong["n_rows"]
|
|
98
|
+
save_filepath = output_folder
|
|
99
|
+
|
|
100
|
+
with pytest.raises(ValueError) as exception_info:
|
|
101
|
+
_, _, _, _ = job(
|
|
102
|
+
model_info=model_info,
|
|
103
|
+
dataset=[],
|
|
104
|
+
n_rows=n_rows,
|
|
105
|
+
save_filepath=save_filepath,
|
|
106
|
+
train=False,
|
|
107
|
+
)
|
|
108
|
+
assert exception_info.type is ValueError
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def test_infer_nodata(setup, teardown):
|
|
112
|
+
model_info = infer_nodata_request["model"]
|
|
113
|
+
model_info["image"] = output_folder
|
|
114
|
+
n_rows = infer_nodata_request["n_rows"]
|
|
115
|
+
save_filepath = output_folder
|
|
116
|
+
|
|
117
|
+
results, metrics, model, data = job(
|
|
118
|
+
model_info=model_info,
|
|
119
|
+
dataset=[],
|
|
120
|
+
n_rows=n_rows,
|
|
121
|
+
save_filepath=save_filepath,
|
|
122
|
+
train=False,
|
|
123
|
+
)
|
|
124
|
+
assert isinstance(results, list)
|
|
125
|
+
assert results is not None
|
|
126
|
+
assert metrics is not None
|
|
127
|
+
assert model is not None
|
|
128
|
+
assert data is not None
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
{
|
|
2
|
+
"dataset": [
|
|
3
|
+
{
|
|
4
|
+
"column_data": [
|
|
5
|
+
13.71,
|
|
6
|
+
13.4,
|
|
7
|
+
13.27,
|
|
8
|
+
13.17,
|
|
9
|
+
14.13
|
|
10
|
+
],
|
|
11
|
+
"column_name": "alcohol",
|
|
12
|
+
"column_type": "continuous",
|
|
13
|
+
"column_datatype": "float64"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"column_data": [
|
|
17
|
+
5.65,
|
|
18
|
+
3.91,
|
|
19
|
+
4.28,
|
|
20
|
+
2.59,
|
|
21
|
+
4.1
|
|
22
|
+
],
|
|
23
|
+
"column_name": "malic_acid",
|
|
24
|
+
"column_type": "continuous",
|
|
25
|
+
"column_datatype": "float64"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"column_data": [
|
|
29
|
+
2.45,
|
|
30
|
+
2.48,
|
|
31
|
+
2.26,
|
|
32
|
+
2.37,
|
|
33
|
+
2.74
|
|
34
|
+
],
|
|
35
|
+
"column_name": "ash",
|
|
36
|
+
"column_type": "continuous",
|
|
37
|
+
"column_datatype": "float64"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"column_data": [
|
|
41
|
+
20.5,
|
|
42
|
+
23.0,
|
|
43
|
+
20.0,
|
|
44
|
+
20.0,
|
|
45
|
+
24.5
|
|
46
|
+
],
|
|
47
|
+
"column_name": "acl",
|
|
48
|
+
"column_type": "continuous",
|
|
49
|
+
"column_datatype": "float64"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"column_data": [
|
|
53
|
+
95,
|
|
54
|
+
102,
|
|
55
|
+
120,
|
|
56
|
+
120,
|
|
57
|
+
96
|
|
58
|
+
],
|
|
59
|
+
"column_name": "Mmg",
|
|
60
|
+
"column_type": "continuous",
|
|
61
|
+
"column_datatype": "int64"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"column_data": [
|
|
65
|
+
1.68,
|
|
66
|
+
1.8,
|
|
67
|
+
1.59,
|
|
68
|
+
1.65,
|
|
69
|
+
2.05
|
|
70
|
+
],
|
|
71
|
+
"column_name": "phenols",
|
|
72
|
+
"column_type": "continuous",
|
|
73
|
+
"column_datatype": "float64"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"column_data": [
|
|
77
|
+
0.61,
|
|
78
|
+
0.75,
|
|
79
|
+
0.69,
|
|
80
|
+
0.68,
|
|
81
|
+
0.76
|
|
82
|
+
],
|
|
83
|
+
"column_name": "flavanoids",
|
|
84
|
+
"column_type": "continuous",
|
|
85
|
+
"column_datatype": "float64"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"column_data": [
|
|
89
|
+
0.52,
|
|
90
|
+
0.43,
|
|
91
|
+
0.43,
|
|
92
|
+
0.53,
|
|
93
|
+
0.56
|
|
94
|
+
],
|
|
95
|
+
"column_name": "nonflavanoid_phenols",
|
|
96
|
+
"column_type": "continuous",
|
|
97
|
+
"column_datatype": "float64"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"column_data": [
|
|
101
|
+
1.06,
|
|
102
|
+
1.41,
|
|
103
|
+
1.35,
|
|
104
|
+
1.46,
|
|
105
|
+
1.35
|
|
106
|
+
],
|
|
107
|
+
"column_name": "proanth",
|
|
108
|
+
"column_type": "continuous",
|
|
109
|
+
"column_datatype": "float64"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"column_data": [
|
|
113
|
+
7.7,
|
|
114
|
+
7.3,
|
|
115
|
+
10.2,
|
|
116
|
+
9.3,
|
|
117
|
+
9.2
|
|
118
|
+
],
|
|
119
|
+
"column_name": "color_int",
|
|
120
|
+
"column_type": "continuous",
|
|
121
|
+
"column_datatype": "float64"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"column_data": [
|
|
125
|
+
0.64,
|
|
126
|
+
0.7,
|
|
127
|
+
0.59,
|
|
128
|
+
0.6,
|
|
129
|
+
0.61
|
|
130
|
+
],
|
|
131
|
+
"column_name": "hue",
|
|
132
|
+
"column_type": "continuous",
|
|
133
|
+
"column_datatype": "float64"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"column_data": [
|
|
137
|
+
3.92,
|
|
138
|
+
3.4,
|
|
139
|
+
3.17,
|
|
140
|
+
3.45,
|
|
141
|
+
2.93
|
|
142
|
+
],
|
|
143
|
+
"column_name": "od",
|
|
144
|
+
"column_type": "continuous",
|
|
145
|
+
"column_datatype": "float64"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"column_data": [
|
|
149
|
+
740,
|
|
150
|
+
750,
|
|
151
|
+
835,
|
|
152
|
+
840,
|
|
153
|
+
560
|
|
154
|
+
],
|
|
155
|
+
"column_name": "prolin",
|
|
156
|
+
"column_type": "continuous",
|
|
157
|
+
"column_datatype": "int64"
|
|
158
|
+
}
|
|
159
|
+
],
|
|
160
|
+
"behavious_id" : [],
|
|
161
|
+
"model": {
|
|
162
|
+
"algorithm_name": "sdg_core_lib.data_generator.models.keras.implementation.TabularVAE.TabularVAE",
|
|
163
|
+
"model_name": "Test-T_VAE"
|
|
164
|
+
},
|
|
165
|
+
"n_rows": 1000
|
|
166
|
+
}
|