“Use the data from heights_weights_genders.csv to create a simple predictor”… link
In [1]:
import pandas as pd
%matplotlib inline
import matplotlib.pyplot as plt
import statsmodels.formula.api as smf # for linear regression
In [2]:
df = pd.read_csv("../data/heights_weights_genders.csv")
In [13]:
lm = smf.ols(formula="Weight~Height",data=df).fit()
intercept, slope = lm.params
In [14]:
def guess_weight(height):
return slope*height + intercept
In [24]:
your_height = input("Please type your height: ")
print("Your weight should be around {}.".format(guess_weight(int(your_height))))