Meaningful Predictive Modeling Week-4 Assignment Cancer Disease Prediction
Meaningful Predictive Modeling Week-4 Assignment Cancer Disease Prediction
In [16]:
In [17]:
dataset.head()
Out[17]:
842302 M 17.99 10.38 122.8 1001 0.1184 0.2776 0.3001 0.1471 ... 25.38
0 842517 M 20.57 17.77 132.90 1326.0 0.08474 0.07864 0.0869 0.07017 ... 24.99 2
1 84300903 M 19.69 21.25 130.00 1203.0 0.10960 0.15990 0.1974 0.12790 ... 23.57 2
2 84348301 M 11.42 20.38 77.58 386.1 0.14250 0.28390 0.2414 0.10520 ... 14.91 2
3 84358402 M 20.29 14.34 135.10 1297.0 0.10030 0.13280 0.1980 0.10430 ... 22.54
4 843786 M 12.45 15.70 82.57 477.1 0.12780 0.17000 0.1578 0.08089 ... 15.47 2
5 rows × 32 columns
In [18]:
localhost:8888/nbconvert/html/Desktop/Cancer.ipynb?download=false 1/6
10/8/2020 Cancer
In [19]:
dataset.isnull().sum()
dataset.isna().sum()
Out[19]:
842302 0
M 0
17.99 0
10.38 0
122.8 0
1001 0
0.1184 0
0.2776 0
0.3001 0
0.1471 0
0.2419 0
0.07871 0
1.095 0
0.9053 0
8.589 0
153.4 0
0.006399 0
0.04904 0
0.05373 0
0.01587 0
0.03003 0
0.006193 0
25.38 0
17.33 0
184.6 0
2019 0
0.1622 0
0.6656 0
0.7119 0
0.2654 0
0.4601 0
0.1189 0
dtype: int64
In [20]:
In [21]:
# Splitting the dataset into the Training set and Test set
from sklearn.model_selection import train_test_split
X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size = 0.25, random_stat
e = 0)
localhost:8888/nbconvert/html/Desktop/Cancer.ipynb?download=false 2/6
10/8/2020 Cancer
In [22]:
#Feature Scaling
from sklearn.preprocessing import StandardScaler
sc = StandardScaler()
X_train = sc.fit_transform(X_train)
X_test = sc.transform(X_test)
localhost:8888/nbconvert/html/Desktop/Cancer.ipynb?download=false 3/6
10/8/2020 Cancer
In [24]:
C:\Users\ROHINI\Anaconda3\lib\site-packages\sklearn\linear_model\logistic.
py:432: FutureWarning: Default solver will be changed to 'lbfgs' in 0.22.
Specify a solver to silence this warning.
FutureWarning)
Out[24]:
localhost:8888/nbconvert/html/Desktop/Cancer.ipynb?download=false 4/6
10/8/2020 Cancer
In [29]:
Y_pred1 = classifier1.predict(X_test)
Y_pred2 = classifier2.predict(X_test)
Y_pred3 = classifier3.predict(X_test)
Y_pred4 = classifier4.predict(X_test)
Y_pred5 = classifier5.predict(X_test)
Y_pred6 = classifier6.predict(X_test)
Y_pred7 = classifier7.predict(X_test)
In [30]:
[[91 1]
[ 2 48]]
[[91 1]
[ 6 44]]
[[90 2]
[ 4 46]]
[[92 0]
[ 6 44]]
[[89 3]
[ 6 44]]
[[84 8]
[ 6 44]]
[[89 3]
[ 6 44]]
localhost:8888/nbconvert/html/Desktop/Cancer.ipynb?download=false 5/6
10/8/2020 Cancer
In [34]:
LogR 97.88732394366197
KNN 95.07042253521126
SVM 95.77464788732394
K-SVM 95.77464788732394
NB 93.66197183098592
DT 90.14084507042254
RF 93.66197183098592
In [38]:
import numpy as np
import pandas as pd
from pandas import Series, DataFrame
import matplotlib.pyplot as plt
localhost:8888/nbconvert/html/Desktop/Cancer.ipynb?download=false 6/6