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


In [1]:
import pandas as pd
%matplotlib inline
import numpy as np
from sklearn.linear_model import LogisticRegression

2. Read in the hanford.csv file in the data/ folder


In [2]:
df = pd.read_csv("hanford.csv")

3. Calculate the basic descriptive statistics on the data


In [3]:
df.describe()


Out[3]:
Exposure Mortality
count 9.000000 9.000000
mean 4.617778 157.344444
std 3.491192 34.791346
min 1.250000 113.500000
25% 2.490000 130.100000
50% 3.410000 147.100000
75% 6.410000 177.900000
max 11.640000 210.300000

4. Find a reasonable threshold to say exposure is high and recode the data


In [9]:
q1 = df.quantile(q=0.25)

In [10]:
q1


Out[10]:
Exposure       2.49
Mortality    130.10
dtype: float64

In [11]:
q3 = df.quantile(q=0.75)

In [12]:
q3


Out[12]:
Exposure       6.41
Mortality    177.90
dtype: float64

In [13]:
iqr = q3-q1

In [14]:
iqr


Out[14]:
Exposure      3.92
Mortality    47.80
dtype: float64

5. Create a logistic regression model


In [ ]:


In [ ]:


In [ ]:

6. Predict whether the mortality rate (Cancer per 100,000 man years) will be high at an exposure level of 50


In [ ]:


In [ ]: