sinapsis-data-analysis 0.1.10__py3-none-any.whl → 0.1.11__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.
- sinapsis_data_analysis/templates/ml_base_inference.py +6 -2
- sinapsis_data_analysis/templates/ml_base_training.py +3 -3
- sinapsis_data_analysis/templates/sklearn_train.py +2 -2
- {sinapsis_data_analysis-0.1.10.dist-info → sinapsis_data_analysis-0.1.11.dist-info}/METADATA +1 -1
- {sinapsis_data_analysis-0.1.10.dist-info → sinapsis_data_analysis-0.1.11.dist-info}/RECORD +8 -8
- {sinapsis_data_analysis-0.1.10.dist-info → sinapsis_data_analysis-0.1.11.dist-info}/WHEEL +1 -1
- {sinapsis_data_analysis-0.1.10.dist-info → sinapsis_data_analysis-0.1.11.dist-info}/licenses/LICENSE +0 -0
- {sinapsis_data_analysis-0.1.10.dist-info → sinapsis_data_analysis-0.1.11.dist-info}/top_level.txt +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
|
+
import os
|
|
2
3
|
from abc import abstractmethod
|
|
3
4
|
from typing import Any
|
|
4
5
|
|
|
@@ -6,6 +7,7 @@ import numpy as np
|
|
|
6
7
|
from sinapsis_core.data_containers.data_packet import DataContainer
|
|
7
8
|
from sinapsis_core.template_base.base_models import TemplateAttributes
|
|
8
9
|
from sinapsis_core.template_base.template import Template
|
|
10
|
+
from sinapsis_core.utils.env_var_keys import SINAPSIS_CACHE_DIR
|
|
9
11
|
|
|
10
12
|
|
|
11
13
|
class MLBaseInference(Template):
|
|
@@ -24,11 +26,12 @@ class MLBaseInference(Template):
|
|
|
24
26
|
"""
|
|
25
27
|
|
|
26
28
|
model_path: str
|
|
29
|
+
root_dir : str = SINAPSIS_CACHE_DIR
|
|
27
30
|
generic_field_key: str
|
|
28
31
|
|
|
29
32
|
def __init__(self, attributes: TemplateAttributes) -> None:
|
|
30
33
|
super().__init__(attributes)
|
|
31
|
-
|
|
34
|
+
|
|
32
35
|
|
|
33
36
|
def get_data(self, container: DataContainer) -> Any:
|
|
34
37
|
"""Get the data from the data container
|
|
@@ -111,7 +114,8 @@ class MLBaseInference(Template):
|
|
|
111
114
|
if not self.data_is_valid(data):
|
|
112
115
|
self.logger.warning("Invalid or missing data")
|
|
113
116
|
return container
|
|
114
|
-
|
|
117
|
+
full_path = os.path.join(self.attributes.root_dir, self.attributes.model_path)
|
|
118
|
+
self.model = self.load_model(full_path)
|
|
115
119
|
data = self.preprocess_data(data)
|
|
116
120
|
predictions = self.predict(data)
|
|
117
121
|
|
|
@@ -34,7 +34,7 @@ class MLBaseAttributes(TemplateAttributes):
|
|
|
34
34
|
model_save_path (str): Path where the trained model will be saved.
|
|
35
35
|
"""
|
|
36
36
|
|
|
37
|
-
generic_field_key: str
|
|
37
|
+
generic_field_key: str | None = None
|
|
38
38
|
root_dir : str = WORKING_DIR
|
|
39
39
|
model_save_path: str
|
|
40
40
|
|
|
@@ -220,13 +220,13 @@ class MLBaseTraining(BaseDynamicWrapperTemplate):
|
|
|
220
220
|
full_path = os.path.join(self.attributes.root_dir, self.attributes.model_save_path)
|
|
221
221
|
try:
|
|
222
222
|
os.makedirs(os.path.dirname(full_path), exist_ok=True)
|
|
223
|
-
self._save_model_implementation()
|
|
223
|
+
self._save_model_implementation(full_path)
|
|
224
224
|
self.logger.info(f"Model saved at {self.attributes.model_save_path}")
|
|
225
225
|
except (MemoryError, TypeError) as e:
|
|
226
226
|
self.logger.error(f"Error saving model: {e}")
|
|
227
227
|
|
|
228
228
|
@abstractmethod
|
|
229
|
-
def _save_model_implementation(self) -> None:
|
|
229
|
+
def _save_model_implementation(self, full_path: str) -> None:
|
|
230
230
|
"""Save the trained model using an implementation-specific method.
|
|
231
231
|
|
|
232
232
|
This abstract method should be implemented by subclasses to define
|
|
@@ -53,12 +53,12 @@ class SKLearnLinearModelsTrain(MLBaseTraining):
|
|
|
53
53
|
category="SKLearn", tags=[Tags.DATA_ANALYSIS, Tags.LINEAR_REGRESSION, Tags.MODELS, Tags.SKLEARN, Tags.TRAINING]
|
|
54
54
|
)
|
|
55
55
|
|
|
56
|
-
def _save_model_implementation(self) -> None:
|
|
56
|
+
def _save_model_implementation(self, full_path:str) -> None:
|
|
57
57
|
"""
|
|
58
58
|
Implements the abstract method from the base class to
|
|
59
59
|
save the model to the path specified in attributes.
|
|
60
60
|
"""
|
|
61
|
-
joblib.dump(self.trained_model,
|
|
61
|
+
joblib.dump(self.trained_model, full_path)
|
|
62
62
|
|
|
63
63
|
|
|
64
64
|
class SKLearnNeighborsModelsTrain(SKLearnLinearModelsTrain):
|
{sinapsis_data_analysis-0.1.10.dist-info → sinapsis_data_analysis-0.1.11.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sinapsis-data-analysis
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.11
|
|
4
4
|
Summary: Templates to work with models for classification, regression and clustering with xgboost and sklearn.
|
|
5
5
|
Author-email: SinapsisAI <dev@sinapsis.tech>
|
|
6
6
|
Project-URL: Homepage, https://sinapsis.tech
|
|
@@ -4,15 +4,15 @@ sinapsis_data_analysis/helpers/excluded_models.py,sha256=gVrTRBdktM3eoBxd7kX22xH
|
|
|
4
4
|
sinapsis_data_analysis/helpers/model_metrics.py,sha256=mR-ZLD8PrGgOh1PrYG8TOjFhJz6l2EDRtn6jtMMyI7A,729
|
|
5
5
|
sinapsis_data_analysis/helpers/tags.py,sha256=ICJNmbNAtwn5BfMvGHh6eLuq5Ro3hCIbwd-Y63qOmC0,372
|
|
6
6
|
sinapsis_data_analysis/templates/__init__.py,sha256=z1-E6V4f6MqoGY0_cPwSurDpXDdMOAEOvSS4ogrl1DM,840
|
|
7
|
-
sinapsis_data_analysis/templates/ml_base_inference.py,sha256=
|
|
8
|
-
sinapsis_data_analysis/templates/ml_base_training.py,sha256=
|
|
7
|
+
sinapsis_data_analysis/templates/ml_base_inference.py,sha256=3QfMH8w4yNCnEFZeJOOO3HZAC75UjJL2P6R4aN06f9g,3655
|
|
8
|
+
sinapsis_data_analysis/templates/ml_base_training.py,sha256=m2yDuR9C7lfN1jT31fTQsn3c4fN0Gtx5jd8MtaemUqw,9364
|
|
9
9
|
sinapsis_data_analysis/templates/sklearn_inference.py,sha256=rf-HsWYE4_g9KM_BZbP3f2jKyKz_MLj9-eZ1CAGHqp8,931
|
|
10
10
|
sinapsis_data_analysis/templates/sklearn_manifold.py,sha256=whYTvwDnVacSh4N2XBXVgn8O1dG-KnQsx6htm5DFEbQ,5519
|
|
11
|
-
sinapsis_data_analysis/templates/sklearn_train.py,sha256=
|
|
11
|
+
sinapsis_data_analysis/templates/sklearn_train.py,sha256=uReIOKQTHYbfsdNy1efVcguwsMTkhDXTbBpSeVDlP-E,6750
|
|
12
12
|
sinapsis_data_analysis/templates/xgboost_inference.py,sha256=rFk44jHFCr-EuqDg74TInjlHDCstvA0V422gQmgbd0I,1028
|
|
13
13
|
sinapsis_data_analysis/templates/xgboost_train.py,sha256=VQSztloGAW4Xcx8MZCoRKdqa5jn4NL857jHTeMRuMwA,2513
|
|
14
|
-
sinapsis_data_analysis-0.1.
|
|
15
|
-
sinapsis_data_analysis-0.1.
|
|
16
|
-
sinapsis_data_analysis-0.1.
|
|
17
|
-
sinapsis_data_analysis-0.1.
|
|
18
|
-
sinapsis_data_analysis-0.1.
|
|
14
|
+
sinapsis_data_analysis-0.1.11.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
|
|
15
|
+
sinapsis_data_analysis-0.1.11.dist-info/METADATA,sha256=OmUDyt8OsaKGfmEmytn_7bgi6pQLpGwVudOrqyauu_I,6297
|
|
16
|
+
sinapsis_data_analysis-0.1.11.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
17
|
+
sinapsis_data_analysis-0.1.11.dist-info/top_level.txt,sha256=Mc5OyqBINgXFLrAyVBmjg25MQd6Lbg7z-rwotzEeygQ,23
|
|
18
|
+
sinapsis_data_analysis-0.1.11.dist-info/RECORD,,
|
{sinapsis_data_analysis-0.1.10.dist-info → sinapsis_data_analysis-0.1.11.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{sinapsis_data_analysis-0.1.10.dist-info → sinapsis_data_analysis-0.1.11.dist-info}/top_level.txt
RENAMED
|
File without changes
|