<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Apply logistic regression to categorize whether a county had high mortality rate due to contamination
1. Import the necessary packages to read in the data, plot, and create a logistic regression model
Step1:  2. Read in the hanford.csv file in the data/ folder
Step2:  3. Calculate the basic descriptive statistics on the data
Step3:  4. Find a reasonable threshold to say exposure is high and recode the data
Step4:  UAL= (IQR * 1.5) +Q3
LAL= Q1- (IQR * 1.5)
Anything outside of UAL and LAL is an outlier
<ASSISTANT_TASK:>
Python Code:
import pandas as pd
%matplotlib inline
import numpy as np
from sklearn.linear_model import LogisticRegression
Explanation: Apply logistic regression to categorize whether a county had high mortality rate due to contamination
1. Import the necessary packages to read in the data, plot, and create a logistic regression model
End of explanation
df = pd.read_csv("hanford.csv")
df.head()
Explanation: 2. Read in the hanford.csv file in the data/ folder
End of explanation
df.mean()
df.median()
#range
df["Exposure"].max() - df["Exposure"].min()
#range
df["Mortality"].max() - df["Mortality"].min()
df.std()
df.corr()
Explanation: 3. Calculate the basic descriptive statistics on the data
End of explanation
#IQR
IQR= df['Exposure'].quantile(q=0.75)- df['Exposure'].quantile(q=0.25)
Explanation: 4. Find a reasonable threshold to say exposure is high and recode the data
End of explanation
Q1= df['Exposure'].quantile(q=0.25) #1st Quartile
Q1
Q2= df['Exposure'].quantile(q=0.5) #2nd Quartile (Median)
Q3= df['Exposure'].quantile(q=0.75) #3rd Quartile
UAL= (IQR * 1.5) +Q3
UAL
LAL= Q1- (IQR * 1.5)
LAL
Explanation: UAL= (IQR * 1.5) +Q3
LAL= Q1- (IQR * 1.5)
Anything outside of UAL and LAL is an outlier
End of explanation
<END_TASK>