In [57]:
import pandas as pd
%matplotlib inline
import matplotlib.pyplot as plt
import statsmodels.formula.api as smf
In [58]:
df = pd.read_csv("data/heights_weights_genders.csv")
In [59]:
df.head()
Out[59]:
In [60]:
users_sex = input('Please enter your sex, m or f: ')
users_height = int(input('Please enter your height in inches: '))
In [61]:
df_male = df[df['Gender'] == 'Male']
df_female = df[df['Gender'] == 'Female']
In [62]:
if users_sex == 'f':
lm = smf.ols(formula="Weight~Height",data=df_female).fit()
elif users_sex == 'm':
lm = smf.ols(formula="Weight~Height",data=df_male).fit()
else:
print("You didn't enter your sex correctly.")
intercept, height = lm.params
weight = height*users_height+intercept
print('You are approximately', round(weight), "pounds, which is", round(weight * 0.453592), 'kg.')
In [ ]: