In [3]:
import pandas as pd
%matplotlib inline
In [4]:
import matplotlib.pyplot as plt
import statsmodels.formula.api as smf
In [5]:
df = pd.read_csv("heights_weights_genders.csv")
In [6]:
df.head()
Out[6]:
In [22]:
lm = smf.ols(formula="Weight~Height",data=df).fit()
In [23]:
lm.params
Out[23]:
In [29]:
def guess_weight(height):
for item in df['Weight']:
intercept = -350.737
weight = height * 7.7 + intercept
return round(weight)
In [30]:
guess_weight(70)
Out[30]: