In [9]:
import pandas as pd
%matplotlib inline
import matplotlib.pyplot as plt
import statsmodels.formula.api as smf
In [20]:
df = pd.read_csv("data/heights_weights_genders.csv")
In [21]:
lm = smf.ols(formula="Weight~Height",data=df).fit()
In [22]:
lm.params
Out[22]:
In [23]:
#Getting the parameters:
intercept, height = lm.params
In [37]:
#Testing my formula:
#example_Height = 60
In [38]:
weight = height*example_Height+intercept
In [39]:
weight
Out[39]:
In [54]:
users_height = int(input('Please enter your height in inches: '))
weight = height*users_height+intercept
print('You are approximately', round(weight), "pounds, which is", round(weight * 0.453592), 'kg.')
In [ ]:
In [ ]: