You are on page 1of 3

import pandas as pd

import matplotlib.pyplot as plt


from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
from sklearn.svm import SVC
from sklearn import tree
from sklearn.naive_bayes import GaussianNB
In [ ]:

In [5]:
df=pd.read_csv(r"C:\Users\SRINIVASULU\Downloads\kindey stone urine analysis.csv")
df.head()
Out[5]:
gravity ph osmo cond urea calc target

0 1.021 4.91 725 14.0 443 2.45 0

1 1.017 5.74 577 20.0 296 4.49 0

2 1.008 7.20 321 14.9 101 2.36 0

3 1.011 5.51 408 12.6 224 2.15 0

4 1.005 6.52 187 7.5 91 1.16 0

In [27]:
f=df.drop('target',axis=1)
t=df.target
In [49]:
(F_train,F_test)=train_test_split(f,test_size=0.3,random_state=1)
(T_train,T_test)=train_test_split(t,test_size=0.3,random_state=1)
In [32]:
F_train.shape
Out[32]:
(63, 6)
In [33]:
F_test.shape
Out[33]:
(16, 6)
In [34]:
T_train.shape
Out[34]:
(63,)
In [35]:
T_test.shape
Out[35]:
(16,)
In [13]:
df1=df[df.target==0]
df1.head(5)
Out[13]:
gravity ph osmo cond urea calc target

0 1.021 4.91 725 14.0 443 2.45 0

1 1.017 5.74 577 20.0 296 4.49 0

2 1.008 7.20 321 14.9 101 2.36 0

3 1.011 5.51 408 12.6 224 2.15 0

4 1.005 6.52 187 7.5 91 1.16 0

In [14]:
df2=df[df.target==1]
df2.head()
Out[14]:
gravity ph osmo cond urea calc target

45 1.021 5.94 774 27.9 325 6.96 1

46 1.024 5.77 698 19.5 354 13.00 1

47 1.024 5.60 866 29.5 360 5.54 1

48 1.021 5.53 775 31.2 302 6.19 1

49 1.024 5.36 853 27.6 364 7.31 1

In [25]:
df3=df.drop('target',axis=1)
df4=df.drop('target',axis=1)
In [21]:
%matplotlib inline
plt.scatter(df1[''],df1['calc'],marker='*',color='green')
plt.scatter(df2['osmo'],df2['calc'],marker='*',color='blue')
Out[21]:
<matplotlib.collections.PathCollection at 0x1c1f5e77880>
In [50]:
model=SVC()
model.fit(F_train,T_train)
model.score(F_test,T_test)
Out[50]:
0.5
In [51]:
model=tree.DecisionTreeClassifier()
model.fit(F_train,T_train)
model.score(F_test,T_test)
Out[51]:
0.6666666666666666
In [52]:
model= GaussianNB()
model.fit(F_train,T_train)
model.score(F_test,T_test)
Out[52]:
0.8333333333333334

You might also like