In [20]:
    
import pandas as pd
import matplotlib.pyplot as plt
plt.style.use('fivethirtyeight')
%matplotlib inline
import statsmodels.formula.api as smf
    
In [21]:
    
df = pd.read_csv('hanford.csv')
    
In [22]:
    
df.describe()
    
    Out[22]:
In [23]:
    
df.corr()
    
    Out[23]:
In [24]:
    
lm = smf.ols(formula="Mortality~Exposure",data=df).fit()
lm.params
    
    Out[24]:
In [25]:
    
intercept, slope = lm.params
    
In [26]:
    
df.plot(kind="scatter",x="Exposure",y="Mortality")
    
    Out[26]:
    
Yes, there does seem to be a correlation worthy of investigation.
In [31]:
    
exposure = int(input('What is the exposure level? '))
mortality = slope * exposure + intercept
print('If the exposure is ' + str(exposure) + ' the mortality rate is probably around ' + str(round(mortality, 2)))
    
    
In [28]:
    
df.plot(kind="scatter",x="Exposure",y="Mortality")
plt.plot(df["Exposure"],slope*df["Exposure"]+intercept,"-",color="darkgrey") 
plt.title('Correlation between exposure and mortality rate')
plt.xlabel('Exposure')
plt.ylabel('Mortality Rate')
    
    Out[28]:
    
In [ ]:
    
0.926345 ** 2
    
In [30]:
    
exposure = 10
mortality = slope * exposure + intercept
print('If the exposure is ' + str(exposure) + ' the mortality rate is probably around ' + str(round(mortality, 2)))