In [1]:
import pandas as pd
import statsmodels.formula.api as smf
In [2]:
df = pd.read_csv("heights_weights_genders.csv")
In [4]:
df.head()
Out[4]:
In [5]:
lm = smf.ols(formula="Weight~Height",data=df).fit()
lm.params
Out[5]:
In [8]:
def pre_weight(height):
i = -350.737192
h = 7.717288
weight = i + (h * float(height))
return weight
In [10]:
df['predict_weight'] = df['Height'].apply(pre_weight)
In [12]:
df.head()
Out[12]:
In [ ]: