In [8]:
import pandas as pd
import statsmodels.formula.api as smf
import matplotlib.pyplot as plt
%matplotlib inline

In [6]:
df = pd.read_csv('heights_weights_genders.csv')
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 [7]:
df.plot(kind='scatter', x="Height", y="Weight")


Out[7]:
<matplotlib.axes._subplots.AxesSubplot at 0x112315390>

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

In [10]:
lm.params


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

In [26]:
height_input = input('Please tell me your height in inches:')
if height_input:
    if height_input <= "0":
        print("Something went wrong with data input. Please try again - add in a value bigger than 0!")
    else:
        output = (7.717288 * int(height_input)) + (-350.737192)
        print("I guess your weight might be approximately", output, "pounds. No offense, if it's incorrect; I'm just a simple algorithm ¯\_(ツ)_/¯")


Please tell me your height in inches:68
I guess your weight might be approximately 174.038392 pounds. No offense, if it's incorrect; I'm just a simple algorithm ¯\_(ツ)_/¯

In [ ]:


In [ ]: