wizata-dsapi 1.3.21__py3-none-any.whl → 1.3.23__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.
- wizata_dsapi/api_config.py +1 -7
- wizata_dsapi/dsapi_json_encoder.py +0 -15
- wizata_dsapi/mlmodel.py +33 -12
- wizata_dsapi/model_toolkit.py +11 -11
- wizata_dsapi/pipeline_image.py +1 -1
- wizata_dsapi/version.py +1 -1
- {wizata_dsapi-1.3.21.dist-info → wizata_dsapi-1.3.23.dist-info}/METADATA +1 -1
- {wizata_dsapi-1.3.21.dist-info → wizata_dsapi-1.3.23.dist-info}/RECORD +11 -11
- {wizata_dsapi-1.3.21.dist-info → wizata_dsapi-1.3.23.dist-info}/WHEEL +0 -0
- {wizata_dsapi-1.3.21.dist-info → wizata_dsapi-1.3.23.dist-info}/licenses/LICENSE.txt +0 -0
- {wizata_dsapi-1.3.21.dist-info → wizata_dsapi-1.3.23.dist-info}/top_level.txt +0 -0
wizata_dsapi/api_config.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
from .plot import Plot
|
|
3
3
|
from .datapoint import DataPoint
|
|
4
4
|
from .datastore import DataStore
|
|
5
|
-
from .mlmodel import
|
|
5
|
+
from .mlmodel import ModelInfo, ModelList
|
|
6
6
|
from .request import Request
|
|
7
7
|
from .execution import Execution, ExecutionStatus
|
|
8
8
|
from .experiment import Experiment
|
|
@@ -76,12 +76,6 @@ _registry = {
|
|
|
76
76
|
"cloud_dsapi": ['lists', 'get_by_id', 'create', 'update', 'delete', 'search'],
|
|
77
77
|
"cloud_context": ['get_by_id', 'create', 'update', 'delete', 'search']
|
|
78
78
|
},
|
|
79
|
-
"mlmodels":
|
|
80
|
-
{
|
|
81
|
-
"class": MLModel,
|
|
82
|
-
"cloud_dsapi": ['lists', 'get_by_id', 'get_by_key', 'delete'],
|
|
83
|
-
"cloud_context": []
|
|
84
|
-
},
|
|
85
79
|
"pipelines":
|
|
86
80
|
{
|
|
87
81
|
"class": Pipeline,
|
|
@@ -3,7 +3,6 @@ import uuid
|
|
|
3
3
|
import pandas
|
|
4
4
|
import time
|
|
5
5
|
|
|
6
|
-
from .mlmodel import MLModel
|
|
7
6
|
from .script import Script
|
|
8
7
|
from .plot import Plot
|
|
9
8
|
from .wizard_function import WizardStep, WizardFunction
|
|
@@ -15,20 +14,6 @@ class DSAPIEncoder(json.JSONEncoder):
|
|
|
15
14
|
def default(self, obj):
|
|
16
15
|
if isinstance(obj, uuid.UUID):
|
|
17
16
|
return str(obj)
|
|
18
|
-
if isinstance(obj, MLModel):
|
|
19
|
-
json_obj = {
|
|
20
|
-
"id": str(obj.model_id),
|
|
21
|
-
"status": str(obj.status),
|
|
22
|
-
"generatedById": str(obj.generatedById),
|
|
23
|
-
"input_columns": list(obj.input_columns),
|
|
24
|
-
"output_columns": list(obj.output_columns),
|
|
25
|
-
"has_anomalies": str(obj.has_anomalies),
|
|
26
|
-
"labels_count": str(obj.label_counts),
|
|
27
|
-
"has_target_feat": str(obj.has_target_feat),
|
|
28
|
-
"needExactColumnNames": str(obj.needExactColumnNames),
|
|
29
|
-
"needExactColumnNumbers": str(obj.needExactColumnNumbers)
|
|
30
|
-
}
|
|
31
|
-
return json_obj
|
|
32
17
|
if isinstance(obj, Script):
|
|
33
18
|
json_obj = {
|
|
34
19
|
"id": str(obj.script_id),
|
wizata_dsapi/mlmodel.py
CHANGED
|
@@ -19,22 +19,33 @@ class ModelInfo:
|
|
|
19
19
|
def __init__(self,
|
|
20
20
|
key: str,
|
|
21
21
|
twin_hardware_id: str = None,
|
|
22
|
-
|
|
22
|
+
property_value: str = None,
|
|
23
23
|
alias: str = None,
|
|
24
24
|
model_type: str = None,
|
|
25
25
|
file_format: str = 'pkl',
|
|
26
|
-
source: str = 'wizata'
|
|
26
|
+
source: str = 'wizata',
|
|
27
|
+
property_name: str = None
|
|
27
28
|
):
|
|
29
|
+
# information identifying a model
|
|
28
30
|
self.key = key
|
|
29
31
|
self.twin_hardware_id = twin_hardware_id
|
|
30
|
-
self.
|
|
32
|
+
self.property_value = property_value
|
|
31
33
|
self.alias = alias
|
|
32
34
|
self.file_format = file_format
|
|
33
35
|
self.source = source
|
|
34
36
|
self.model_type = model_type
|
|
37
|
+
|
|
38
|
+
# files attached to model when loaded
|
|
35
39
|
self.trained_model = None
|
|
36
40
|
self.scaler = None
|
|
37
41
|
|
|
42
|
+
# temporary properties during model generation not generally stored
|
|
43
|
+
self.property_name = property_name
|
|
44
|
+
self.input_columns = None
|
|
45
|
+
self.has_target_feat = False
|
|
46
|
+
self.label_counts = 0
|
|
47
|
+
|
|
48
|
+
|
|
38
49
|
def identifier(self, include_alias: bool = False) -> str:
|
|
39
50
|
"""
|
|
40
51
|
returns the complete string identifier for this model.
|
|
@@ -48,8 +59,8 @@ class ModelInfo:
|
|
|
48
59
|
if self.twin_hardware_id is not None:
|
|
49
60
|
identifier += f".{self.twin_hardware_id}"
|
|
50
61
|
|
|
51
|
-
if self.
|
|
52
|
-
identifier += f".{self.
|
|
62
|
+
if self.property_value is not None:
|
|
63
|
+
identifier += f".{self.property_value}"
|
|
53
64
|
|
|
54
65
|
if include_alias and self.alias is not None:
|
|
55
66
|
identifier += f"@{self.alias}"
|
|
@@ -68,8 +79,8 @@ class ModelInfo:
|
|
|
68
79
|
}
|
|
69
80
|
if self.twin_hardware_id is not None:
|
|
70
81
|
obj["twin_hardware_id"] = str(self.twin_hardware_id)
|
|
71
|
-
if self.
|
|
72
|
-
obj["
|
|
82
|
+
if self.property_value is not None:
|
|
83
|
+
obj["property_value"] = self.property_value
|
|
73
84
|
if self.alias is not None:
|
|
74
85
|
obj["alias"] = self.alias
|
|
75
86
|
if self.model_type is not None:
|
|
@@ -78,6 +89,8 @@ class ModelInfo:
|
|
|
78
89
|
obj["file_format"] = self.file_format
|
|
79
90
|
if self.source is not None:
|
|
80
91
|
obj["source"] = self.source
|
|
92
|
+
if self.property_name is not None:
|
|
93
|
+
obj["property_name"] = self.property_name
|
|
81
94
|
return obj
|
|
82
95
|
|
|
83
96
|
def from_json(self, obj):
|
|
@@ -88,8 +101,8 @@ class ModelInfo:
|
|
|
88
101
|
self.key = obj["key"]
|
|
89
102
|
if "twin_hardware_id" in obj.keys():
|
|
90
103
|
self.twin_hardware_id = obj["twin_hardware_id"]
|
|
91
|
-
if "
|
|
92
|
-
self.property_name = obj["
|
|
104
|
+
if "property_value" in obj.keys():
|
|
105
|
+
self.property_name = obj["property_value"]
|
|
93
106
|
if "alias" in obj.keys():
|
|
94
107
|
self.alias = obj["alias"]
|
|
95
108
|
if "model_type" in obj.keys():
|
|
@@ -98,6 +111,8 @@ class ModelInfo:
|
|
|
98
111
|
self.key = obj["file_format"]
|
|
99
112
|
if "source" in obj.keys():
|
|
100
113
|
self.source = obj["source"]
|
|
114
|
+
if "property_name" in obj.keys():
|
|
115
|
+
self.property_name = obj["property_name"]
|
|
101
116
|
|
|
102
117
|
|
|
103
118
|
class ModelList:
|
|
@@ -194,22 +209,28 @@ class MLModelConfig(ApiDto):
|
|
|
194
209
|
self.model_type = model_type
|
|
195
210
|
self.model_alias = model_alias
|
|
196
211
|
|
|
197
|
-
def create_model_info(self,
|
|
212
|
+
def create_model_info(self,
|
|
213
|
+
hardware_id: str = None,
|
|
214
|
+
property_value: str = None) -> ModelInfo:
|
|
198
215
|
"""
|
|
199
216
|
create model info corresponding to the configuration.
|
|
200
217
|
:param hardware_id: provide a hardware id for this model if by_twin.
|
|
218
|
+
:param property_value: provide a value for this model if by_property.
|
|
201
219
|
:return:
|
|
202
220
|
"""
|
|
203
221
|
if self.by_twin and hardware_id is None:
|
|
204
222
|
raise ValueError('hardware_id is required if by_twin to create a model info')
|
|
223
|
+
if self.by_property and property_value is None:
|
|
224
|
+
raise ValueError('property_value is required if by_property to create a model info')
|
|
205
225
|
model_info = ModelInfo(
|
|
206
226
|
key=self.model_key,
|
|
207
227
|
twin_hardware_id=hardware_id,
|
|
208
|
-
|
|
228
|
+
property_value=property_value,
|
|
209
229
|
source=self.source,
|
|
210
230
|
alias=self.model_alias,
|
|
211
231
|
file_format=self.model_format,
|
|
212
|
-
model_type=self.model_type
|
|
232
|
+
model_type=self.model_type,
|
|
233
|
+
property_name=self.property_name
|
|
213
234
|
)
|
|
214
235
|
return model_info
|
|
215
236
|
|
wizata_dsapi/model_toolkit.py
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import pandas
|
|
2
|
-
from .mlmodel import
|
|
2
|
+
from .mlmodel import ModelInfo
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
def predict(df: pandas.DataFrame,
|
|
5
|
+
def predict(df: pandas.DataFrame, model_info: ModelInfo, mapping_table=None):
|
|
6
6
|
"""
|
|
7
7
|
Execute a Machine Learning models locally.
|
|
8
8
|
:param df: dataframe to use as input.
|
|
9
|
-
:param
|
|
9
|
+
:param model_info: model information handler.
|
|
10
10
|
:param mapping_table: Optional mapping table.
|
|
11
11
|
:return: output dataframe with predicted values.
|
|
12
12
|
"""
|
|
13
|
-
if
|
|
13
|
+
if model_info is None or model_info.trained_model is None or model_info.input_columns is None:
|
|
14
14
|
raise ValueError("Please download your model from DS API before using it.")
|
|
15
15
|
old_index = df.index
|
|
16
16
|
df.index = pandas.to_datetime(df.index)
|
|
17
17
|
df_result = pandas.DataFrame(index=df.index)
|
|
18
|
-
features =
|
|
19
|
-
if
|
|
20
|
-
df_result['result'] =
|
|
18
|
+
features = model_info.input_columns
|
|
19
|
+
if model_info.has_target_feat is True:
|
|
20
|
+
df_result['result'] = model_info.trained_model.detect(df[features]).astype(float)
|
|
21
21
|
else:
|
|
22
|
-
df_result['result'] =
|
|
23
|
-
if
|
|
24
|
-
df_result[__generate_label_columns(
|
|
25
|
-
|
|
22
|
+
df_result['result'] = model_info.trained_model.predict(df[features]).astype(float)
|
|
23
|
+
if model_info.label_counts != 0:
|
|
24
|
+
df_result[__generate_label_columns(model_info.label_counts)] = \
|
|
25
|
+
model_info.trained_model.predict_proba(df[features]).astype(float)
|
|
26
26
|
df_result = df_result.set_index(old_index)
|
|
27
27
|
return df_result
|
|
28
28
|
|
wizata_dsapi/pipeline_image.py
CHANGED
wizata_dsapi/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "1.3.
|
|
1
|
+
__version__ = "1.3.23"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
wizata_dsapi/__init__.py,sha256=MPTx3eqYPaHzIBrnrx27xW2xCliPLHjCYn7ar5FYefY,2040
|
|
2
|
-
wizata_dsapi/api_config.py,sha256=
|
|
2
|
+
wizata_dsapi/api_config.py,sha256=6Pnnv62X_QrTUXaa1MtFZeQaqMUJC-9Y5BW7B4gef10,5139
|
|
3
3
|
wizata_dsapi/api_dto.py,sha256=-NdaTRvw5jW5xFGpIhY8U0-SdvzW2t6QD26y0UPApU0,2238
|
|
4
4
|
wizata_dsapi/api_interface.py,sha256=DURk-0ey16T8sV5e2Y2G_YybPEusJvZuY0oD5L7AnXo,10903
|
|
5
5
|
wizata_dsapi/bucket.py,sha256=Zz9olv-pymikAutGitSuGWrAPiawOTW86JDDHG4ugTc,1150
|
|
@@ -9,19 +9,19 @@ wizata_dsapi/dataframe_toolkit.py,sha256=7D8JrhsFSGXeO3mRAd2e2cLmdjbXRjk04IuaMG8
|
|
|
9
9
|
wizata_dsapi/datapoint.py,sha256=UUatqzWMwC4ucM6HdeQDWtLS4fGqEsDABCNVmxoP5Hg,14635
|
|
10
10
|
wizata_dsapi/datastore.py,sha256=BSHZmCSJ679boBA1eCkaWGJCy1CUeipKKGt2jDHzdVo,2663
|
|
11
11
|
wizata_dsapi/ds_dataframe.py,sha256=Sk2JRUuTRJzko3HosJnbK34STpgSJUlqxLq8w_E5VM4,2089
|
|
12
|
-
wizata_dsapi/dsapi_json_encoder.py,sha256=
|
|
12
|
+
wizata_dsapi/dsapi_json_encoder.py,sha256=_NJE2IncJCS-juOxV_IQWHq8WpaanKe2aWpGNZNUzyk,2062
|
|
13
13
|
wizata_dsapi/evaluation.py,sha256=kB61SD66uRBBbKqiES7XZERn77bwhacbyufneSD4s8c,2222
|
|
14
14
|
wizata_dsapi/execution.py,sha256=JuU8qZDcUZxtCvQwwvM_luwHi18GQ2jbBSxAjc2cSlM,14148
|
|
15
15
|
wizata_dsapi/experiment.py,sha256=QYQ1CJ-MTWsXq08xYbm5sAp95dRxbPOmGDgaAOoBMDQ,4631
|
|
16
16
|
wizata_dsapi/group_system.py,sha256=6rUKe0_J3YWACysyBlzuw_TEpKNXgLOMxhpWsNxOzwY,1708
|
|
17
17
|
wizata_dsapi/ilogger.py,sha256=iYnID-Z-qrYhie26C43404aIuU4_tHSKXbDeQIdo82Q,807
|
|
18
18
|
wizata_dsapi/insight.py,sha256=ABFZ04DqYxxzqAEfU1tzlTZqqrigM-zN-8Lbetko3g0,6468
|
|
19
|
-
wizata_dsapi/mlmodel.py,sha256=
|
|
20
|
-
wizata_dsapi/model_toolkit.py,sha256=
|
|
19
|
+
wizata_dsapi/mlmodel.py,sha256=rsUmkRniFQktXZAiBejdAJQIgnChvi-J_KJJjmifrSI,15681
|
|
20
|
+
wizata_dsapi/model_toolkit.py,sha256=UNyw5CFSgZeXydQFsiDIRTjoMeqIsdyIIuiwumLW5bA,1574
|
|
21
21
|
wizata_dsapi/paged_query_result.py,sha256=0Iyt2Kd4tvrfthhT-tk9EmSERsbJTaPNON2euHcBn6k,1150
|
|
22
22
|
wizata_dsapi/pipeline.py,sha256=WDJeOxPZJiYW1qwTNZUm3jom2epIxqrSoiUwcrTF9EE,31300
|
|
23
23
|
wizata_dsapi/pipeline_deployment.py,sha256=grekBaxUK0EhL9w7lDB8vNuW_wzLnHVm9Mq8Lkbkguk,1722
|
|
24
|
-
wizata_dsapi/pipeline_image.py,sha256=
|
|
24
|
+
wizata_dsapi/pipeline_image.py,sha256=FUxaDDAOZHG8MA2xpZDoG7m1xbtiRSB8YuLFObUSd8c,5274
|
|
25
25
|
wizata_dsapi/plot.py,sha256=SPGKFWWYNcRvHcqvvnPIIIBKsd5UwhdsxLW7b2dG2rs,2360
|
|
26
26
|
wizata_dsapi/request.py,sha256=W4E1BHacQdJiBLPI96yVeHz41rbfFuGrbuw1U60L_DM,27560
|
|
27
27
|
wizata_dsapi/script.py,sha256=DeEciwVpuCYZetgJCoivw_bYe8ma52WuTaTQ_VkLEcg,12930
|
|
@@ -31,7 +31,7 @@ wizata_dsapi/template.py,sha256=wtCRKKk3PchH4RrNgNYlEF_9C6bzZwKIeLyEvgv6Fdo,1370
|
|
|
31
31
|
wizata_dsapi/trigger.py,sha256=w3BZYP-L3SUwvaT0oCTanh_Ewn57peZvlt7vxzHv9J8,5129
|
|
32
32
|
wizata_dsapi/twin.py,sha256=S0DUzQf1smZXZTdXpXZPtkZYCfKIhw53EecCnsl9i4Q,11017
|
|
33
33
|
wizata_dsapi/twinregistration.py,sha256=Mi6-YuwroiEXc0c1hgrOaphh4hNVoHupxOnXedVtJtE,13377
|
|
34
|
-
wizata_dsapi/version.py,sha256=
|
|
34
|
+
wizata_dsapi/version.py,sha256=EGztvYCGaOWq_edANXRtYB9YDbL4jWFHJI9a0CTSz5Y,23
|
|
35
35
|
wizata_dsapi/wizard_function.py,sha256=RbM7W7Gf-6Rhp_1dU9DBYkHaciknGAGvuAndhAS_vyo,942
|
|
36
36
|
wizata_dsapi/wizard_request.py,sha256=v6BaqKLKvTWmUSo0_gda9FabAQz5x_-GOH1Av50GzFo,3762
|
|
37
37
|
wizata_dsapi/wizata_dsapi_client.py,sha256=h8iSz7IGbP-Zq9rbqMdq-hTrt16laD1JeaRWPzaLaoo,77695
|
|
@@ -42,8 +42,8 @@ wizata_dsapi/plots/__init__.py,sha256=qgnSFqrjOPur-807M8uh5awIfjM1ZHXUXcAqHc-r2l
|
|
|
42
42
|
wizata_dsapi/plots/common.py,sha256=jdPsJqLHBwSKc6dX83BSGPqSRxzIVNHSYO5yI_8sjGk,6568
|
|
43
43
|
wizata_dsapi/scripts/__init__.py,sha256=hAxiETSQf0qOHde1si1tEAJU48seqEgHrchCzS2-LvQ,80
|
|
44
44
|
wizata_dsapi/scripts/common.py,sha256=efwq-Rd0lvYljIs3gSFz9izogBD7asOU2cTK-IvHTkM,4244
|
|
45
|
-
wizata_dsapi-1.3.
|
|
46
|
-
wizata_dsapi-1.3.
|
|
47
|
-
wizata_dsapi-1.3.
|
|
48
|
-
wizata_dsapi-1.3.
|
|
49
|
-
wizata_dsapi-1.3.
|
|
45
|
+
wizata_dsapi-1.3.23.dist-info/licenses/LICENSE.txt,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
|
|
46
|
+
wizata_dsapi-1.3.23.dist-info/METADATA,sha256=s72ozfS_1A5XMtwD2-aeYcGdsPAwaluPyME2GP7s7P8,5651
|
|
47
|
+
wizata_dsapi-1.3.23.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
48
|
+
wizata_dsapi-1.3.23.dist-info/top_level.txt,sha256=-OeTJbEnh5DuWyTOHtvw0Dw3LRg3G27TNS6W4ZtfwPs,13
|
|
49
|
+
wizata_dsapi-1.3.23.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|