sarapy 1.2.6__tar.gz → 1.3.0__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.
- {sarapy-1.2.6/sarapy.egg-info → sarapy-1.3.0}/PKG-INFO +5 -1
- {sarapy-1.2.6 → sarapy-1.3.0}/README.md +4 -0
- {sarapy-1.2.6 → sarapy-1.3.0}/pyproject.toml +1 -1
- {sarapy-1.2.6 → sarapy-1.3.0}/sarapy/dataProcessing/OpsProcessor.py +26 -6
- sarapy-1.3.0/sarapy/mlProcessors/FertilizerFMCreator.py +54 -0
- sarapy-1.3.0/sarapy/mlProcessors/FertilizerTransformer.py +81 -0
- {sarapy-1.2.6 → sarapy-1.3.0}/sarapy/preprocessing/TransformToOutputData.py +4 -2
- {sarapy-1.2.6 → sarapy-1.3.0}/sarapy/version.py +1 -1
- {sarapy-1.2.6 → sarapy-1.3.0/sarapy.egg-info}/PKG-INFO +5 -1
- {sarapy-1.2.6 → sarapy-1.3.0}/sarapy.egg-info/SOURCES.txt +2 -0
- {sarapy-1.2.6 → sarapy-1.3.0}/LICENCE +0 -0
- {sarapy-1.2.6 → sarapy-1.3.0}/sarapy/__init__.py +0 -0
- {sarapy-1.2.6 → sarapy-1.3.0}/sarapy/dataProcessing/GeoProcessor.py +0 -0
- {sarapy-1.2.6 → sarapy-1.3.0}/sarapy/dataProcessing/TLMSensorDataProcessor.py +0 -0
- {sarapy-1.2.6 → sarapy-1.3.0}/sarapy/dataProcessing/TimeSeriesProcessor.py +0 -0
- {sarapy-1.2.6 → sarapy-1.3.0}/sarapy/dataProcessing/__init__.py +0 -0
- {sarapy-1.2.6 → sarapy-1.3.0}/sarapy/mlProcessors/PlantinClassifier.py +0 -0
- {sarapy-1.2.6 → sarapy-1.3.0}/sarapy/mlProcessors/PlantinFMCreator.py +0 -0
- {sarapy-1.2.6 → sarapy-1.3.0}/sarapy/mlProcessors/__init__.py +0 -0
- {sarapy-1.2.6 → sarapy-1.3.0}/sarapy/preprocessing/DistancesImputer.py +0 -0
- {sarapy-1.2.6 → sarapy-1.3.0}/sarapy/preprocessing/FertilizerImputer.py +0 -0
- {sarapy-1.2.6 → sarapy-1.3.0}/sarapy/preprocessing/TransformInputData.py +0 -0
- {sarapy-1.2.6 → sarapy-1.3.0}/sarapy/preprocessing/__init__.py +0 -0
- {sarapy-1.2.6 → sarapy-1.3.0}/sarapy/utils/__init__.py +0 -0
- {sarapy-1.2.6 → sarapy-1.3.0}/sarapy/utils/amg_decoder.py +0 -0
- {sarapy-1.2.6 → sarapy-1.3.0}/sarapy/utils/amg_ppk.py +0 -0
- {sarapy-1.2.6 → sarapy-1.3.0}/sarapy/utils/getRawOperations.py +0 -0
- {sarapy-1.2.6 → sarapy-1.3.0}/sarapy.egg-info/dependency_links.txt +0 -0
- {sarapy-1.2.6 → sarapy-1.3.0}/sarapy.egg-info/requires.txt +0 -0
- {sarapy-1.2.6 → sarapy-1.3.0}/sarapy.egg-info/top_level.txt +0 -0
- {sarapy-1.2.6 → sarapy-1.3.0}/setup.cfg +0 -0
- {sarapy-1.2.6 → sarapy-1.3.0}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sarapy
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Home-page: https://github.com/lucasbaldezzari/sarapy
|
|
5
5
|
Author: Lucas Baldezzari
|
|
6
6
|
Author-email: Lucas Baldezzari <lmbaldezzari@gmail.com>
|
|
@@ -19,6 +19,10 @@ Requires-Dist: geopy
|
|
|
19
19
|
|
|
20
20
|
Library for processing SARAPICO project metadata of _AMG SA_.
|
|
21
21
|
|
|
22
|
+
#### Version 1.3.0
|
|
23
|
+
|
|
24
|
+
- Se agrega funcionalidad para estimar la cantidad de gramos de fertilizante en base al nivel de distorsión de fertilizante arrojado por la electrónica. Se implementa mlProcessor.FertlizerFMCreator y mlProcessor.FertilizerTransformer. Además se modifican las clases OpsProcessor y TransformToOutputData para poder usar estas nuevas clases.
|
|
25
|
+
|
|
22
26
|
#### Version 1.2.6
|
|
23
27
|
|
|
24
28
|
- Se agrega línea dentro de clase OpsProcessor.
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Library for processing SARAPICO project metadata of _AMG SA_.
|
|
4
4
|
|
|
5
|
+
#### Version 1.3.0
|
|
6
|
+
|
|
7
|
+
- Se agrega funcionalidad para estimar la cantidad de gramos de fertilizante en base al nivel de distorsión de fertilizante arrojado por la electrónica. Se implementa mlProcessor.FertlizerFMCreator y mlProcessor.FertilizerTransformer. Además se modifican las clases OpsProcessor y TransformToOutputData para poder usar estas nuevas clases.
|
|
8
|
+
|
|
5
9
|
#### Version 1.2.6
|
|
6
10
|
|
|
7
11
|
- Se agrega línea dentro de clase OpsProcessor.
|
|
@@ -4,6 +4,7 @@ import pandas as pd
|
|
|
4
4
|
from sarapy.mlProcessors import PlantinFMCreator
|
|
5
5
|
from sarapy.mlProcessors import PlantinClassifier
|
|
6
6
|
from sarapy.preprocessing import TransformInputData, TransformToOutputData
|
|
7
|
+
from sarapy.mlProcessors import FertilizerFMCreator, FertilizerTransformer
|
|
7
8
|
|
|
8
9
|
class OpsProcessor():
|
|
9
10
|
"""Clase para procesar las operaciones de los operarios. La información se toma de la base de datos
|
|
@@ -40,7 +41,17 @@ class OpsProcessor():
|
|
|
40
41
|
|
|
41
42
|
self._plantin_classifier = PlantinClassifier.PlantinClassifier(**kwargs_plclass)
|
|
42
43
|
self.plantinFMCreator = PlantinFMCreator.PlantinFMCreator(**fmcreator_kargs)
|
|
43
|
-
|
|
44
|
+
|
|
45
|
+
##mapa de argumentos para FertilizerTransformer
|
|
46
|
+
ft_map = {"regresor_file", "poly_features_file"}
|
|
47
|
+
ft_kwargs = {}
|
|
48
|
+
##recorro kwargs y usando ft_map creo un nuevo diccionario con los valores que se pasaron
|
|
49
|
+
for key, value in kwargs.items():
|
|
50
|
+
if key in ft_map:
|
|
51
|
+
ft_kwargs[key] = value
|
|
52
|
+
|
|
53
|
+
self._ftfmcreator = FertilizerFMCreator.FertilizerFMCreator()
|
|
54
|
+
self._fertilizer_transformer = FertilizerTransformer.FertilizerTransformer(**ft_kwargs)
|
|
44
55
|
|
|
45
56
|
self._operationsDict = {} ##diccionario de operarios con sus operaciones
|
|
46
57
|
self._platin_classifiedOperations = np.array([]) ##array con las operaciones clasificadas para plantin
|
|
@@ -77,7 +88,7 @@ class OpsProcessor():
|
|
|
77
88
|
|
|
78
89
|
Returns:
|
|
79
90
|
Lista de diccionarios con las clasificaciones. Cada diccionario tiene la forma
|
|
80
|
-
{"id_db_h": 10, "id_db_dw": 10, "tag_seedling": 1, "tag_fertilizer":
|
|
91
|
+
{"id_db_h": 10, "id_db_dw": 10, "tag_seedling": 1, "tag_fertilizer": gramos (float)}
|
|
81
92
|
"""
|
|
82
93
|
|
|
83
94
|
##chqueo que newSample no esté vacío
|
|
@@ -86,13 +97,16 @@ class OpsProcessor():
|
|
|
86
97
|
#Si tenemos nuevas operaciones, actualizamos el diccionario de operaciones
|
|
87
98
|
self.updateOperationsDict(newSample) #actualizamos diccionario interno de la clase
|
|
88
99
|
pl_clas = self.classifyForPlantin(**kwargs) #clasificamos las operaciones para plantín
|
|
89
|
-
|
|
100
|
+
|
|
101
|
+
#estimamos los gramos de fertilizante
|
|
102
|
+
dst_ft = self._ftfmcreator.transform(newSample[:,2]).astype(int)
|
|
103
|
+
ft_grams = self._fertilizer_transformer.transform(dst_ft.reshape(-1,1))
|
|
90
104
|
id_db_h_nums, id_db_dw_nums = self.getActualOperationsNumbers() #obtenemos los números de operaciones desde el diccionario de operaciones
|
|
91
105
|
date_oprc = newSample[:,3]
|
|
92
106
|
return self.transformToOutputData.fit_transform(np.column_stack((id_db_h_nums,
|
|
93
107
|
id_db_dw_nums,
|
|
94
108
|
pl_clas,
|
|
95
|
-
|
|
109
|
+
ft_grams,
|
|
96
110
|
date_oprc)))
|
|
97
111
|
else:
|
|
98
112
|
self.resetAllNewSamplesValues()
|
|
@@ -324,7 +338,8 @@ if __name__ == "__main__":
|
|
|
324
338
|
|
|
325
339
|
import time
|
|
326
340
|
start_time = time.time()
|
|
327
|
-
op = OpsProcessor.OpsProcessor(classifier_file='modelos\\pipeline_rf.pkl', imputeDistances = False
|
|
341
|
+
op = OpsProcessor.OpsProcessor(classifier_file='modelos\\pipeline_rf.pkl', imputeDistances = False,
|
|
342
|
+
regresor_file='modelos\\regresor.pkl', poly_features_file='modelos\\poly_features.pkl')
|
|
328
343
|
classifications = op.processOperations(raw_ops, update_samePlace=True, useRatioStats=True)
|
|
329
344
|
end_time = time.time()
|
|
330
345
|
execution_time = end_time - start_time
|
|
@@ -334,4 +349,9 @@ if __name__ == "__main__":
|
|
|
334
349
|
df = pd.DataFrame(classifications)
|
|
335
350
|
tag_seedling = df["tag_seedling"].values
|
|
336
351
|
print(tag_seedling.mean())
|
|
337
|
-
print(df["tag_seedling"].shape)
|
|
352
|
+
print(df["tag_seedling"].shape)
|
|
353
|
+
|
|
354
|
+
##datos de fertilizante
|
|
355
|
+
tag_fertilizer = df["tag_fertilizer"].values
|
|
356
|
+
print(tag_fertilizer[1500:1560])
|
|
357
|
+
print(tag_fertilizer.mean())
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from sklearn.base import BaseEstimator, TransformerMixin
|
|
3
|
+
from sarapy.dataProcessing import TLMSensorDataProcessor
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class FertilizerFMCreator():
|
|
7
|
+
"""Clase para crear la matriz de características para el procesamiento del fertilizante"""
|
|
8
|
+
|
|
9
|
+
def __init__(self):
|
|
10
|
+
self._dataPositions = {"DST_FT": 0}
|
|
11
|
+
self.dst_ft = None ##cuando no se ha transformado ningún dato, se inicializa en None
|
|
12
|
+
|
|
13
|
+
def transform(self, X):
|
|
14
|
+
"""
|
|
15
|
+
Transforma los datos de telemetría para retornar los datos de distorsión de fertilizante.
|
|
16
|
+
|
|
17
|
+
Params:
|
|
18
|
+
- X: Es un array con los datos de telemetría. La forma de X es (n,1)
|
|
19
|
+
|
|
20
|
+
Returns:
|
|
21
|
+
- dst_ft: Array con los valores de distorsión de fertilizante.
|
|
22
|
+
"""
|
|
23
|
+
tlmDataExtractor = TLMSensorDataProcessor.TLMSensorDataProcessor()
|
|
24
|
+
tlmdeDP = tlmDataExtractor.dataPositions #posiciones de los datos transformados de tlmDataExtractor
|
|
25
|
+
|
|
26
|
+
tlmExtracted = tlmDataExtractor.fit_transform(X)
|
|
27
|
+
|
|
28
|
+
self.dst_ft = tlmExtracted[:,tlmdeDP["DSTRFT"]]
|
|
29
|
+
|
|
30
|
+
return self.dst_ft
|
|
31
|
+
|
|
32
|
+
if __name__ == "__main__":
|
|
33
|
+
import os
|
|
34
|
+
import pandas as pd
|
|
35
|
+
import numpy as np
|
|
36
|
+
from sarapy.preprocessing import TransformInputData
|
|
37
|
+
from sarapy.mlProcessors import PlantinFMCreator
|
|
38
|
+
import sarapy.utils.getRawOperations as getRawOperations
|
|
39
|
+
tindata = TransformInputData.TransformInputData()
|
|
40
|
+
|
|
41
|
+
##cargo los archivos examples\2024-09-04\UPM001N\data.json y examples\2024-09-04\UPM001N\historical-data.json
|
|
42
|
+
data_path = os.path.join(os.getcwd(), "examples\\2024-09-04\\UPM001N\\data.json")
|
|
43
|
+
historical_data_path = os.path.join(os.getcwd(), "examples\\2024-09-04\\UPM001N\\historical-data.json")
|
|
44
|
+
raw_data = pd.read_json(data_path, orient="records").to_dict(orient="records")
|
|
45
|
+
raw_data2 = pd.read_json(historical_data_path, orient="records").to_dict(orient="records")
|
|
46
|
+
|
|
47
|
+
raw_ops = np.array(getRawOperations.getRawOperations(raw_data, raw_data2))
|
|
48
|
+
X = tindata.fit_transform(raw_ops) #transforma los datos de operaciones a un array de numpy
|
|
49
|
+
|
|
50
|
+
from sarapy.mlProcessors import FertilizerFMCreator
|
|
51
|
+
|
|
52
|
+
ftfmcreator = FertilizerFMCreator.FertilizerFMCreator()
|
|
53
|
+
dst_ft = ftfmcreator.transform(X[:,2])
|
|
54
|
+
print(dst_ft[:10]) #imprime los primeros 10 valores de DST_FT
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import pickle
|
|
2
|
+
|
|
3
|
+
class FertilizerTransformer:
|
|
4
|
+
"""
|
|
5
|
+
Clase para tomar los valores de distorsión de fertilizante y transformarlos a gramos
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
def __init__(self, regresor_file, poly_features_file):
|
|
9
|
+
"""Constructor de la clase FertilizerImputer.
|
|
10
|
+
|
|
11
|
+
Args:
|
|
12
|
+
- regresor: Regresor que transforma los valores de distorsión a gramos.
|
|
13
|
+
- poly_features: Grado del polinomio a utilizar en la transformación de los datos.
|
|
14
|
+
"""
|
|
15
|
+
##cargo el regresor con pickle. Usamos try para capturar el error FileNotFoundError
|
|
16
|
+
try:
|
|
17
|
+
with open(regresor_file, 'rb') as file:
|
|
18
|
+
self._regresor = pickle.load(file)
|
|
19
|
+
print("Regresor cargado con éxito.")
|
|
20
|
+
except FileNotFoundError:
|
|
21
|
+
print("El archivo no se encuentra en el directorio actual.")
|
|
22
|
+
|
|
23
|
+
##cargo las características polinómicas con pickle. Usamos try para capturar el error FileNotFoundError
|
|
24
|
+
try:
|
|
25
|
+
with open(poly_features_file, 'rb') as file:
|
|
26
|
+
self._poly_features = pickle.load(file)
|
|
27
|
+
print("Características polinómicas cargadas con éxito.")
|
|
28
|
+
except FileNotFoundError:
|
|
29
|
+
print("El archivo no se encuentra en el directorio actual.")
|
|
30
|
+
|
|
31
|
+
self.fertilizer_grams = None ##cuando no se ha transformado ningún dato, se inicializa en None
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def transform(self, X):
|
|
35
|
+
"""Transforma los datos de distorsión de fertilizante a gramos.
|
|
36
|
+
|
|
37
|
+
Params:
|
|
38
|
+
- X: Es un array con los datos de distorsión de fertilizante. La forma de X es (n,1)
|
|
39
|
+
|
|
40
|
+
Ejemplo: [12. 1. 12. 0. 0. 0. 0. 0. 0. 12.]
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
- 0: Array con los valores de distorsión de fertilizante transformados a gramos.
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
X_poly = self._poly_features.fit_transform(X)
|
|
47
|
+
self.fertilizer_grams = self._regresor.predict(X_poly)
|
|
48
|
+
|
|
49
|
+
##retorno con shape (n,)
|
|
50
|
+
return self.fertilizer_grams.reshape(-1,)
|
|
51
|
+
|
|
52
|
+
if __name__ == "__main__":
|
|
53
|
+
import os
|
|
54
|
+
import pandas as pd
|
|
55
|
+
import numpy as np
|
|
56
|
+
from sarapy.preprocessing import TransformInputData
|
|
57
|
+
from sarapy.mlProcessors import PlantinFMCreator
|
|
58
|
+
import sarapy.utils.getRawOperations as getRawOperations
|
|
59
|
+
tindata = TransformInputData.TransformInputData()
|
|
60
|
+
|
|
61
|
+
##cargo los archivos examples\2024-09-04\UPM001N\data.json y examples\2024-09-04\UPM001N\historical-data.json
|
|
62
|
+
data_path = os.path.join(os.getcwd(), "examples\\2024-09-04\\UPM001N\\data.json")
|
|
63
|
+
historical_data_path = os.path.join(os.getcwd(), "examples\\2024-09-04\\UPM001N\\historical-data.json")
|
|
64
|
+
raw_data = pd.read_json(data_path, orient="records").to_dict(orient="records")
|
|
65
|
+
raw_data2 = pd.read_json(historical_data_path, orient="records").to_dict(orient="records")
|
|
66
|
+
|
|
67
|
+
raw_ops = np.array(getRawOperations.getRawOperations(raw_data, raw_data2))
|
|
68
|
+
X = tindata.fit_transform(raw_ops) #transforma los datos de operaciones a un array de numpy
|
|
69
|
+
|
|
70
|
+
from sarapy.mlProcessors import FertilizerFMCreator
|
|
71
|
+
|
|
72
|
+
ftfmcreator = FertilizerFMCreator.FertilizerFMCreator()
|
|
73
|
+
dst_ft = ftfmcreator.transform(X[:,2])
|
|
74
|
+
##convierto a int dst_ft
|
|
75
|
+
dst_ft = dst_ft.astype(int)
|
|
76
|
+
|
|
77
|
+
from sarapy.mlProcessors import FertilizerTransformer
|
|
78
|
+
|
|
79
|
+
fertransformer = FertilizerTransformer.FertilizerTransformer(regresor_file='modelos\\regresor.pkl', poly_features_file='modelos\\poly_features.pkl')
|
|
80
|
+
gramos = fertransformer.transform(dst_ft.reshape(-1,1))
|
|
81
|
+
print(gramos[:10])
|
|
@@ -53,9 +53,11 @@ class TransformToOutputData(BaseEstimator, TransformerMixin):
|
|
|
53
53
|
date_data = X[:,4].astype(int)
|
|
54
54
|
date_oprc = np.array([datetime.datetime.fromtimestamp(date, datetime.timezone.utc) for date in date_data])
|
|
55
55
|
self.temp_df.loc[:,"date_oprc"] = date_oprc.flatten()
|
|
56
|
-
##convierto las columnas "id_db_h", "id_db_dw", "tag_seedling"
|
|
57
|
-
for col in ["id_db_h", "id_db_dw", "tag_seedling"
|
|
56
|
+
##convierto las columnas "id_db_h", "id_db_dw", "tag_seedling" a int
|
|
57
|
+
for col in ["id_db_h", "id_db_dw", "tag_seedling"]:
|
|
58
58
|
self.temp_df[col] = self.temp_df[col].astype(float).astype(int)
|
|
59
|
+
##convierto la columna "tag_fertilizer" a float de y redondeo a 3 decimales
|
|
60
|
+
self.temp_df["tag_fertilizer"] = self.temp_df["tag_fertilizer"].astype(float).round(3)
|
|
59
61
|
|
|
60
62
|
return self
|
|
61
63
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
## Version of the package
|
|
2
|
-
__version__ = "1.
|
|
2
|
+
__version__ = "1.3.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sarapy
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Home-page: https://github.com/lucasbaldezzari/sarapy
|
|
5
5
|
Author: Lucas Baldezzari
|
|
6
6
|
Author-email: Lucas Baldezzari <lmbaldezzari@gmail.com>
|
|
@@ -19,6 +19,10 @@ Requires-Dist: geopy
|
|
|
19
19
|
|
|
20
20
|
Library for processing SARAPICO project metadata of _AMG SA_.
|
|
21
21
|
|
|
22
|
+
#### Version 1.3.0
|
|
23
|
+
|
|
24
|
+
- Se agrega funcionalidad para estimar la cantidad de gramos de fertilizante en base al nivel de distorsión de fertilizante arrojado por la electrónica. Se implementa mlProcessor.FertlizerFMCreator y mlProcessor.FertilizerTransformer. Además se modifican las clases OpsProcessor y TransformToOutputData para poder usar estas nuevas clases.
|
|
25
|
+
|
|
22
26
|
#### Version 1.2.6
|
|
23
27
|
|
|
24
28
|
- Se agrega línea dentro de clase OpsProcessor.
|
|
@@ -14,6 +14,8 @@ sarapy/dataProcessing/OpsProcessor.py
|
|
|
14
14
|
sarapy/dataProcessing/TLMSensorDataProcessor.py
|
|
15
15
|
sarapy/dataProcessing/TimeSeriesProcessor.py
|
|
16
16
|
sarapy/dataProcessing/__init__.py
|
|
17
|
+
sarapy/mlProcessors/FertilizerFMCreator.py
|
|
18
|
+
sarapy/mlProcessors/FertilizerTransformer.py
|
|
17
19
|
sarapy/mlProcessors/PlantinClassifier.py
|
|
18
20
|
sarapy/mlProcessors/PlantinFMCreator.py
|
|
19
21
|
sarapy/mlProcessors/__init__.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|