<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 1. Import the necessary packages to read in the data, plot, and create a linear regression model
Step1:  2. Read in the hanford.csv file
Step2:  County
Step3:  3. Calculate the basic descriptive statistics on the data
Step4:  4. Calculate the coefficient of correlation (r) and generate the scatter plot. Does there seem to be a correlation worthy of investigation?
Step5:  5. Create a linear regression model based on the available data to predict the mortality rate given a level of exposure
Step6:  6. Plot the linear regression line on the scatter plot of values. Calculate the r^2 (coefficient of determination)
Step7:  7. Predict the mortality rate (Cancer per 100,000 man years) given an index of exposure = 10
<ASSISTANT_TASK:>
Python Code:
import pandas as pd
import pandas as pd
import matplotlib.pyplot as plt # package for doing plotting (necessary for adding the line)
import statsmodels.formula.api as smf # package we'll be using for linear regression
%matplotlib inline
Explanation: 1. Import the necessary packages to read in the data, plot, and create a linear regression model
End of explanation
df = pd.read_csv('../data/hanford.csv')
Explanation: 2. Read in the hanford.csv file
End of explanation
df
Explanation: County: Name of county
Exposuere: Inde of exposure
Mortality: Cancer mortality per 100000 man-years
End of explanation
df.describe()
Explanation: 3. Calculate the basic descriptive statistics on the data
End of explanation
correlation = df.corr()
print(correlation)
df.plot(kind='scatter', x='Exposure', y='Mortality')
Explanation: 4. Calculate the coefficient of correlation (r) and generate the scatter plot. Does there seem to be a correlation worthy of investigation?
End of explanation
lm = smf.ols(formula="Mortality~Exposure",data=df).fit()
lm.params
intercept, height = lm.params
# Function using the built math. 
def simplest_predictor(exposure, height, intercept):
    height = float(height)
    intercept = float(intercept)
    exposure = float(exposure)
    return height*exposure+intercept
# Input the data
exposure = input("Please enter the exposure: ")
print("The mortality rate for your exposure lies at", simplest_predictor(exposure,height,intercept), ".")
Explanation: 5. Create a linear regression model based on the available data to predict the mortality rate given a level of exposure
End of explanation
df.plot(kind="scatter",x="Exposure",y="Mortality")
plt.plot(df["Exposure"],height*df["Exposure"]+intercept,"-",color="darkgrey") #we create the best fit line from the values in the fit model
Explanation: 6. Plot the linear regression line on the scatter plot of values. Calculate the r^2 (coefficient of determination)
End of explanation
def predictiong_mortality_rate(exposure):
    return intercept + float()
Explanation: 7. Predict the mortality rate (Cancer per 100,000 man years) given an index of exposure = 10
End of explanation
<END_TASK>