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]:
Gender Height Weight
0 Male 73.847017 241.893563
1 Male 68.781904 162.310473
2 Male 74.110105 212.740856
3 Male 71.730978 220.042470
4 Male 69.881796 206.349801

In [22]:
lm = smf.ols(formula="Weight~Height",data=df).fit()

In [23]:
lm.params


Out[23]:
Intercept   -350.737192
Height         7.717288
dtype: float64

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]:
188