feat(SRC): :rocket: Change style and logic
Browse files- .gitignore +3 -0
- app.py +63 -221
- find_matches.py +61 -0
- input_options.py +219 -0
- queries.py +110 -66
- test.ipynb +0 -0
- test_one_query.ipynb +505 -0
.gitignore
CHANGED
@@ -6,3 +6,6 @@ __pycache__/
|
|
6 |
|
7 |
# gradio
|
8 |
.gradio/
|
|
|
|
|
|
|
|
6 |
|
7 |
# gradio
|
8 |
.gradio/
|
9 |
+
|
10 |
+
# Results to analyze
|
11 |
+
macros_evolution_results.txt
|
app.py
CHANGED
@@ -3,6 +3,8 @@ from queries import (clustering_esfuerzo_dieta_response, clustering_objetivo_res
|
|
3 |
clustering_cumplimiento_dieta_response, clustering_compromiso_response, clustering_diferencia_peso_response,
|
4 |
make_query, get_min_max_mean_mode_macros_differences)
|
5 |
from find_matches import find_user_dates_matches, find_macros_that_match_dates_of_users
|
|
|
|
|
6 |
|
7 |
def clustering_responses(esfuerzo_dieta, objetivo, cumplimiento_entrenamiento,
|
8 |
cumplimiento_dieta, compromiso, variacion_peso):
|
@@ -42,8 +44,8 @@ def calcular_macros(esfuerzo_dieta, objetivo, cumplimiento_entrenamiento,
|
|
42 |
if list(opcion.values())[0]["text"] == compromiso)
|
43 |
|
44 |
# Clustering
|
45 |
-
variacion_peso =
|
46 |
-
print(f"
|
47 |
(cluster_esfuerzo_dieta, cluster_objetivo, cluster_entrenamiento, cluster_cumplimiento_dieta,
|
48 |
cluster_compromiso, diff_peso_min, diff_peso_max) = clustering_responses(valor_esfuerzo, valor_objetivo,
|
49 |
valor_cumplimiento_entr,
|
@@ -51,32 +53,46 @@ def calcular_macros(esfuerzo_dieta, objetivo, cumplimiento_entrenamiento,
|
|
51 |
variacion_peso)
|
52 |
|
53 |
# Imprimimos los resultados
|
54 |
-
print(f"
|
55 |
print(f"\tEsfuerzo para cumplir dieta: {cluster_esfuerzo_dieta}")
|
56 |
print(f"\tObjetivo: {cluster_objetivo}")
|
57 |
print(f"\tEntrenamiento: {cluster_entrenamiento}")
|
58 |
print(f"\tCumplimiento dieta: {cluster_cumplimiento_dieta}")
|
59 |
print(f"\tCompromiso: {cluster_compromiso}")
|
60 |
-
print(f"\
|
61 |
print(f"\t{diff_peso_min} <= Diferencia peso <= {diff_peso_max}")
|
62 |
|
63 |
# Crear query
|
64 |
query = make_query(cluster_esfuerzo_dieta, cluster_objetivo, cluster_entrenamiento, cluster_cumplimiento_dieta, cluster_compromiso, diff_peso_min, diff_peso_max)
|
65 |
|
66 |
# Print query
|
67 |
-
print(f"Query:
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
# Crear diccionario de matches
|
70 |
matches_dict = find_user_dates_matches(query)
|
71 |
|
72 |
# Print matches
|
73 |
-
print(f"Matches
|
|
|
|
|
74 |
|
75 |
# Find macros that match dates of users
|
76 |
macros_differences_list = find_macros_that_match_dates_of_users(matches_dict)
|
77 |
|
78 |
# Print macros
|
79 |
-
print(f"
|
|
|
|
|
80 |
|
81 |
# Calculate macros min, max and mean
|
82 |
if len(macros_differences_list) > 0:
|
@@ -93,245 +109,68 @@ def calcular_macros(esfuerzo_dieta, objetivo, cumplimiento_entrenamiento,
|
|
93 |
rest_day_fat_std = [0, 0, 0, 0]
|
94 |
|
95 |
# Print macros min, max and mean
|
96 |
-
print(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
|
98 |
-
# Get macros
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
rest_day_carbs_min, rest_day_carbs_max, rest_day_carbs_mean, rest_day_carbs_mode = rest_day_carbs_std
|
108 |
-
rest_day_fat_min, rest_day_fat_max, rest_day_fat_mean, rest_day_fat_mode = rest_day_fat_std
|
109 |
|
110 |
# Calculate macros final
|
111 |
train_day_protein_final = train_day_protein_initial + train_day_protein_mode
|
112 |
train_day_carbs_final = train_day_carbs_initial + train_day_carbs_mode
|
113 |
train_day_fat_final = train_day_fat_initial + train_day_fat_mode
|
114 |
-
|
115 |
intratrain_protein_final = intratrain_protein_initial + intratrain_protein_mode
|
116 |
intratrain_carbs_final = intratrain_carbs_initial + intratrain_carbs_mode
|
117 |
-
|
118 |
rest_day_protein_final = rest_day_protein_initial + rest_day_protein_mode
|
119 |
rest_day_carbs_final = rest_day_carbs_initial + rest_day_carbs_mode
|
120 |
rest_day_fat_final = rest_day_fat_initial + rest_day_fat_mode
|
121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
return (train_day_protein_final, train_day_carbs_final, train_day_fat_final,
|
123 |
intratrain_protein_final, intratrain_carbs_final,
|
124 |
rest_day_protein_final, rest_day_carbs_final, rest_day_fat_final)
|
125 |
|
126 |
-
# Definimos las opciones para cada menú desplegable
|
127 |
-
opciones_esfuerzo = [
|
128 |
-
{
|
129 |
-
"No entiendo la calculadora, quiero menús tipo": {
|
130 |
-
"text": "No entiendo la calculadora, quiero menús tipo",
|
131 |
-
"value": " | no data"
|
132 |
-
}
|
133 |
-
},
|
134 |
-
{
|
135 |
-
"No costó nada": {
|
136 |
-
"text": "No costó nada",
|
137 |
-
"value": " | no costo"
|
138 |
-
}
|
139 |
-
},
|
140 |
-
{
|
141 |
-
"Costó demasiado, súbeme macros": {
|
142 |
-
"text": "Costó demasiado, súbeme macros",
|
143 |
-
"value": " | costo subir macros"
|
144 |
-
}
|
145 |
-
},
|
146 |
-
{
|
147 |
-
"Costó demasiado, bájame macros": {
|
148 |
-
"text": "Costó demasiado, bájame macros",
|
149 |
-
"value": " | costo bajar macros"
|
150 |
-
}
|
151 |
-
},
|
152 |
-
{
|
153 |
-
"Costó, pero me adapto a nuevos ajustes": {
|
154 |
-
"text": "Costó, pero me adapto a nuevos ajustes",
|
155 |
-
"value": " | costo y me adapto a nuevos ajustes"
|
156 |
-
}
|
157 |
-
},
|
158 |
-
{
|
159 |
-
"Iba a coger menús tipo, pero al final por precio no": {
|
160 |
-
"text": "Iba a coger menús tipo, pero al final por precio no",
|
161 |
-
"value": " | no data"
|
162 |
-
}
|
163 |
-
}
|
164 |
-
]
|
165 |
-
|
166 |
-
opciones_objetivo = [
|
167 |
-
{
|
168 |
-
"definición (nada cambia)": {
|
169 |
-
"text": "definición (nada cambia)",
|
170 |
-
"value": " | definicion"
|
171 |
-
}
|
172 |
-
},
|
173 |
-
{
|
174 |
-
"empezamos a definir (cambia)": {
|
175 |
-
"text": "empezamos a definir (cambia)",
|
176 |
-
"value": " | definicion"
|
177 |
-
}
|
178 |
-
},
|
179 |
-
{
|
180 |
-
"perder peso (nada cambia)": {
|
181 |
-
"text": "perder peso (nada cambia)",
|
182 |
-
"value": " | definicion"
|
183 |
-
}
|
184 |
-
},
|
185 |
-
{
|
186 |
-
"volumen (nada cambia)": {
|
187 |
-
"text": "volumen (nada cambia)",
|
188 |
-
"value": " | volumen"
|
189 |
-
}
|
190 |
-
},
|
191 |
-
{
|
192 |
-
"empezamos a coger volumen (cambia)": {
|
193 |
-
"text": "empezamos a coger volumen (cambia)",
|
194 |
-
"value": " | volumen"
|
195 |
-
}
|
196 |
-
},
|
197 |
-
{
|
198 |
-
"empezamos a coger volumen, sobre todo tren inferior (cambia)": {
|
199 |
-
"text": "empezamos a coger volumen, sobre todo tren inferior (cambia)",
|
200 |
-
"value": " | volumen"
|
201 |
-
}
|
202 |
-
},
|
203 |
-
{
|
204 |
-
"empezamos a coger volumen, en todo el cuerpo (cambia)": {
|
205 |
-
"text": "empezamos a coger volumen, en todo el cuerpo (cambia)",
|
206 |
-
"value": " | volumen"
|
207 |
-
}
|
208 |
-
}
|
209 |
-
]
|
210 |
-
|
211 |
-
opciones_cumplimiento_entrenamiento = [
|
212 |
-
{
|
213 |
-
"Lo hice perfecto": {
|
214 |
-
"text": "Lo hice perfecto",
|
215 |
-
"value": " | bien"
|
216 |
-
}
|
217 |
-
},
|
218 |
-
{
|
219 |
-
"He fallado algunos días, pero sí": {
|
220 |
-
"text": "He fallado algunos días, pero sí",
|
221 |
-
"value": " | bien"
|
222 |
-
}
|
223 |
-
},
|
224 |
-
{
|
225 |
-
"Lesión importante": {
|
226 |
-
"text": "Lesión importante",
|
227 |
-
"value": " | mal"
|
228 |
-
}
|
229 |
-
},
|
230 |
-
{
|
231 |
-
"Lo hice prácticamente perfecto": {
|
232 |
-
"text": "Lo hice prácticamente perfecto",
|
233 |
-
"value": " | bien"
|
234 |
-
}
|
235 |
-
},
|
236 |
-
{
|
237 |
-
"Pequeña lesión": {
|
238 |
-
"text": "Pequeña lesión",
|
239 |
-
"value": " | mal"
|
240 |
-
}
|
241 |
-
},
|
242 |
-
{
|
243 |
-
"No hice nada, mantenemos la rutina un mes más": {
|
244 |
-
"text": "No hice nada, mantenemos la rutina un mes más",
|
245 |
-
"value": " | mal"
|
246 |
-
}
|
247 |
-
},
|
248 |
-
{
|
249 |
-
"Alárgame la rutina una semana más": {
|
250 |
-
"text": "Alárgame la rutina una semana más",
|
251 |
-
"value": " | mal"
|
252 |
-
}
|
253 |
-
}
|
254 |
-
]
|
255 |
-
|
256 |
-
opciones_cumplimiento_dieta = [
|
257 |
-
{
|
258 |
-
"al 70%": {
|
259 |
-
"text": "al 70%",
|
260 |
-
"value": " | bien"
|
261 |
-
}
|
262 |
-
},
|
263 |
-
{
|
264 |
-
"regular, me cuesta llegar": {
|
265 |
-
"text": "regular, me cuesta llegar",
|
266 |
-
"value": " | regular"
|
267 |
-
}
|
268 |
-
},
|
269 |
-
{
|
270 |
-
"Nada, mantén mis macros": {
|
271 |
-
"text": "Nada, mantén mis macros",
|
272 |
-
"value": " | mal"
|
273 |
-
}
|
274 |
-
},
|
275 |
-
{
|
276 |
-
"casi perfecta": {
|
277 |
-
"text": "casi perfecta",
|
278 |
-
"value": " | bien"
|
279 |
-
}
|
280 |
-
},
|
281 |
-
{
|
282 |
-
"regular, me salto la dieta": {
|
283 |
-
"text": "regular, me salto la dieta",
|
284 |
-
"value": " | regular"
|
285 |
-
}
|
286 |
-
},
|
287 |
-
{
|
288 |
-
"Perfecta": {
|
289 |
-
"text": "Perfecta",
|
290 |
-
"value": " | bien"
|
291 |
-
}
|
292 |
-
}
|
293 |
-
]
|
294 |
-
|
295 |
-
opciones_compromiso = [
|
296 |
-
{
|
297 |
-
"Bueno, pero mejorable": {
|
298 |
-
"text": "Bueno, pero mejorable",
|
299 |
-
"value": " | bueno"
|
300 |
-
}
|
301 |
-
},
|
302 |
-
{
|
303 |
-
"Mal, pero a partir de ahora voy a por todas": {
|
304 |
-
"text": "Mal, pero a partir de ahora voy a por todas",
|
305 |
-
"value": " | mal"
|
306 |
-
}
|
307 |
-
},
|
308 |
-
{
|
309 |
-
"Mal, demasiado exigente": {
|
310 |
-
"text": "Mal, demasiado exigente",
|
311 |
-
"value": " | mal"
|
312 |
-
}
|
313 |
-
},
|
314 |
-
{
|
315 |
-
"Máximo": {
|
316 |
-
"text": "Máximo",
|
317 |
-
"value": " | bueno"
|
318 |
-
}
|
319 |
-
}
|
320 |
-
]
|
321 |
-
|
322 |
# Definimos el color naranja
|
323 |
naranja = "#ea580b"
|
324 |
|
|
|
|
|
|
|
|
|
325 |
title_macros_iniciales_html = f"""
|
326 |
-
<
|
327 |
"""
|
328 |
|
329 |
title_cuestionario_html = f"""
|
330 |
-
<
|
331 |
"""
|
332 |
|
333 |
title_macros_finales_html = f"""
|
334 |
-
<
|
335 |
"""
|
336 |
|
337 |
style_css = f"""
|
@@ -378,6 +217,9 @@ with gr.Blocks(css=style_css, elem_classes="demo") as demo:
|
|
378 |
textos_cumplimiento_entr = [list(opcion.values())[0]["text"] for opcion in opciones_cumplimiento_entrenamiento]
|
379 |
textos_cumplimiento_dieta = [list(opcion.values())[0]["text"] for opcion in opciones_cumplimiento_dieta]
|
380 |
textos_compromiso = [list(opcion.values())[0]["text"] for opcion in opciones_compromiso]
|
|
|
|
|
|
|
381 |
|
382 |
# Entradas
|
383 |
gr.Markdown(title_macros_iniciales_html)
|
|
|
3 |
clustering_cumplimiento_dieta_response, clustering_compromiso_response, clustering_diferencia_peso_response,
|
4 |
make_query, get_min_max_mean_mode_macros_differences)
|
5 |
from find_matches import find_user_dates_matches, find_macros_that_match_dates_of_users
|
6 |
+
from input_options import (opciones_esfuerzo, opciones_objetivo, opciones_cumplimiento_entrenamiento,
|
7 |
+
opciones_cumplimiento_dieta, opciones_compromiso, diferencia_peso_options)
|
8 |
|
9 |
def clustering_responses(esfuerzo_dieta, objetivo, cumplimiento_entrenamiento,
|
10 |
cumplimiento_dieta, compromiso, variacion_peso):
|
|
|
44 |
if list(opcion.values())[0]["text"] == compromiso)
|
45 |
|
46 |
# Clustering
|
47 |
+
variacion_peso = peso_final - peso_inicial
|
48 |
+
print(f"\n\nVariación de peso: {variacion_peso}")
|
49 |
(cluster_esfuerzo_dieta, cluster_objetivo, cluster_entrenamiento, cluster_cumplimiento_dieta,
|
50 |
cluster_compromiso, diff_peso_min, diff_peso_max) = clustering_responses(valor_esfuerzo, valor_objetivo,
|
51 |
valor_cumplimiento_entr,
|
|
|
53 |
variacion_peso)
|
54 |
|
55 |
# Imprimimos los resultados
|
56 |
+
print(f"Respuestas formulario:")
|
57 |
print(f"\tEsfuerzo para cumplir dieta: {cluster_esfuerzo_dieta}")
|
58 |
print(f"\tObjetivo: {cluster_objetivo}")
|
59 |
print(f"\tEntrenamiento: {cluster_entrenamiento}")
|
60 |
print(f"\tCumplimiento dieta: {cluster_cumplimiento_dieta}")
|
61 |
print(f"\tCompromiso: {cluster_compromiso}")
|
62 |
+
print(f"\tPeso inicial: {peso_inicial}, peso final: {peso_final} --> Diferencia: {variacion_peso:.1f}")
|
63 |
print(f"\t{diff_peso_min} <= Diferencia peso <= {diff_peso_max}")
|
64 |
|
65 |
# Crear query
|
66 |
query = make_query(cluster_esfuerzo_dieta, cluster_objetivo, cluster_entrenamiento, cluster_cumplimiento_dieta, cluster_compromiso, diff_peso_min, diff_peso_max)
|
67 |
|
68 |
# Print query
|
69 |
+
print(f"Query:")
|
70 |
+
for q in query:
|
71 |
+
print(f"\t{list(q.keys())[0]}", end=" --> ")
|
72 |
+
for primary_key in q.keys():
|
73 |
+
primary_key_dict = q[primary_key]
|
74 |
+
for i, secondary_key in enumerate(primary_key_dict.keys()):
|
75 |
+
if i == len(primary_key_dict.keys()) - 1:
|
76 |
+
print(f"{secondary_key}: \"{primary_key_dict[secondary_key]}\"", end="")
|
77 |
+
else:
|
78 |
+
print(f"{secondary_key}: \"{primary_key_dict[secondary_key]}\"", end=", ")
|
79 |
+
print()
|
80 |
+
|
81 |
# Crear diccionario de matches
|
82 |
matches_dict = find_user_dates_matches(query)
|
83 |
|
84 |
# Print matches
|
85 |
+
print(f"Matches ({len(matches_dict)}):")
|
86 |
+
for match in matches_dict:
|
87 |
+
print(f"\t{match}")
|
88 |
|
89 |
# Find macros that match dates of users
|
90 |
macros_differences_list = find_macros_that_match_dates_of_users(matches_dict)
|
91 |
|
92 |
# Print macros
|
93 |
+
print(f"Diferencia de macros ({len(macros_differences_list)}):")
|
94 |
+
for macros_difference in macros_differences_list:
|
95 |
+
print(f"\t{macros_difference}")
|
96 |
|
97 |
# Calculate macros min, max and mean
|
98 |
if len(macros_differences_list) > 0:
|
|
|
109 |
rest_day_fat_std = [0, 0, 0, 0]
|
110 |
|
111 |
# Print macros min, max and mean
|
112 |
+
print("Variación de macros:")
|
113 |
+
print(f"\tproteína día de entreno: Min: {train_day_protein_std[0]}, Max: {train_day_protein_std[1]}, Mean: {train_day_protein_std[2]:.2f}, Mode: {train_day_protein_std[3]}")
|
114 |
+
print(f"\tcarbohidratos día de entreno: Min: {train_day_carbs_std[0]}, Max: {train_day_carbs_std[1]}, Mean: {train_day_carbs_std[2]:.2f}, Mode: {train_day_carbs_std[3]}")
|
115 |
+
print(f"\tgrasas día de entreno: Min: {train_day_fat_std[0]}, Max: {train_day_fat_std[1]}, Mean: {train_day_fat_std[2]:.2f}, Mode: {train_day_fat_std[3]}")
|
116 |
+
print(f"\tproteína intraentreno: Min: {intratrain_protein_std[0]}, Max: {intratrain_protein_std[1]}, Mean: {intratrain_protein_std[2]:.2f}, Mode: {intratrain_protein_std[3]}")
|
117 |
+
print(f"\tcarbohidratos intraentreno: Min: {intratrain_carbs_std[0]}, Max: {intratrain_carbs_std[1]}, Mean: {intratrain_carbs_std[2]:.2f}, Mode: {intratrain_carbs_std[3]}")
|
118 |
+
print(f"\tproteína día de descanso: Min: {rest_day_protein_std[0]}, Max: {rest_day_protein_std[1]}, Mean: {rest_day_protein_std[2]:.2f}, Mode: {rest_day_protein_std[3]}")
|
119 |
+
print(f"\tcarbohidratos día de descanso: Min: {rest_day_carbs_std[0]}, Max: {rest_day_carbs_std[1]}, Mean: {rest_day_carbs_std[2]:.2f}, Mode: {rest_day_carbs_std[3]}")
|
120 |
+
print(f"\tgrasas día de descanso: Min: {rest_day_fat_std[0]}, Max: {rest_day_fat_std[1]}, Mean: {rest_day_fat_std[2]:.2f}, Mode: {rest_day_fat_std[3]}")
|
121 |
|
122 |
+
# Get macros mode
|
123 |
+
train_day_protein_mode = train_day_protein_std[3]
|
124 |
+
train_day_carbs_mode = train_day_carbs_std[3]
|
125 |
+
train_day_fat_mode = train_day_fat_std[3]
|
126 |
+
intratrain_protein_mode = intratrain_protein_std[3]
|
127 |
+
intratrain_carbs_mode = intratrain_carbs_std[3]
|
128 |
+
rest_day_protein_mode = rest_day_protein_std[3]
|
129 |
+
rest_day_carbs_mode = rest_day_carbs_std[3]
|
130 |
+
rest_day_fat_mode = rest_day_fat_std[3]
|
|
|
|
|
131 |
|
132 |
# Calculate macros final
|
133 |
train_day_protein_final = train_day_protein_initial + train_day_protein_mode
|
134 |
train_day_carbs_final = train_day_carbs_initial + train_day_carbs_mode
|
135 |
train_day_fat_final = train_day_fat_initial + train_day_fat_mode
|
|
|
136 |
intratrain_protein_final = intratrain_protein_initial + intratrain_protein_mode
|
137 |
intratrain_carbs_final = intratrain_carbs_initial + intratrain_carbs_mode
|
|
|
138 |
rest_day_protein_final = rest_day_protein_initial + rest_day_protein_mode
|
139 |
rest_day_carbs_final = rest_day_carbs_initial + rest_day_carbs_mode
|
140 |
rest_day_fat_final = rest_day_fat_initial + rest_day_fat_mode
|
141 |
|
142 |
+
# Print macros
|
143 |
+
print("Macros finales:")
|
144 |
+
print(f"\tProteína día de entreno inicial: {train_day_protein_initial} --> final: {train_day_protein_final}")
|
145 |
+
print(f"\tCarbohidratos día de entreno inicial: {train_day_carbs_initial} --> final: {train_day_carbs_final}")
|
146 |
+
print(f"\tGrasas día de entreno inicial: {train_day_fat_initial} --> final: {train_day_fat_final}")
|
147 |
+
print(f"\tProteína intraentreno inicial: {intratrain_protein_initial} --> final: {intratrain_protein_final}")
|
148 |
+
print(f"\tCarbohidratos intraentreno inicial: {intratrain_carbs_initial} --> final: {intratrain_carbs_final}")
|
149 |
+
print(f"\tProteína día de descanso inicial: {rest_day_protein_initial} --> final: {rest_day_protein_final}")
|
150 |
+
print(f"\tCarbohidratos día de descanso inicial: {rest_day_carbs_initial} --> final: {rest_day_carbs_final}")
|
151 |
+
print(f"\tGrasas día de descanso inicial: {rest_day_fat_initial} --> final: {rest_day_fat_final}")
|
152 |
+
|
153 |
return (train_day_protein_final, train_day_carbs_final, train_day_fat_final,
|
154 |
intratrain_protein_final, intratrain_carbs_final,
|
155 |
rest_day_protein_final, rest_day_carbs_final, rest_day_fat_final)
|
156 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
# Definimos el color naranja
|
158 |
naranja = "#ea580b"
|
159 |
|
160 |
+
title = f"""
|
161 |
+
<h1 style="text-align: center; color: {naranja}; margin: 0; padding-bottom: 30px; font-size: 50px;">Macros evolution</h1>
|
162 |
+
"""
|
163 |
+
|
164 |
title_macros_iniciales_html = f"""
|
165 |
+
<h2 style="text-align: center; color: {naranja}; margin: 0; padding: 0;">Macros iniciales</h2>
|
166 |
"""
|
167 |
|
168 |
title_cuestionario_html = f"""
|
169 |
+
<h2 style="text-align: center; color: {naranja}; margin: 0; padding: 0;">Respuestas cuestionario</h2>
|
170 |
"""
|
171 |
|
172 |
title_macros_finales_html = f"""
|
173 |
+
<h2 style="text-align: center; color: {naranja}; margin: 0; padding: 0;">Macros finales</h2>
|
174 |
"""
|
175 |
|
176 |
style_css = f"""
|
|
|
217 |
textos_cumplimiento_entr = [list(opcion.values())[0]["text"] for opcion in opciones_cumplimiento_entrenamiento]
|
218 |
textos_cumplimiento_dieta = [list(opcion.values())[0]["text"] for opcion in opciones_cumplimiento_dieta]
|
219 |
textos_compromiso = [list(opcion.values())[0]["text"] for opcion in opciones_compromiso]
|
220 |
+
|
221 |
+
# Title
|
222 |
+
gr.Markdown(title)
|
223 |
|
224 |
# Entradas
|
225 |
gr.Markdown(title_macros_iniciales_html)
|
find_matches.py
CHANGED
@@ -10,6 +10,45 @@ def find_user_dates_matches(query, debug=False):
|
|
10 |
# Create a dictionary to store the matches
|
11 |
matches_dict = {}
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
# Get all the files in the formularios_path
|
14 |
files = Path(formularios_weight_difference_path).glob('*.json')
|
15 |
files = list(files)
|
@@ -50,6 +89,21 @@ def find_user_dates_matches(query, debug=False):
|
|
50 |
def find_macros_that_match_dates_of_users(matches_dict, debug=False):
|
51 |
# Create a list to store the macros differences
|
52 |
macros_differences_list = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
# Iterate over the matches dictionary
|
55 |
for match_user in matches_dict:
|
@@ -60,6 +114,13 @@ def find_macros_that_match_dates_of_users(matches_dict, debug=False):
|
|
60 |
|
61 |
# Get user data
|
62 |
user_data = usuarios_macros_difference_path + '/' + match_user
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
user_data = json.load(open(user_data, 'r'))
|
64 |
|
65 |
# Query usuarios
|
|
|
10 |
# Create a dictionary to store the matches
|
11 |
matches_dict = {}
|
12 |
|
13 |
+
# Get the query values
|
14 |
+
query_cumplimiento_entrenamiento = None
|
15 |
+
query_cumplimiento_dieta = None
|
16 |
+
query_compromiso = None
|
17 |
+
query_esfuerzo_dieta = None
|
18 |
+
query_objetivo = None
|
19 |
+
for query_item in query:
|
20 |
+
query_item_key = list(query_item.keys())[0]
|
21 |
+
query_item_value = query_item[query_item_key]['value']
|
22 |
+
if query_item_key == 'cumplimientoEntrenamiento':
|
23 |
+
query_cumplimiento_entrenamiento = query_item_value
|
24 |
+
elif query_item_key == 'cumplimientoDieta':
|
25 |
+
query_cumplimiento_dieta = query_item_value
|
26 |
+
elif query_item_key == 'compromiso':
|
27 |
+
query_compromiso = query_item_value
|
28 |
+
elif query_item_key == 'esfuerzoParaCumplirDieta':
|
29 |
+
query_esfuerzo_dieta = query_item_value
|
30 |
+
elif query_item_key == 'objetivo':
|
31 |
+
query_objetivo = query_item_value
|
32 |
+
|
33 |
+
# If cumplimiento entrenamiento or cumplimiento dieta is mal, then return empty dict
|
34 |
+
if query_cumplimiento_entrenamiento == 'mal' or query_cumplimiento_dieta == 'mal':
|
35 |
+
print("[find_user_dates_matches] Cumplimiento entrenamiento or cumplimiento dieta is \"mal\"")
|
36 |
+
return matches_dict
|
37 |
+
|
38 |
+
# If query_esfuerzo_dieta is costo subir macros, then return subir macros dict
|
39 |
+
if query_esfuerzo_dieta == 'costo subir macros':
|
40 |
+
print("[find_user_dates_matches] query_esfuerzo_dieta is \"costo subir macros\"")
|
41 |
+
subir_macros_dict = {}
|
42 |
+
subir_macros_dict['costo subir macros'] = []
|
43 |
+
return subir_macros_dict
|
44 |
+
|
45 |
+
# If query_esfuerzo_dieta is costo bajar macros, then return bajar macros dict
|
46 |
+
elif query_esfuerzo_dieta == 'costo bajar macros':
|
47 |
+
print("[find_user_dates_matches] query_esfuerzo_dieta is \"costo bajar macros\"")
|
48 |
+
bajar_macros_dict = {}
|
49 |
+
bajar_macros_dict['costo bajar macros'] = []
|
50 |
+
return bajar_macros_dict
|
51 |
+
|
52 |
# Get all the files in the formularios_path
|
53 |
files = Path(formularios_weight_difference_path).glob('*.json')
|
54 |
files = list(files)
|
|
|
89 |
def find_macros_that_match_dates_of_users(matches_dict, debug=False):
|
90 |
# Create a list to store the macros differences
|
91 |
macros_differences_list = []
|
92 |
+
macros_differences_list_subir_macros = ["0 20 0 0 0 0 20 0"]
|
93 |
+
macros_differences_list_bajar_macros = ["0 -20 0 0 0 0 -20 0"]
|
94 |
+
|
95 |
+
# If matches_dict is empty, then return empty list
|
96 |
+
if len(matches_dict) == 0:
|
97 |
+
print("[find_macros_that_match_dates_of_users] matches_dict is empty")
|
98 |
+
return macros_differences_list
|
99 |
+
|
100 |
+
# If matches_dict is costo subir macros, then return empty list
|
101 |
+
if list(matches_dict.keys())[0] == 'costo subir macros':
|
102 |
+
print("[find_macros_that_match_dates_of_users] matches_dict is \"costo subir macros\"")
|
103 |
+
return macros_differences_list_subir_macros
|
104 |
+
elif list(matches_dict.keys())[0] == 'costo bajar macros':
|
105 |
+
print("[find_macros_that_match_dates_of_users] matches_dict is \"costo bajar macros\"")
|
106 |
+
return macros_differences_list_bajar_macros
|
107 |
|
108 |
# Iterate over the matches dictionary
|
109 |
for match_user in matches_dict:
|
|
|
114 |
|
115 |
# Get user data
|
116 |
user_data = usuarios_macros_difference_path + '/' + match_user
|
117 |
+
|
118 |
+
# Check if user data exists
|
119 |
+
if not Path(user_data).exists():
|
120 |
+
if debug: print(f"User data not found: {user_data}")
|
121 |
+
continue
|
122 |
+
|
123 |
+
# Load user data
|
124 |
user_data = json.load(open(user_data, 'r'))
|
125 |
|
126 |
# Query usuarios
|
input_options.py
ADDED
@@ -0,0 +1,219 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Definimos las opciones para cada menú desplegable
|
2 |
+
opciones_esfuerzo = [
|
3 |
+
{
|
4 |
+
"No entiendo la calculadora, quiero menús tipo": {
|
5 |
+
"text": "No entiendo la calculadora, quiero menús tipo",
|
6 |
+
"value": " | no data"
|
7 |
+
}
|
8 |
+
},
|
9 |
+
{
|
10 |
+
"No costó nada": {
|
11 |
+
"text": "No costó nada",
|
12 |
+
"value": " | no costo"
|
13 |
+
}
|
14 |
+
},
|
15 |
+
{
|
16 |
+
"Costó demasiado, súbeme macros": {
|
17 |
+
"text": "Costó demasiado, súbeme macros",
|
18 |
+
"value": " | costo subir macros"
|
19 |
+
}
|
20 |
+
},
|
21 |
+
{
|
22 |
+
"Costó demasiado, bájame macros": {
|
23 |
+
"text": "Costó demasiado, bájame macros",
|
24 |
+
"value": " | costo bajar macros"
|
25 |
+
}
|
26 |
+
},
|
27 |
+
{
|
28 |
+
"Costó, pero me adapto a nuevos ajustes": {
|
29 |
+
"text": "Costó, pero me adapto a nuevos ajustes",
|
30 |
+
"value": " | costo y me adapto a nuevos ajustes"
|
31 |
+
}
|
32 |
+
},
|
33 |
+
{
|
34 |
+
"Iba a coger menús tipo, pero al final por precio no": {
|
35 |
+
"text": "Iba a coger menús tipo, pero al final por precio no",
|
36 |
+
"value": " | no data"
|
37 |
+
}
|
38 |
+
}
|
39 |
+
]
|
40 |
+
|
41 |
+
opciones_objetivo = [
|
42 |
+
{
|
43 |
+
"definición (nada cambia)": {
|
44 |
+
"text": "definición (nada cambia)",
|
45 |
+
"value": " | definicion"
|
46 |
+
}
|
47 |
+
},
|
48 |
+
{
|
49 |
+
"empezamos a definir (cambia)": {
|
50 |
+
"text": "empezamos a definir (cambia)",
|
51 |
+
"value": " | definicion"
|
52 |
+
}
|
53 |
+
},
|
54 |
+
{
|
55 |
+
"perder peso (nada cambia)": {
|
56 |
+
"text": "perder peso (nada cambia)",
|
57 |
+
"value": " | definicion"
|
58 |
+
}
|
59 |
+
},
|
60 |
+
{
|
61 |
+
"volumen (nada cambia)": {
|
62 |
+
"text": "volumen (nada cambia)",
|
63 |
+
"value": " | volumen"
|
64 |
+
}
|
65 |
+
},
|
66 |
+
{
|
67 |
+
"empezamos a coger volumen (cambia)": {
|
68 |
+
"text": "empezamos a coger volumen (cambia)",
|
69 |
+
"value": " | volumen"
|
70 |
+
}
|
71 |
+
},
|
72 |
+
{
|
73 |
+
"empezamos a coger volumen, sobre todo tren inferior (cambia)": {
|
74 |
+
"text": "empezamos a coger volumen, sobre todo tren inferior (cambia)",
|
75 |
+
"value": " | volumen"
|
76 |
+
}
|
77 |
+
},
|
78 |
+
{
|
79 |
+
"empezamos a coger volumen, en todo el cuerpo (cambia)": {
|
80 |
+
"text": "empezamos a coger volumen, en todo el cuerpo (cambia)",
|
81 |
+
"value": " | volumen"
|
82 |
+
}
|
83 |
+
}
|
84 |
+
]
|
85 |
+
|
86 |
+
opciones_cumplimiento_entrenamiento = [
|
87 |
+
{
|
88 |
+
"Lo hice perfecto": {
|
89 |
+
"text": "Lo hice perfecto",
|
90 |
+
"value": " | bien"
|
91 |
+
}
|
92 |
+
},
|
93 |
+
{
|
94 |
+
"He fallado algunos días, pero sí": {
|
95 |
+
"text": "He fallado algunos días, pero sí",
|
96 |
+
"value": " | bien"
|
97 |
+
}
|
98 |
+
},
|
99 |
+
{
|
100 |
+
"Lesión importante": {
|
101 |
+
"text": "Lesión importante",
|
102 |
+
"value": " | mal"
|
103 |
+
}
|
104 |
+
},
|
105 |
+
{
|
106 |
+
"Lo hice prácticamente perfecto": {
|
107 |
+
"text": "Lo hice prácticamente perfecto",
|
108 |
+
"value": " | bien"
|
109 |
+
}
|
110 |
+
},
|
111 |
+
{
|
112 |
+
"Pequeña lesión": {
|
113 |
+
"text": "Pequeña lesión",
|
114 |
+
"value": " | mal"
|
115 |
+
}
|
116 |
+
},
|
117 |
+
{
|
118 |
+
"No hice nada, mantenemos la rutina un mes más": {
|
119 |
+
"text": "No hice nada, mantenemos la rutina un mes más",
|
120 |
+
"value": " | mal"
|
121 |
+
}
|
122 |
+
},
|
123 |
+
{
|
124 |
+
"Alárgame la rutina una semana más": {
|
125 |
+
"text": "Alárgame la rutina una semana más",
|
126 |
+
"value": " | mal"
|
127 |
+
}
|
128 |
+
}
|
129 |
+
]
|
130 |
+
|
131 |
+
opciones_cumplimiento_dieta = [
|
132 |
+
{
|
133 |
+
"al 70%": {
|
134 |
+
"text": "al 70%",
|
135 |
+
"value": " | bien"
|
136 |
+
}
|
137 |
+
},
|
138 |
+
{
|
139 |
+
"regular, me cuesta llegar": {
|
140 |
+
"text": "regular, me cuesta llegar",
|
141 |
+
"value": " | regular"
|
142 |
+
}
|
143 |
+
},
|
144 |
+
{
|
145 |
+
"Nada, mantén mis macros": {
|
146 |
+
"text": "Nada, mantén mis macros",
|
147 |
+
"value": " | mal"
|
148 |
+
}
|
149 |
+
},
|
150 |
+
{
|
151 |
+
"casi perfecta": {
|
152 |
+
"text": "casi perfecta",
|
153 |
+
"value": " | bien"
|
154 |
+
}
|
155 |
+
},
|
156 |
+
{
|
157 |
+
"regular, me salto la dieta": {
|
158 |
+
"text": "regular, me salto la dieta",
|
159 |
+
"value": " | regular"
|
160 |
+
}
|
161 |
+
},
|
162 |
+
{
|
163 |
+
"Perfecta": {
|
164 |
+
"text": "Perfecta",
|
165 |
+
"value": " | bien"
|
166 |
+
}
|
167 |
+
}
|
168 |
+
]
|
169 |
+
|
170 |
+
opciones_compromiso = [
|
171 |
+
{
|
172 |
+
"Bueno, pero mejorable": {
|
173 |
+
"text": "Bueno, pero mejorable",
|
174 |
+
"value": " | bueno"
|
175 |
+
}
|
176 |
+
},
|
177 |
+
{
|
178 |
+
"Mal, pero a partir de ahora voy a por todas": {
|
179 |
+
"text": "Mal, pero a partir de ahora voy a por todas",
|
180 |
+
"value": " | mal"
|
181 |
+
}
|
182 |
+
},
|
183 |
+
{
|
184 |
+
"Mal, demasiado exigente": {
|
185 |
+
"text": "Mal, demasiado exigente",
|
186 |
+
"value": " | mal"
|
187 |
+
}
|
188 |
+
},
|
189 |
+
{
|
190 |
+
"Máximo": {
|
191 |
+
"text": "Máximo",
|
192 |
+
"value": " | bueno"
|
193 |
+
}
|
194 |
+
}
|
195 |
+
]
|
196 |
+
|
197 |
+
diferencia_peso_options = [
|
198 |
+
-5,
|
199 |
+
-4.5,
|
200 |
+
-4,
|
201 |
+
-3.5,
|
202 |
+
-3,
|
203 |
+
-2.5,
|
204 |
+
-2,
|
205 |
+
-1.5,
|
206 |
+
-1,
|
207 |
+
-0.5,
|
208 |
+
0,
|
209 |
+
0.5,
|
210 |
+
1,
|
211 |
+
1.5,
|
212 |
+
2,
|
213 |
+
2.5,
|
214 |
+
3,
|
215 |
+
3.5,
|
216 |
+
4,
|
217 |
+
4.5,
|
218 |
+
5
|
219 |
+
]
|
queries.py
CHANGED
@@ -351,19 +351,19 @@ def clustering_esfuerzo_dieta_response(response, debug=False):
|
|
351 |
# 4 (no costó):
|
352 |
# No costó nada|A: 1504 | no costo
|
353 |
|
354 |
-
if " | No data".lower() in response.lower():
|
355 |
if debug: print(f"\t\t{response} -> no data")
|
356 |
return 'no data'
|
357 |
-
elif " | costo subir macros".lower() in response.lower():
|
358 |
if debug: print(f"\t\t{response} -> costo subir macros")
|
359 |
return 'costo subir macros'
|
360 |
-
elif " | costo bajar macros".lower() in response.lower():
|
361 |
if debug: print(f"\t\t{response} -> costo bajar macros")
|
362 |
return 'costo bajar macros'
|
363 |
-
elif " | costo y me adapto a nuevos ajustes".lower() in response.lower():
|
364 |
if debug: print(f"\t\t{response} -> costo y me adapto a nuevos ajustes")
|
365 |
return 'costo y me adapto a nuevos ajustes'
|
366 |
-
elif " | no costo".lower() in response.lower():
|
367 |
if debug: print(f"\t\t{response} -> no costo")
|
368 |
return 'no costo'
|
369 |
else:
|
@@ -391,10 +391,10 @@ def clustering_objetivo_response(response, debug=False):
|
|
391 |
# empezamos a coger volumen, sobre todo tren inferior (cambia)|C: 7 | volumen
|
392 |
# empezamos a coger volumen, en todo el cuerpo (cambia)|C: 6 | volumen
|
393 |
|
394 |
-
if " | definicion".lower() in response.lower():
|
395 |
if debug: print(f"\t\t{response} -> definicion")
|
396 |
return 'definicion'
|
397 |
-
elif " | volumen".lower() in response.lower():
|
398 |
if debug: print(f"\t\t{response} -> volumen")
|
399 |
return 'volumen'
|
400 |
else:
|
@@ -422,10 +422,10 @@ def clustering_entrenamiento_response(response, debug=False):
|
|
422 |
# No hice nada, mantenemos la rutina un mes más|I|0: 64 | mal
|
423 |
# Alárgame la rutina una semana más|I|6: 32 | mal
|
424 |
|
425 |
-
if " | bien".lower() in response.lower():
|
426 |
if debug: print(f"\t\t{response} -> bien")
|
427 |
return 'bien'
|
428 |
-
elif " | mal".lower() in response.lower():
|
429 |
if debug: print(f"\t\t{response} -> mal")
|
430 |
return 'mal'
|
431 |
else:
|
@@ -452,13 +452,13 @@ def clustering_cumplimiento_dieta_response(response, debug=False):
|
|
452 |
# 2 (mal):
|
453 |
# Nada, mantén mis macros|I|0: 123 | mal
|
454 |
|
455 |
-
if " | bien".lower() in response.lower():
|
456 |
if debug: print(f"\t\t{response} -> bien")
|
457 |
return 'bien'
|
458 |
-
elif " | regular".lower() in response.lower():
|
459 |
if debug: print(f"\t\t{response} -> regular")
|
460 |
return 'regular'
|
461 |
-
elif "nada" in response.lower():
|
462 |
if debug: print(f"\t\t{response} -> mal")
|
463 |
return 'mal'
|
464 |
else:
|
@@ -480,10 +480,10 @@ def clustering_compromiso_response(response, debug=False):
|
|
480 |
# Mal, pero a partir de ahora voy a por todas|C|0: 319 | mal
|
481 |
# Mal, demasiado exigente|D|0: 15 | mal
|
482 |
|
483 |
-
if " | bueno".lower() in response.lower():
|
484 |
if debug: print(f"\t\t{response} -> bueno")
|
485 |
return 'bueno'
|
486 |
-
elif " | mal".lower() in response.lower():
|
487 |
if debug: print(f"\t\t{response} -> mal")
|
488 |
return 'mal'
|
489 |
else:
|
@@ -630,56 +630,100 @@ def dieta_response(response_esfuerzo, response_cumplimiento, debug=False):
|
|
630 |
else:
|
631 |
return 3
|
632 |
|
633 |
-
def make_query(cluster_esfuerzo_dieta, cluster_objetivo, cluster_entrenamiento, cluster_cumplimiento_dieta,
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
685 |
return query
|
|
|
351 |
# 4 (no costó):
|
352 |
# No costó nada|A: 1504 | no costo
|
353 |
|
354 |
+
if " | No data".lower() in response.lower() or 'no data'.lower() in response.lower():
|
355 |
if debug: print(f"\t\t{response} -> no data")
|
356 |
return 'no data'
|
357 |
+
elif " | costo subir macros".lower() in response.lower() or 'costo subir macros'.lower() in response.lower():
|
358 |
if debug: print(f"\t\t{response} -> costo subir macros")
|
359 |
return 'costo subir macros'
|
360 |
+
elif " | costo bajar macros".lower() in response.lower() or 'costo bajar macros'.lower() in response.lower():
|
361 |
if debug: print(f"\t\t{response} -> costo bajar macros")
|
362 |
return 'costo bajar macros'
|
363 |
+
elif " | costo y me adapto a nuevos ajustes".lower() in response.lower() or 'costo y me adapto a nuevos ajustes'.lower() in response.lower():
|
364 |
if debug: print(f"\t\t{response} -> costo y me adapto a nuevos ajustes")
|
365 |
return 'costo y me adapto a nuevos ajustes'
|
366 |
+
elif " | no costo".lower() in response.lower() or 'no costo'.lower() in response.lower():
|
367 |
if debug: print(f"\t\t{response} -> no costo")
|
368 |
return 'no costo'
|
369 |
else:
|
|
|
391 |
# empezamos a coger volumen, sobre todo tren inferior (cambia)|C: 7 | volumen
|
392 |
# empezamos a coger volumen, en todo el cuerpo (cambia)|C: 6 | volumen
|
393 |
|
394 |
+
if " | definicion".lower() in response.lower() or 'definicion'.lower() in response.lower():
|
395 |
if debug: print(f"\t\t{response} -> definicion")
|
396 |
return 'definicion'
|
397 |
+
elif " | volumen".lower() in response.lower() or 'volumen'.lower() in response.lower():
|
398 |
if debug: print(f"\t\t{response} -> volumen")
|
399 |
return 'volumen'
|
400 |
else:
|
|
|
422 |
# No hice nada, mantenemos la rutina un mes más|I|0: 64 | mal
|
423 |
# Alárgame la rutina una semana más|I|6: 32 | mal
|
424 |
|
425 |
+
if " | bien".lower() in response.lower() or 'bien'.lower() in response.lower():
|
426 |
if debug: print(f"\t\t{response} -> bien")
|
427 |
return 'bien'
|
428 |
+
elif " | mal".lower() in response.lower() or 'mal'.lower() in response.lower():
|
429 |
if debug: print(f"\t\t{response} -> mal")
|
430 |
return 'mal'
|
431 |
else:
|
|
|
452 |
# 2 (mal):
|
453 |
# Nada, mantén mis macros|I|0: 123 | mal
|
454 |
|
455 |
+
if " | bien".lower() in response.lower() or 'bien'.lower() in response.lower():
|
456 |
if debug: print(f"\t\t{response} -> bien")
|
457 |
return 'bien'
|
458 |
+
elif " | regular".lower() in response.lower() or 'regular'.lower() in response.lower():
|
459 |
if debug: print(f"\t\t{response} -> regular")
|
460 |
return 'regular'
|
461 |
+
elif "nada" in response.lower() or 'mal'.lower() in response.lower():
|
462 |
if debug: print(f"\t\t{response} -> mal")
|
463 |
return 'mal'
|
464 |
else:
|
|
|
480 |
# Mal, pero a partir de ahora voy a por todas|C|0: 319 | mal
|
481 |
# Mal, demasiado exigente|D|0: 15 | mal
|
482 |
|
483 |
+
if " | bueno".lower() in response.lower() or 'bueno'.lower() in response.lower():
|
484 |
if debug: print(f"\t\t{response} -> bueno")
|
485 |
return 'bueno'
|
486 |
+
elif " | mal".lower() in response.lower() or 'mal'.lower() in response.lower():
|
487 |
if debug: print(f"\t\t{response} -> mal")
|
488 |
return 'mal'
|
489 |
else:
|
|
|
630 |
else:
|
631 |
return 3
|
632 |
|
633 |
+
def make_query(cluster_esfuerzo_dieta, cluster_objetivo, cluster_entrenamiento, cluster_cumplimiento_dieta,
|
634 |
+
cluster_compromiso, diff_peso_min, diff_peso_max,
|
635 |
+
basic_query=False):
|
636 |
+
if not basic_query:
|
637 |
+
query = [
|
638 |
+
{
|
639 |
+
'esfuerzoParaCumplirDieta':
|
640 |
+
{
|
641 |
+
'operator': 'in',
|
642 |
+
'value': cluster_esfuerzo_dieta,
|
643 |
+
}
|
644 |
+
},
|
645 |
+
{
|
646 |
+
'objetivo':
|
647 |
+
{
|
648 |
+
'operator': 'in',
|
649 |
+
'value': cluster_objetivo,
|
650 |
+
}
|
651 |
+
},
|
652 |
+
{
|
653 |
+
'cumplimientoEntrenamiento':
|
654 |
+
{
|
655 |
+
'operator': 'in',
|
656 |
+
'value': cluster_entrenamiento,
|
657 |
+
}
|
658 |
+
},
|
659 |
+
{
|
660 |
+
'cumplimientoDieta':
|
661 |
+
{
|
662 |
+
'operator': 'in',
|
663 |
+
'value': cluster_cumplimiento_dieta,
|
664 |
+
}
|
665 |
+
},
|
666 |
+
{
|
667 |
+
'compromiso':
|
668 |
+
{
|
669 |
+
'operator': 'in',
|
670 |
+
'value': cluster_compromiso,
|
671 |
+
}
|
672 |
+
},
|
673 |
+
{
|
674 |
+
'diferencia_peso':
|
675 |
+
{
|
676 |
+
'operator': '<=',
|
677 |
+
'value': diff_peso_max,
|
678 |
+
}
|
679 |
+
},
|
680 |
+
{
|
681 |
+
'diferencia_peso':
|
682 |
+
{
|
683 |
+
'operator': '>=',
|
684 |
+
'value': diff_peso_min,
|
685 |
+
}
|
686 |
+
}
|
687 |
+
]
|
688 |
+
else:
|
689 |
+
query = [
|
690 |
+
{
|
691 |
+
'objetivo':
|
692 |
+
{
|
693 |
+
'operator': 'in',
|
694 |
+
'value': cluster_objetivo,
|
695 |
+
}
|
696 |
+
},
|
697 |
+
{
|
698 |
+
'cumplimientoEntrenamiento':
|
699 |
+
{
|
700 |
+
'operator': 'in',
|
701 |
+
'value': cluster_entrenamiento,
|
702 |
+
}
|
703 |
+
},
|
704 |
+
{
|
705 |
+
'cumplimientoDieta':
|
706 |
+
{
|
707 |
+
'operator': 'in',
|
708 |
+
'value': cluster_cumplimiento_dieta,
|
709 |
+
}
|
710 |
+
},
|
711 |
+
]
|
712 |
+
|
713 |
+
if cluster_esfuerzo_dieta.lower() == 'costo subir macros'.lower() or cluster_esfuerzo_dieta.lower() == 'costo bajar macros'.lower():
|
714 |
+
# Remove diferencia peso
|
715 |
+
query.pop(6)
|
716 |
+
query.pop(5)
|
717 |
+
# Remove compromiso
|
718 |
+
query.pop(4)
|
719 |
+
# Remove cumplimiento dieta
|
720 |
+
query.pop(3)
|
721 |
+
# Remove cumplimiento entrenamiento
|
722 |
+
query.pop(2)
|
723 |
+
# Remove objetivo
|
724 |
+
query.pop(1)
|
725 |
+
elif cluster_esfuerzo_dieta.lower() == 'no data'.lower():
|
726 |
+
# Remove esfuerzo dieta
|
727 |
+
query.pop(0)
|
728 |
+
|
729 |
return query
|
test.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
test_one_query.ipynb
ADDED
@@ -0,0 +1,505 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 1,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [],
|
8 |
+
"source": [
|
9 |
+
"from pathlib import Path\n",
|
10 |
+
"import json\n",
|
11 |
+
"from queries import (query_formularios, query_usuarios, get_macros_differences, get_min_max_mean_mode_macros_differences,\n",
|
12 |
+
" clustering_esfuerzo_dieta_response, clustering_objetivo_response, clustering_entrenamiento_response,\n",
|
13 |
+
" clustering_cumplimiento_dieta_response, clustering_compromiso_response, \n",
|
14 |
+
" make_query)\n",
|
15 |
+
"from find_matches import find_user_dates_matches, find_macros_that_match_dates_of_users\n",
|
16 |
+
"from input_options import opciones_esfuerzo, opciones_objetivo, opciones_cumplimiento_entrenamiento, opciones_cumplimiento_dieta, opciones_compromiso"
|
17 |
+
]
|
18 |
+
},
|
19 |
+
{
|
20 |
+
"cell_type": "code",
|
21 |
+
"execution_count": 2,
|
22 |
+
"metadata": {},
|
23 |
+
"outputs": [],
|
24 |
+
"source": [
|
25 |
+
"formularios_weight_difference_path = 'formularios_weight_difference'\n",
|
26 |
+
"usuarios_macros_difference_path = 'usuarios_macros_difference'"
|
27 |
+
]
|
28 |
+
},
|
29 |
+
{
|
30 |
+
"cell_type": "code",
|
31 |
+
"execution_count": 3,
|
32 |
+
"metadata": {},
|
33 |
+
"outputs": [],
|
34 |
+
"source": [
|
35 |
+
"# Get all the files in the formularios_path\n",
|
36 |
+
"files = Path(formularios_weight_difference_path).glob('*.json')\n",
|
37 |
+
"files = list(files)\n",
|
38 |
+
"files.sort()"
|
39 |
+
]
|
40 |
+
},
|
41 |
+
{
|
42 |
+
"cell_type": "code",
|
43 |
+
"execution_count": 4,
|
44 |
+
"metadata": {},
|
45 |
+
"outputs": [
|
46 |
+
{
|
47 |
+
"name": "stdout",
|
48 |
+
"output_type": "stream",
|
49 |
+
"text": [
|
50 |
+
"response esfuerzo dieta: No costó nada --> | no costo\n",
|
51 |
+
"response cumplimiento dieta: casi perfecta --> | bien\n",
|
52 |
+
"response objetivo: volumen (nada cambia) --> | volumen\n",
|
53 |
+
"response entrenamiento: Lo hice perfecto --> | bien\n",
|
54 |
+
"response compromiso: Bueno, pero mejorable --> | bueno\n"
|
55 |
+
]
|
56 |
+
}
|
57 |
+
],
|
58 |
+
"source": [
|
59 |
+
"response_esfuerzo_dieta = opciones_esfuerzo[1]\n",
|
60 |
+
"response_esfuerzo_dieta_key = list(response_esfuerzo_dieta.keys())[0]\n",
|
61 |
+
"response_esfuerzo_dieta_text = response_esfuerzo_dieta[response_esfuerzo_dieta_key]['text']\n",
|
62 |
+
"response_esfuerzo_dieta_value = response_esfuerzo_dieta[response_esfuerzo_dieta_key]['value']\n",
|
63 |
+
"\n",
|
64 |
+
"response_cumplimiento_dieta = opciones_cumplimiento_dieta[3]\n",
|
65 |
+
"response_cumplimiento_dieta_key = list(response_cumplimiento_dieta.keys())[0]\n",
|
66 |
+
"response_cumplimiento_dieta_text = response_cumplimiento_dieta[response_cumplimiento_dieta_key]['text']\n",
|
67 |
+
"response_cumplimiento_dieta_value = response_cumplimiento_dieta[response_cumplimiento_dieta_key]['value']\n",
|
68 |
+
"\n",
|
69 |
+
"response_objetivo = opciones_objetivo[3]\n",
|
70 |
+
"response_objetivo_key = list(response_objetivo.keys())[0]\n",
|
71 |
+
"response_objetivo_text = response_objetivo[response_objetivo_key]['text']\n",
|
72 |
+
"response_objetivo_value = response_objetivo[response_objetivo_key]['value']\n",
|
73 |
+
"\n",
|
74 |
+
"response_entrenamiento = opciones_cumplimiento_entrenamiento[0]\n",
|
75 |
+
"response_entrenamiento_key = list(response_entrenamiento.keys())[0]\n",
|
76 |
+
"response_entrenamiento_text = response_entrenamiento[response_entrenamiento_key]['text']\n",
|
77 |
+
"response_entrenamiento_value = response_entrenamiento[response_entrenamiento_key]['value']\n",
|
78 |
+
"\n",
|
79 |
+
"response_compromiso = opciones_compromiso[0]\n",
|
80 |
+
"response_compromiso_key = list(response_compromiso.keys())[0]\n",
|
81 |
+
"response_compromiso_text = response_compromiso[response_compromiso_key]['text']\n",
|
82 |
+
"response_compromiso_value = response_compromiso[response_compromiso_key]['value']\n",
|
83 |
+
"\n",
|
84 |
+
"print(f\"response esfuerzo dieta: {response_esfuerzo_dieta_text} --> {response_esfuerzo_dieta_value}\")\n",
|
85 |
+
"print(f\"response cumplimiento dieta: {response_cumplimiento_dieta_text} --> {response_cumplimiento_dieta_value}\")\n",
|
86 |
+
"print(f\"response objetivo: {response_objetivo_text} --> {response_objetivo_value}\")\n",
|
87 |
+
"print(f\"response entrenamiento: {response_entrenamiento_text} --> {response_entrenamiento_value}\")\n",
|
88 |
+
"print(f\"response compromiso: {response_compromiso_text} --> {response_compromiso_value}\")"
|
89 |
+
]
|
90 |
+
},
|
91 |
+
{
|
92 |
+
"cell_type": "code",
|
93 |
+
"execution_count": 5,
|
94 |
+
"metadata": {},
|
95 |
+
"outputs": [
|
96 |
+
{
|
97 |
+
"name": "stdout",
|
98 |
+
"output_type": "stream",
|
99 |
+
"text": [
|
100 |
+
"Consulta:\n",
|
101 |
+
"\tEsfuerzo para cumplir dieta: no costo\n",
|
102 |
+
"\tCumplimiento dieta: bien\n",
|
103 |
+
"\tObjetivo: volumen\n",
|
104 |
+
"\tEntrenamiento: bien\n",
|
105 |
+
"\tCompromiso: bueno\n",
|
106 |
+
"\t0.5 <= Diferencia peso <= 1.0\n"
|
107 |
+
]
|
108 |
+
}
|
109 |
+
],
|
110 |
+
"source": [
|
111 |
+
"cluster_esfuerzo_dieta = clustering_esfuerzo_dieta_response(response_esfuerzo_dieta_value, debug=False)\n",
|
112 |
+
"cluster_objetivo = clustering_objetivo_response(response_objetivo_value, debug=False)\n",
|
113 |
+
"cluster_entrenamiento = clustering_entrenamiento_response(response_entrenamiento_value, debug=False)\n",
|
114 |
+
"cluster_cumplimiento_dieta = clustering_cumplimiento_dieta_response(response_cumplimiento_dieta_value, debug=False)\n",
|
115 |
+
"cluster_compromiso = clustering_compromiso_response(response_compromiso_value, debug=False)\n",
|
116 |
+
"diff_peso_min = 0.5\n",
|
117 |
+
"diff_peso_max = 1.0\n",
|
118 |
+
"\n",
|
119 |
+
"print(f\"Consulta:\")\n",
|
120 |
+
"print(f\"\\tEsfuerzo para cumplir dieta: {cluster_esfuerzo_dieta}\")\n",
|
121 |
+
"print(f\"\\tCumplimiento dieta: {cluster_cumplimiento_dieta}\")\n",
|
122 |
+
"print(f\"\\tObjetivo: {cluster_objetivo}\")\n",
|
123 |
+
"print(f\"\\tEntrenamiento: {cluster_entrenamiento}\")\n",
|
124 |
+
"print(f\"\\tCompromiso: {cluster_compromiso}\")\n",
|
125 |
+
"print(f\"\\t{diff_peso_min} <= Diferencia peso <= {diff_peso_max}\")"
|
126 |
+
]
|
127 |
+
},
|
128 |
+
{
|
129 |
+
"cell_type": "code",
|
130 |
+
"execution_count": 6,
|
131 |
+
"metadata": {},
|
132 |
+
"outputs": [
|
133 |
+
{
|
134 |
+
"data": {
|
135 |
+
"text/plain": [
|
136 |
+
"[{'esfuerzoParaCumplirDieta': {'operator': 'in', 'value': 'no costo'}},\n",
|
137 |
+
" {'objetivo': {'operator': 'in', 'value': 'volumen'}},\n",
|
138 |
+
" {'cumplimientoEntrenamiento': {'operator': 'in', 'value': 'bien'}},\n",
|
139 |
+
" {'cumplimientoDieta': {'operator': 'in', 'value': 'bien'}},\n",
|
140 |
+
" {'compromiso': {'operator': 'in', 'value': 'bueno'}},\n",
|
141 |
+
" {'diferencia_peso': {'operator': '<=', 'value': 1.0}},\n",
|
142 |
+
" {'diferencia_peso': {'operator': '>=', 'value': 0.5}}]"
|
143 |
+
]
|
144 |
+
},
|
145 |
+
"execution_count": 6,
|
146 |
+
"metadata": {},
|
147 |
+
"output_type": "execute_result"
|
148 |
+
}
|
149 |
+
],
|
150 |
+
"source": [
|
151 |
+
"query = make_query(cluster_esfuerzo_dieta, cluster_objetivo, cluster_entrenamiento, cluster_cumplimiento_dieta, cluster_compromiso, diff_peso_min, diff_peso_max)\n",
|
152 |
+
"query"
|
153 |
+
]
|
154 |
+
},
|
155 |
+
{
|
156 |
+
"cell_type": "code",
|
157 |
+
"execution_count": 10,
|
158 |
+
"metadata": {},
|
159 |
+
"outputs": [
|
160 |
+
{
|
161 |
+
"data": {
|
162 |
+
"text/plain": [
|
163 |
+
"[{'cumplimientoEntrenamiento': {'operator': 'in', 'value': 'bien'}},\n",
|
164 |
+
" {'cumplimientoDieta': {'operator': 'in', 'value': 'regular'}},\n",
|
165 |
+
" {'compromiso': {'operator': 'in', 'value': 'bueno'}},\n",
|
166 |
+
" {'diferencia_peso': {'operator': '<=', 'value': 0.5}},\n",
|
167 |
+
" {'diferencia_peso': {'operator': '>=', 'value': 0}}]"
|
168 |
+
]
|
169 |
+
},
|
170 |
+
"execution_count": 10,
|
171 |
+
"metadata": {},
|
172 |
+
"output_type": "execute_result"
|
173 |
+
}
|
174 |
+
],
|
175 |
+
"source": [
|
176 |
+
"# Delete esfuerzoParaCumplirDieta from query that is element 0\n",
|
177 |
+
"query.pop(0)\n",
|
178 |
+
"query"
|
179 |
+
]
|
180 |
+
},
|
181 |
+
{
|
182 |
+
"cell_type": "code",
|
183 |
+
"execution_count": 10,
|
184 |
+
"metadata": {},
|
185 |
+
"outputs": [],
|
186 |
+
"source": [
|
187 |
+
"matches_dict = find_user_dates_matches(query)"
|
188 |
+
]
|
189 |
+
},
|
190 |
+
{
|
191 |
+
"cell_type": "code",
|
192 |
+
"execution_count": 13,
|
193 |
+
"metadata": {},
|
194 |
+
"outputs": [
|
195 |
+
{
|
196 |
+
"name": "stdout",
|
197 |
+
"output_type": "stream",
|
198 |
+
"text": [
|
199 |
+
"Matches (53):\n",
|
200 |
+
"\[email protected]\n",
|
201 |
+
"\[email protected]\n",
|
202 |
+
"\[email protected]\n",
|
203 |
+
"\[email protected]\n",
|
204 |
+
"\[email protected]\n",
|
205 |
+
"\[email protected]\n",
|
206 |
+
"\[email protected]\n",
|
207 |
+
"\[email protected]\n",
|
208 |
+
"\[email protected]\n",
|
209 |
+
"\[email protected]\n",
|
210 |
+
"\[email protected]\n",
|
211 |
+
"\[email protected]\n",
|
212 |
+
"\[email protected]\n",
|
213 |
+
"\[email protected]\n",
|
214 |
+
"\[email protected]\n",
|
215 |
+
"\[email protected]\n",
|
216 |
+
"\[email protected]\n",
|
217 |
+
"\[email protected]\n",
|
218 |
+
"\[email protected]\n",
|
219 |
+
"\[email protected]\n",
|
220 |
+
"\[email protected]\n",
|
221 |
+
"\[email protected]\n",
|
222 |
+
"\[email protected]\n",
|
223 |
+
"\[email protected]\n",
|
224 |
+
"\[email protected]\n",
|
225 |
+
"\[email protected]\n",
|
226 |
+
"\[email protected]\n",
|
227 |
+
"\[email protected]\n",
|
228 |
+
"\[email protected]\n",
|
229 |
+
"\[email protected]\n",
|
230 |
+
"\[email protected]\n",
|
231 |
+
"\[email protected]\n",
|
232 |
+
"\[email protected]\n",
|
233 |
+
"\[email protected]\n",
|
234 |
+
"\[email protected]\n",
|
235 |
+
"\[email protected]\n",
|
236 |
+
"\[email protected]\n",
|
237 |
+
"\[email protected]\n",
|
238 |
+
"\[email protected]\n",
|
239 |
+
"\[email protected]\n",
|
240 |
+
"\[email protected]\n",
|
241 |
+
"\[email protected]\n",
|
242 |
+
"\[email protected]\n",
|
243 |
+
"\[email protected]\n",
|
244 |
+
"\[email protected]\n",
|
245 |
+
"\[email protected]\n",
|
246 |
+
"\[email protected]\n",
|
247 |
+
"\[email protected]\n",
|
248 |
+
"\[email protected]\n",
|
249 |
+
"\[email protected]\n",
|
250 |
+
"\[email protected]\n",
|
251 |
+
"\[email protected]\n",
|
252 |
+
"\[email protected]\n"
|
253 |
+
]
|
254 |
+
}
|
255 |
+
],
|
256 |
+
"source": [
|
257 |
+
"print(f\"Matches ({len(matches_dict)}):\")\n",
|
258 |
+
"for match in matches_dict:\n",
|
259 |
+
" print(f\"\\t{match}\")"
|
260 |
+
]
|
261 |
+
},
|
262 |
+
{
|
263 |
+
"cell_type": "code",
|
264 |
+
"execution_count": 14,
|
265 |
+
"metadata": {},
|
266 |
+
"outputs": [],
|
267 |
+
"source": [
|
268 |
+
"macros_differences_list = find_macros_that_match_dates_of_users(matches_dict)"
|
269 |
+
]
|
270 |
+
},
|
271 |
+
{
|
272 |
+
"cell_type": "code",
|
273 |
+
"execution_count": 15,
|
274 |
+
"metadata": {},
|
275 |
+
"outputs": [
|
276 |
+
{
|
277 |
+
"name": "stdout",
|
278 |
+
"output_type": "stream",
|
279 |
+
"text": [
|
280 |
+
"Diferencia de macros (109):\n",
|
281 |
+
"\t0 30 0 0 0 0 20 10\n",
|
282 |
+
"\t0 0 10 -5 0 20 10 10\n",
|
283 |
+
"\t0 40 0 0 0 10 20 10\n",
|
284 |
+
"\t0 0 10 0 0 0 10 0\n",
|
285 |
+
"\t0 50 0 0 10 0 40 0\n",
|
286 |
+
"\t0 20 10 0 15 0 20 10\n",
|
287 |
+
"\t0 40 0 0 10 0 20 0\n",
|
288 |
+
"\t0 20 10 0 15 0 30 0\n",
|
289 |
+
"\t0 25 0 0 0 0 20 0\n",
|
290 |
+
"\t0 20 0 0 10 0 0 0\n",
|
291 |
+
"\t0 20 0 0 0 0 20 0\n",
|
292 |
+
"\t0 20 0 0 15 0 10 0\n",
|
293 |
+
"\t0 40 0 0 15 0 40 10\n",
|
294 |
+
"\t0 0 10 0 0 0 25 0\n",
|
295 |
+
"\t0 20 10 0 10 0 20 0\n",
|
296 |
+
"\t0 0 10 0 15 0 20 10\n",
|
297 |
+
"\t0 20 0 0 0 0 10 0\n",
|
298 |
+
"\t0 40 0 0 0 0 40 0\n",
|
299 |
+
"\t0 10 0 0 0 0 0 10\n",
|
300 |
+
"\t0 30 0 0 0 0 30 10\n",
|
301 |
+
"\t0 0 10 0 5 0 10 0\n",
|
302 |
+
"\t-20 10 10 -5 20 0 40 0\n",
|
303 |
+
"\t10 40 0 5 10 -10 40 0\n",
|
304 |
+
"\t0 -10 0 0 0 0 -10 0\n",
|
305 |
+
"\t0 20 0 0 10 0 20 0\n",
|
306 |
+
"\t0 20 0 0 0 0 30 0\n",
|
307 |
+
"\t0 -20 -10 0 0 0 -10 0\n",
|
308 |
+
"\t0 20 0 0 0 0 20 0\n",
|
309 |
+
"\t10 30 0 0 0 10 0 0\n",
|
310 |
+
"\t0 30 0 0 15 10 30 10\n",
|
311 |
+
"\t0 40 0 0 0 0 30 10\n",
|
312 |
+
"\t0 20 0 0 0 0 20 0\n",
|
313 |
+
"\t0 30 0 0 15 0 30 0\n",
|
314 |
+
"\t0 30 0 0 0 0 20 10\n",
|
315 |
+
"\t0 0 10 0 0 0 20 0\n",
|
316 |
+
"\t0 20 0 0 0 0 10 0\n",
|
317 |
+
"\t0 10 0 0 0 0 20 10\n",
|
318 |
+
"\t0 20 0 0 10 0 30 0\n",
|
319 |
+
"\t0 20 10 0 0 0 30 0\n",
|
320 |
+
"\t0 0 0 0 0 0 0 0\n",
|
321 |
+
"\t0 0 0 0 0 0 25 0\n",
|
322 |
+
"\t10 20 10 -5 10 5 20 10\n",
|
323 |
+
"\t0 30 0 0 10 0 20 0\n",
|
324 |
+
"\t0 10 0 0 10 0 10 10\n",
|
325 |
+
"\t0 30 0 0 0 0 30 0\n",
|
326 |
+
"\t0 20 10 0 15 0 40 0\n",
|
327 |
+
"\t0 10 0 0 10 0 20 0\n",
|
328 |
+
"\t0 30 10 0 0 0 20 0\n",
|
329 |
+
"\t0 30 0 0 15 0 20 0\n",
|
330 |
+
"\t0 0 0 0 0 0 0 0\n",
|
331 |
+
"\t-30 40 10 0 10 0 20 10\n",
|
332 |
+
"\t0 20 0 0 10 0 30 0\n",
|
333 |
+
"\t0 -20 0 0 0 0 -10 0\n",
|
334 |
+
"\t0 20 0 0 15 0 20 0\n",
|
335 |
+
"\t0 0 -10 0 -15 0 0 0\n",
|
336 |
+
"\t0 30 10 0 10 0 20 0\n",
|
337 |
+
"\t20 30 10 0 10 10 20 10\n",
|
338 |
+
"\t0 0 0 0 0 0 0 10\n",
|
339 |
+
"\t0 20 0 0 0 0 30 0\n",
|
340 |
+
"\t0 20 10 0 0 0 20 0\n",
|
341 |
+
"\t0 30 0 0 0 0 30 0\n",
|
342 |
+
"\t0 20 0 0 0 0 40 0\n",
|
343 |
+
"\t0 20 0 0 15 0 10 10\n",
|
344 |
+
"\t10 15 0 0 15 -20 15 10\n",
|
345 |
+
"\t0 20 0 0 10 0 20 10\n",
|
346 |
+
"\t0 0 0 0 10 0 0 0\n",
|
347 |
+
"\t-10 40 0 0 10 -10 20 0\n",
|
348 |
+
"\t-20 30 10 -5 10 10 30 10\n",
|
349 |
+
"\t0 40 0 0 0 0 20 10\n",
|
350 |
+
"\t0 30 10 -5 10 10 20 0\n",
|
351 |
+
"\t0 30 0 0 10 0 10 10\n",
|
352 |
+
"\t0 10 10 0 0 0 20 0\n",
|
353 |
+
"\t0 20 0 0 0 0 30 0\n",
|
354 |
+
"\t0 0 0 0 15 0 20 0\n",
|
355 |
+
"\t0 20 0 0 15 0 15 0\n",
|
356 |
+
"\t0 -20 -10 0 -15 0 -30 -10\n",
|
357 |
+
"\t0 40 0 0 0 0 40 0\n",
|
358 |
+
"\t0 20 10 0 0 0 20 0\n",
|
359 |
+
"\t-10 -10 0 0 0 0 -20 0\n",
|
360 |
+
"\t0 40 10 0 15 0 20 0\n",
|
361 |
+
"\t0 20 0 0 0 0 20 0\n",
|
362 |
+
"\t0 30 0 0 0 0 30 10\n",
|
363 |
+
"\t0 20 0 0 0 0 20 0\n",
|
364 |
+
"\t0 0 0 0 0 0 20 0\n",
|
365 |
+
"\t0 30 0 0 0 0 20 0\n",
|
366 |
+
"\t0 40 0 0 10 0 20 0\n",
|
367 |
+
"\t0 0 0 0 10 0 10 10\n",
|
368 |
+
"\t0 30 10 0 0 0 20 0\n",
|
369 |
+
"\t0 0 10 0 -15 0 -20 10\n",
|
370 |
+
"\t0 20 0 0 15 0 30 10\n",
|
371 |
+
"\t0 30 10 0 15 0 30 0\n",
|
372 |
+
"\t0 0 0 0 0 0 0 0\n",
|
373 |
+
"\t0 40 0 0 10 0 20 0\n",
|
374 |
+
"\t0 25 0 0 10 0 30 0\n",
|
375 |
+
"\t0 20 0 0 0 -10 30 0\n",
|
376 |
+
"\t0 40 0 0 0 0 20 10\n",
|
377 |
+
"\t0 20 0 0 0 0 20 0\n",
|
378 |
+
"\t0 30 0 0 0 0 20 0\n",
|
379 |
+
"\t0 30 10 0 10 0 20 -30\n",
|
380 |
+
"\t0 30 0 0 10 0 30 0\n",
|
381 |
+
"\t0 20 0 0 0 0 20 0\n",
|
382 |
+
"\t0 20 0 0 10 0 10 10\n",
|
383 |
+
"\t0 25 0 0 0 0 10 0\n",
|
384 |
+
"\t-5 40 0 -5 15 5 20 0\n",
|
385 |
+
"\t0 15 0 0 0 0 20 0\n",
|
386 |
+
"\t0 -30 0 0 -10 0 -20 0\n",
|
387 |
+
"\t0 20 0 0 0 0 20 10\n",
|
388 |
+
"\t0 10 0 0 0 0 20 0\n",
|
389 |
+
"\t0 30 10 0 0 0 40 0\n"
|
390 |
+
]
|
391 |
+
}
|
392 |
+
],
|
393 |
+
"source": [
|
394 |
+
"print(f\"Diferencia de macros ({len(macros_differences_list)}):\")\n",
|
395 |
+
"for macros_difference in macros_differences_list:\n",
|
396 |
+
" print(f\"\\t{macros_difference}\")"
|
397 |
+
]
|
398 |
+
},
|
399 |
+
{
|
400 |
+
"cell_type": "code",
|
401 |
+
"execution_count": 16,
|
402 |
+
"metadata": {},
|
403 |
+
"outputs": [
|
404 |
+
{
|
405 |
+
"name": "stdout",
|
406 |
+
"output_type": "stream",
|
407 |
+
"text": [
|
408 |
+
"Variación de macros:\n",
|
409 |
+
"\tproteína día de entreno: Min: -30, Max: 20, Mean: -0.32, Mode: 0\n",
|
410 |
+
"\tcarbohidratos día de entreno: Min: -30, Max: 50, Mean: 19.40, Mode: 20\n",
|
411 |
+
"\tgrasas día de entreno: Min: -10, Max: 10, Mean: 2.29, Mode: 0\n",
|
412 |
+
"\tproteína intraentreno: Min: -5, Max: 5, Mean: -0.23, Mode: 0\n",
|
413 |
+
"\tcarbohidratos intraentreno: Min: -15, Max: 20, Mean: 4.77, Mode: 0\n",
|
414 |
+
"\tproteína día de descanso: Min: -20, Max: 20, Mean: 0.37, Mode: 0\n",
|
415 |
+
"\tcarbohidratos día de descanso: Min: -30, Max: 40, Mean: 18.35, Mode: 20\n",
|
416 |
+
"\tgrasas día de descanso: Min: -30, Max: 10, Mean: 2.39, Mode: 0\n"
|
417 |
+
]
|
418 |
+
}
|
419 |
+
],
|
420 |
+
"source": [
|
421 |
+
"train_day_protein_std, train_day_carbs_std, train_day_fat_std, intratrain_protein_std, intratrain_carbs_std, rest_day_protein_std, rest_day_carbs_std, rest_day_fat_std = get_min_max_mean_mode_macros_differences(macros_differences_list)\n",
|
422 |
+
"\n",
|
423 |
+
"print(\"Variación de macros:\")\n",
|
424 |
+
"print(f\"\\tproteína día de entreno: Min: {train_day_protein_std[0]}, Max: {train_day_protein_std[1]}, Mean: {train_day_protein_std[2]:.2f}, Mode: {train_day_protein_std[3]}\")\n",
|
425 |
+
"print(f\"\\tcarbohidratos día de entreno: Min: {train_day_carbs_std[0]}, Max: {train_day_carbs_std[1]}, Mean: {train_day_carbs_std[2]:.2f}, Mode: {train_day_carbs_std[3]}\")\n",
|
426 |
+
"print(f\"\\tgrasas día de entreno: Min: {train_day_fat_std[0]}, Max: {train_day_fat_std[1]}, Mean: {train_day_fat_std[2]:.2f}, Mode: {train_day_fat_std[3]}\")\n",
|
427 |
+
"print(f\"\\tproteína intraentreno: Min: {intratrain_protein_std[0]}, Max: {intratrain_protein_std[1]}, Mean: {intratrain_protein_std[2]:.2f}, Mode: {intratrain_protein_std[3]}\")\n",
|
428 |
+
"print(f\"\\tcarbohidratos intraentreno: Min: {intratrain_carbs_std[0]}, Max: {intratrain_carbs_std[1]}, Mean: {intratrain_carbs_std[2]:.2f}, Mode: {intratrain_carbs_std[3]}\")\n",
|
429 |
+
"print(f\"\\tproteína día de descanso: Min: {rest_day_protein_std[0]}, Max: {rest_day_protein_std[1]}, Mean: {rest_day_protein_std[2]:.2f}, Mode: {rest_day_protein_std[3]}\")\n",
|
430 |
+
"print(f\"\\tcarbohidratos día de descanso: Min: {rest_day_carbs_std[0]}, Max: {rest_day_carbs_std[1]}, Mean: {rest_day_carbs_std[2]:.2f}, Mode: {rest_day_carbs_std[3]}\")\n",
|
431 |
+
"print(f\"\\tgrasas día de descanso: Min: {rest_day_fat_std[0]}, Max: {rest_day_fat_std[1]}, Mean: {rest_day_fat_std[2]:.2f}, Mode: {rest_day_fat_std[3]}\")"
|
432 |
+
]
|
433 |
+
},
|
434 |
+
{
|
435 |
+
"cell_type": "code",
|
436 |
+
"execution_count": 33,
|
437 |
+
"metadata": {},
|
438 |
+
"outputs": [
|
439 |
+
{
|
440 |
+
"name": "stdout",
|
441 |
+
"output_type": "stream",
|
442 |
+
"text": [
|
443 |
+
"Para la consulta\n",
|
444 |
+
"\tobjetivo: \"definicion\"\n",
|
445 |
+
"\tcumplimientoEntrenamiento: \"bien\"\n",
|
446 |
+
"\tcumplimientoDieta: \"regular\"\n",
|
447 |
+
"\tcompromiso: \"bueno\"\n",
|
448 |
+
"\tdiferencia_peso: <= \"0.5\"\n",
|
449 |
+
"\tdiferencia_peso: >= \"0\"\n",
|
450 |
+
"Se recomienda la siguiente variación de macros (g):\n",
|
451 |
+
"\tDía de entrenamiento - proteínas: min: 0.00, max: 0.00, media: 0.00, moda: 0.00\n",
|
452 |
+
"\tDía de entrenamiento - carbohidratos: min: -10.00, max: 10.00, media: -3.33, moda: -10.00\n",
|
453 |
+
"\tDía de entrenamiento - grasa: min: -10.00, max: 0.00, media: -3.33, moda: 0.00\n",
|
454 |
+
"\tIntraentreno - proteínas: min: 0.00, max: 0.00, media: 0.00, moda: 0.00\n",
|
455 |
+
"\tIntraentreno - carbohidratos: min: -15.00, max: 0.00, media: -5.00, moda: 0.00\n",
|
456 |
+
"\tDía de descanso - proteínas: min: 0.00, max: 0.00, media: 0.00, moda: 0.00\n",
|
457 |
+
"\tDía de descanso - carbohidratos: min: -20.00, max: 10.00, media: -3.33, moda: 10.00\n",
|
458 |
+
"\tDía de descanso - grasa: min: -10.00, max: 0.00, media: -3.33, moda: 0.00\n"
|
459 |
+
]
|
460 |
+
}
|
461 |
+
],
|
462 |
+
"source": [
|
463 |
+
"print(f\"Para la consulta\")\n",
|
464 |
+
"for query_item in query:\n",
|
465 |
+
" key = list(query_item.keys())[0]\n",
|
466 |
+
" print(f\"\\t{key}\", end=\": \")\n",
|
467 |
+
" if query_item[key]['operator'] != 'in':\n",
|
468 |
+
" print(f\"{query_item[key]['operator']}\", end=\" \")\n",
|
469 |
+
" print(f\"\\\"{query_item[key]['value']}\\\"\")\n",
|
470 |
+
" \n",
|
471 |
+
"\n",
|
472 |
+
"print(f\"Se recomienda la siguiente variación de macros (g):\")\n",
|
473 |
+
"print(f\"\\tDía de entrenamiento - proteínas: min: {train_day_protein_std[0]:.2f}, max: {train_day_protein_std[1]:.2f}, media: {train_day_protein_std[2]:.2f}, moda: {train_day_protein_std[3]:.2f}\")\n",
|
474 |
+
"print(f\"\\tDía de entrenamiento - carbohidratos: min: {train_day_carbs_std[0]:.2f}, max: {train_day_carbs_std[1]:.2f}, media: {train_day_carbs_std[2]:.2f}, moda: {train_day_carbs_std[3]:.2f}\")\n",
|
475 |
+
"print(f\"\\tDía de entrenamiento - grasa: min: {train_day_fat_std[0]:.2f}, max: {train_day_fat_std[1]:.2f}, media: {train_day_fat_std[2]:.2f}, moda: {train_day_fat_std[3]:.2f}\")\n",
|
476 |
+
"print(f\"\\tIntraentreno - proteínas: min: {intratrain_protein_std[0]:.2f}, max: {intratrain_protein_std[1]:.2f}, media: {intratrain_protein_std[2]:.2f}, moda: {intratrain_protein_std[3]:.2f}\")\n",
|
477 |
+
"print(f\"\\tIntraentreno - carbohidratos: min: {intratrain_carbs_std[0]:.2f}, max: {intratrain_carbs_std[1]:.2f}, media: {intratrain_carbs_std[2]:.2f}, moda: {intratrain_carbs_std[3]:.2f}\")\n",
|
478 |
+
"print(f\"\\tDía de descanso - proteínas: min: {rest_day_protein_std[0]:.2f}, max: {rest_day_protein_std[1]:.2f}, media: {rest_day_protein_std[2]:.2f}, moda: {rest_day_protein_std[3]:.2f}\")\n",
|
479 |
+
"print(f\"\\tDía de descanso - carbohidratos: min: {rest_day_carbs_std[0]:.2f}, max: {rest_day_carbs_std[1]:.2f}, media: {rest_day_carbs_std[2]:.2f}, moda: {rest_day_carbs_std[3]:.2f}\")\n",
|
480 |
+
"print(f\"\\tDía de descanso - grasa: min: {rest_day_fat_std[0]:.2f}, max: {rest_day_fat_std[1]:.2f}, media: {rest_day_fat_std[2]:.2f}, moda: {rest_day_fat_std[3]:.2f}\")"
|
481 |
+
]
|
482 |
+
}
|
483 |
+
],
|
484 |
+
"metadata": {
|
485 |
+
"kernelspec": {
|
486 |
+
"display_name": "Python 3",
|
487 |
+
"language": "python",
|
488 |
+
"name": "python3"
|
489 |
+
},
|
490 |
+
"language_info": {
|
491 |
+
"codemirror_mode": {
|
492 |
+
"name": "ipython",
|
493 |
+
"version": 3
|
494 |
+
},
|
495 |
+
"file_extension": ".py",
|
496 |
+
"mimetype": "text/x-python",
|
497 |
+
"name": "python",
|
498 |
+
"nbconvert_exporter": "python",
|
499 |
+
"pygments_lexer": "ipython3",
|
500 |
+
"version": "3.12.8"
|
501 |
+
}
|
502 |
+
},
|
503 |
+
"nbformat": 4,
|
504 |
+
"nbformat_minor": 2
|
505 |
+
}
|