wizata-dsapi 1.3.21__tar.gz → 1.3.24__tar.gz

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.
Files changed (54) hide show
  1. {wizata_dsapi-1.3.21/wizata_dsapi.egg-info → wizata_dsapi-1.3.24}/PKG-INFO +1 -1
  2. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/api_config.py +1 -7
  3. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/dsapi_json_encoder.py +0 -15
  4. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/mlmodel.py +35 -12
  5. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/model_toolkit.py +11 -11
  6. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/pipeline_image.py +1 -1
  7. wizata_dsapi-1.3.24/wizata_dsapi/version.py +1 -0
  8. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24/wizata_dsapi.egg-info}/PKG-INFO +1 -1
  9. wizata_dsapi-1.3.21/wizata_dsapi/version.py +0 -1
  10. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/LICENSE.txt +0 -0
  11. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/README.rst +0 -0
  12. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/setup.cfg +0 -0
  13. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/setup.py +0 -0
  14. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/__init__.py +0 -0
  15. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/api_dto.py +0 -0
  16. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/api_interface.py +0 -0
  17. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/bucket.py +0 -0
  18. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/business_label.py +0 -0
  19. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/context.py +0 -0
  20. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/dataframe_toolkit.py +0 -0
  21. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/datapoint.py +0 -0
  22. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/datastore.py +0 -0
  23. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/ds_dataframe.py +0 -0
  24. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/evaluation.py +0 -0
  25. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/execution.py +0 -0
  26. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/experiment.py +0 -0
  27. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/group_system.py +0 -0
  28. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/ilogger.py +0 -0
  29. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/insight.py +0 -0
  30. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/models/__init__.py +0 -0
  31. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/models/common.py +0 -0
  32. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/paged_query_result.py +0 -0
  33. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/pipeline.py +0 -0
  34. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/plot.py +0 -0
  35. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/plots/__init__.py +0 -0
  36. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/plots/common.py +0 -0
  37. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/request.py +0 -0
  38. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/script.py +0 -0
  39. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/scripts/__init__.py +0 -0
  40. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/scripts/common.py +0 -0
  41. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/solution_component.py +0 -0
  42. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/streamlit_utils.py +0 -0
  43. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/template.py +0 -0
  44. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/trigger.py +0 -0
  45. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/twin.py +0 -0
  46. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/twinregistration.py +0 -0
  47. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/wizard_function.py +0 -0
  48. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/wizard_request.py +0 -0
  49. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/wizata_dsapi_client.py +0 -0
  50. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi/words.py +0 -0
  51. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi.egg-info/SOURCES.txt +0 -0
  52. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi.egg-info/dependency_links.txt +0 -0
  53. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi.egg-info/requires.txt +0 -0
  54. {wizata_dsapi-1.3.21 → wizata_dsapi-1.3.24}/wizata_dsapi.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wizata_dsapi
3
- Version: 1.3.21
3
+ Version: 1.3.24
4
4
  Summary: Wizata Data Science Toolkit
5
5
  Author: Wizata S.A.
6
6
  Author-email: info@wizata.com
@@ -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 MLModel
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),
@@ -19,22 +19,33 @@ class ModelInfo:
19
19
  def __init__(self,
20
20
  key: str,
21
21
  twin_hardware_id: str = None,
22
- property_name: str = None,
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.property_name = property_name
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.property_name is not None:
52
- identifier += f".{self.property_name}"
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.property_name is not None:
72
- obj["property_name"] = self.property_name
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,10 @@ 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
94
+ if self.identifier is not None:
95
+ obj["identifier"] = self.identifier(include_alias=True)
81
96
  return obj
82
97
 
83
98
  def from_json(self, obj):
@@ -88,8 +103,8 @@ class ModelInfo:
88
103
  self.key = obj["key"]
89
104
  if "twin_hardware_id" in obj.keys():
90
105
  self.twin_hardware_id = obj["twin_hardware_id"]
91
- if "property_name" in obj.keys():
92
- self.property_name = obj["property_name"]
106
+ if "property_value" in obj.keys():
107
+ self.property_name = obj["property_value"]
93
108
  if "alias" in obj.keys():
94
109
  self.alias = obj["alias"]
95
110
  if "model_type" in obj.keys():
@@ -98,6 +113,8 @@ class ModelInfo:
98
113
  self.key = obj["file_format"]
99
114
  if "source" in obj.keys():
100
115
  self.source = obj["source"]
116
+ if "property_name" in obj.keys():
117
+ self.property_name = obj["property_name"]
101
118
 
102
119
 
103
120
  class ModelList:
@@ -194,22 +211,28 @@ class MLModelConfig(ApiDto):
194
211
  self.model_type = model_type
195
212
  self.model_alias = model_alias
196
213
 
197
- def create_model_info(self, hardware_id: str = None) -> ModelInfo:
214
+ def create_model_info(self,
215
+ hardware_id: str = None,
216
+ property_value: str = None) -> ModelInfo:
198
217
  """
199
218
  create model info corresponding to the configuration.
200
219
  :param hardware_id: provide a hardware id for this model if by_twin.
220
+ :param property_value: provide a value for this model if by_property.
201
221
  :return:
202
222
  """
203
223
  if self.by_twin and hardware_id is None:
204
224
  raise ValueError('hardware_id is required if by_twin to create a model info')
225
+ if self.by_property and property_value is None:
226
+ raise ValueError('property_value is required if by_property to create a model info')
205
227
  model_info = ModelInfo(
206
228
  key=self.model_key,
207
229
  twin_hardware_id=hardware_id,
208
- property_name=self.property_name,
230
+ property_value=property_value,
209
231
  source=self.source,
210
232
  alias=self.model_alias,
211
233
  file_format=self.model_format,
212
- model_type=self.model_type
234
+ model_type=self.model_type,
235
+ property_name=self.property_name
213
236
  )
214
237
  return model_info
215
238
 
@@ -1,28 +1,28 @@
1
1
  import pandas
2
- from .mlmodel import MLModel
2
+ from .mlmodel import ModelInfo
3
3
 
4
4
 
5
- def predict(df: pandas.DataFrame, ml_model: MLModel, mapping_table=None):
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 ml_model: trained machine learning model.
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 ml_model is None or ml_model.trained_model is None or ml_model.input_columns is None:
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 = ml_model.input_columns
19
- if ml_model.has_target_feat is True:
20
- df_result['result'] = ml_model.trained_model.detect(df[features]).astype(float)
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'] = ml_model.trained_model.predict(df[features]).astype(float)
23
- if ml_model.label_counts != 0:
24
- df_result[__generate_label_columns(ml_model.label_counts)] = \
25
- ml_model.trained_model.predict_proba(df[features]).astype(float)
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
 
@@ -3,7 +3,7 @@ import json
3
3
  from .api_dto import ApiDto
4
4
  from .pipeline import Pipeline
5
5
  from .script import Script
6
- from .mlmodel import MLModel
6
+ from .mlmodel import ModelInfo
7
7
  from datetime import datetime
8
8
 
9
9
  import pytz
@@ -0,0 +1 @@
1
+ __version__ = "1.3.24"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wizata_dsapi
3
- Version: 1.3.21
3
+ Version: 1.3.24
4
4
  Summary: Wizata Data Science Toolkit
5
5
  Author: Wizata S.A.
6
6
  Author-email: info@wizata.com
@@ -1 +0,0 @@
1
- __version__ = "1.3.21"
File without changes
File without changes
File without changes
File without changes