In [1]:
import pandas as pd
%matplotlib inline
import numpy as np
from sklearn.linear_model import LogisticRegression
In [5]:
cd C:\Users\Harsha Devulapalli\Desktop\algorithms\class7
In [6]:
df=pd.read_csv('data/hanford.csv')
In [13]:
len(df)
Out[13]:
In [7]:
df.describe()
Out[7]:
In [20]:
df['Mortality'].hist(bins=5)
Out[20]:
In [23]:
df['Mort_high']=df['Mortality'].apply(lambda x:1 if x>=147.1 else 0)
df['Exposure_high']=df['Exposure'].apply(lambda x:1 if x>=3.41 else 0)
In [25]:
df
Out[25]:
In [ ]:
df exposure_high(x):
if x >=3.41
return 1
else:
return 0
# THIS IS THE FUNCTION ONE HAD TO USE IF IT WASNT FOR LAMBDA FUNCTION
In [15]:
from sklearn.linear_model import LogisticRegression
In [16]:
lm = LogisticRegression()
In [28]:
x = np.asarray(df[['Exposure_high']])
y = np.asarray(df['Mort_high'])
In [29]:
lm = lm.fit(x,y)
In [30]:
lm.predict([50])
Out[30]: