-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcompute_bmi.py
44 lines (31 loc) · 1.32 KB
/
compute_bmi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import mlflow
from tabulate import tabulate
def calculate_bmi(height, weight):
""" Funcion para calcular el indice de masa corporal
en relación a la estatura y el peso.
Args:
height ([float]): [estatura de la persona]
weight ([float]): [peso de la persona]
"""
return weight / (height/100)**2
if __name__ == "__main__":
# datos que van a ser tipo etiquetas
names = ['Bob', 'Lital', 'Simona']
ages = [18, 32, 100]
# parámetros de entrada de la funcion que calcula el BMI
heights = [150, 165, 50]
weights = [55, 80, 80]
# Para almacenar el resultado y mostrarlo en la terminal
bmis = [] #BMIs a calcular
# Provide uri and connect to your tracking server
mlflow.set_tracking_uri('http://127.0.0.1:5000/')
for i, (height, weight) in enumerate(zip(heights, weights)):
with mlflow.start_run(run_name = names[i]):
bmis.append(calculate_bmi(height, weight))
mlflow.set_tag('age', ages[i])
mlflow.log_param('height', height)
mlflow.log_param('weight', weight)
mlflow.log_metric("bmi", bmis[i])
# imprimo logs en terminal
print(tabulate({"name": names,"age":ages,"height":heights,
"weight":weights,"bmi":bmis}, headers="keys"))