Use the data from heights_weights_genders.csv to create a simple predictor that takes in a person's height and guesses their weight based on a model using all the data, regardless of gender. To do this, find the parameters (lm.params) and use those in your function (i.e. don't generate a model each time)
In [1]:
import pandas as pd
%matplotlib inline
import matplotlib.pyplot as plt
import statsmodels.formula.api as smf
In [2]:
df = pd.read_csv("heights_weights_genders.csv")
In [13]:
df.head()
Out[13]:
In [4]:
df.plot(kind="scatter",x="Height",y="Weight")
Out[4]:
In [5]:
lm = smf.ols(formula="Weight~Height",data=df).fit()
In [6]:
lm.params
Out[6]:
In [7]:
def find_user_weight(user_height):
user_weight = 7.7172876407853712 * float(user_height) - 350.737192
return user_weight
In [ ]:
user_height = input("How tall are you in inches?: ")
find_user_weight(user_height)
In [ ]: