-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMultiple_Disease_Prediction.py
572 lines (476 loc) · 29 KB
/
Multiple_Disease_Prediction.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 27 16:25:58 2024
@author: prachet
"""
import pickle
import streamlit as st
from streamlit_option_menu import option_menu
import json
import pandas as pd
#loading the saved model of diabetes prediction
with open("Preprocessing Files/ML-Project-2-Diabetes_Prediction_Pre_Processing_Files/columns.pkl", 'rb') as f:
all_features_diabetes_disease = pickle.load(f)
with open("Preprocessing Files/ML-Project-2-Diabetes_Prediction_Pre_Processing_Files/scaler.pkl", 'rb') as f:
scalers_diabetes_disease = pickle.load(f)
with open("Best Features/ML-Project-2-Diabetes_Prediction_Best_Features/best_features_svc.json", 'r') as file:
best_features_svc_diabetes_disease = json.load(file)
with open("Best Features/ML-Project-2-Diabetes_Prediction_Best_Features/best_features_lr.json", 'r') as file:
best_features_lr_diabetes_disease = json.load(file)
with open("Best Features/ML-Project-2-Diabetes_Prediction_Best_Features/best_features_rfc.json", 'r') as file:
best_features_rfc_diabetes_disease = json.load(file)
with open("Models/ML-Project-2-Diabetes_Prediction_Models/diabetes_disease_trained_svc_model.sav", 'rb') as f:
loaded_model_svc_diabetes_disease = pickle.load(f)
with open("Models/ML-Project-2-Diabetes_Prediction_Models/diabetes_disease_trained_lr_model.sav", 'rb') as f:
loaded_model_lr_diabetes_disease = pickle.load(f)
with open("Models/ML-Project-2-Diabetes_Prediction_Models/diabetes_disease_trained_rfc_model.sav", 'rb') as f:
loaded_model_rfc_diabetes_disease = pickle.load(f)
#loading the saved model of heart disease prediction
with open("Preprocessing Files/ML-Project-9-Heart_Disease_Prediction_Pre_Processing_Files/columns.pkl", 'rb') as f:
all_columns_heart_disease = pickle.load(f)
with open("Preprocessing Files/ML-Project-9-Heart_Disease_Prediction_Pre_Processing_Files/cat_columns.pkl", 'rb') as f:
cat_columns_heart_disease = pickle.load(f)
with open("Preprocessing Files/ML-Project-9-Heart_Disease_Prediction_Pre_Processing_Files/encoder.pkl", 'rb') as f:
encoder_heart_disease = pickle.load(f)
with open("Preprocessing Files/ML-Project-9-Heart_Disease_Prediction_Pre_Processing_Files/encoded_columns.pkl", 'rb') as f:
encoded_columns_heart_disease = pickle.load(f)
with open("Preprocessing Files/ML-Project-9-Heart_Disease_Prediction_Pre_Processing_Files/training_columns.pkl", 'rb') as f:
training_columns_heart_disease = pickle.load(f)
with open("Preprocessing Files/ML-Project-9-Heart_Disease_Prediction_Pre_Processing_Files/scaler.pkl", 'rb') as f:
scaler_heart_disease = pickle.load(f)
with open("Best Features/ML-Project-9-Heart_Disease_Prediction_Best_Features/best_features_xgb.json", 'r') as file:
best_features_xgb_heart_disease = json.load(file)
with open("Best Features/ML-Project-9-Heart_Disease_Prediction_Best_Features/best_features_rfc.json", 'r') as file:
best_features_rfc_heart_disease = json.load(file)
with open("Best Features/ML-Project-9-Heart_Disease_Prediction_Best_Features/best_features_lr.json", 'r') as file:
best_features_lr_heart_disease = json.load(file)
with open("Models/ML-Project-9-Heart_Disease_Prediction_Models/heart_disease_trained_xgb_model.sav", 'rb') as f:
loaded_model_xgb_heart_disease = pickle.load(f)
with open("Models/ML-Project-9-Heart_Disease_Prediction_Models/heart_disease_trained_rfc_model.sav", 'rb') as f:
loaded_model_rfc_heart_disease = pickle.load(f)
with open("Models/ML-Project-9-Heart_Disease_Prediction_Models/heart_disease_trained_lr_model.sav", 'rb') as f:
loaded_model_lr_heart_disease = pickle.load(f)
#loading the saved model of parkinson disease
with open("Preprocessing Files/ML-Project-14-Parkinson's_Disease_Prediction_Pre_Processing_Files/columns.pkl", 'rb') as f:
all_features_parkinson_disease = pickle.load(f)
with open("Preprocessing Files/ML-Project-14-Parkinson's_Disease_Prediction_Pre_Processing_Files/scaler.pkl", 'rb') as f:
scalers_parkinson_disease = pickle.load(f)
with open("Best Features/ML-Project-14-Parkinson's_Disease_Prediction_Best_Features/best_features_knn.json", 'r') as file:
best_features_knn_parkinson_disease = json.load(file)
with open("Best Features/ML-Project-14-Parkinson's_Disease_Prediction_Best_Features/best_features_xgb.json", 'r') as file:
best_features_xgb_parkinson_disease = json.load(file)
with open("Best Features/ML-Project-14-Parkinson's_Disease_Prediction_Best_Features/best_features_rfc.json", 'r') as file:
best_features_rfc_parkinson_disease = json.load(file)
with open("Models/ML-Project-14-Parkinson's_Disease_Prediction_Models/parkinsons_disease_trained_knn_model.sav", 'rb') as f:
loaded_model_knn_parkinson_disease = pickle.load(f)
with open("Models/ML-Project-14-Parkinson's_Disease_Prediction_Models/parkinsons_disease_trained_xgb_model.sav", 'rb') as f:
loaded_model_xgb_parkinson_disease = pickle.load(f)
with open("Models/ML-Project-14-Parkinson's_Disease_Prediction_Models/parkinsons_disease_trained_rfc_model.sav", 'rb') as f:
loaded_model_rfc_parkinson_disease = pickle.load(f)
#loading the saved model of breast cancer
with open("Preprocessing Files/ML-Project-19-Breast_Cancer_Classification_Pre_Processing_Files/columns.pkl", 'rb') as f:
all_features_breast_cancer = pickle.load(f)
with open("Preprocessing Files/ML-Project-19-Breast_Cancer_Classification_Pre_Processing_Files/scaler.pkl", 'rb') as f:
scalers_breast_cancer = pickle.load(f)
with open("Best Features/ML-Project-19-Breast_Cancer_Classification_Best_Features/best_features_lr.json", 'r') as file:
best_features_lr_breast_cancer = json.load(file)
with open("Best Features/ML-Project-19-Breast_Cancer_Classification_Best_Features/best_features_xgb.json", 'r') as file:
best_features_xgb_breast_cancer = json.load(file)
with open("Best Features/ML-Project-19-Breast_Cancer_Classification_Best_Features/best_features_knn.json", 'r') as file:
best_features_knn_breast_cancer = json.load(file)
with open("Models/ML-Project-19-Breast_Cancer_Classification_Models/parkinsons_disease_trained_lr_model.sav", 'rb') as f:
loaded_model_lr_breast_cancer = pickle.load(f)
with open("Models/ML-Project-19-Breast_Cancer_Classification_Models/parkinsons_disease_trained_xgb_model.sav", 'rb') as f:
loaded_model_xgb_breast_cancer = pickle.load(f)
with open("Models/ML-Project-19-Breast_Cancer_Classification_Models/parkinsons_disease_trained_knn_model.sav", 'rb') as f:
loaded_model_knn_breast_cancer = pickle.load(f)
def diabetes_prediction(input_data):
df_diabetes_disease = pd.DataFrame([input_data], columns=all_features_diabetes_disease)
df_diabetes_disease[all_features_diabetes_disease] = scalers_diabetes_disease.transform(df_diabetes_disease[all_features_diabetes_disease])
df_best_features_svc_diabetes_disease = df_diabetes_disease[best_features_svc_diabetes_disease]
df_best_features_lr_diabetes_disease = df_diabetes_disease[best_features_lr_diabetes_disease]
df_best_features_rfc_diabetes_disease = df_diabetes_disease[best_features_rfc_diabetes_disease]
prediction1_diabetes_disease = loaded_model_svc_diabetes_disease.predict(df_best_features_svc_diabetes_disease)
prediction2_diabetes_disease = loaded_model_lr_diabetes_disease.predict(df_best_features_lr_diabetes_disease)
prediction3_diabetes_disease = loaded_model_rfc_diabetes_disease.predict(df_best_features_rfc_diabetes_disease)
return prediction1_diabetes_disease , prediction2_diabetes_disease, prediction3_diabetes_disease
def heart_disease_prediction(input_data):
columns_heart_disease = all_columns_heart_disease
df_heart_disease = pd.DataFrame([input_data], columns=columns_heart_disease)
df_heart_disease[cat_columns_heart_disease] = df_heart_disease[cat_columns_heart_disease].astype('str')
input_data_encoded_heart_disease = encoder_heart_disease.transform(df_heart_disease[cat_columns_heart_disease])
input_data_encoded_df_heart_disease = pd.DataFrame(input_data_encoded_heart_disease, columns=encoded_columns_heart_disease)
input_data_final_encoded_heart_disease = pd.concat([df_heart_disease.drop(cat_columns_heart_disease, axis=1).reset_index(drop=True), input_data_encoded_df_heart_disease], axis=1)
input_data_scaled_heart_disease = scaler_heart_disease.transform(input_data_final_encoded_heart_disease)
input_data_df_heart_disease = pd.DataFrame(input_data_scaled_heart_disease, columns=training_columns_heart_disease)
df_best_features_xgb_heart_disease = input_data_df_heart_disease[best_features_xgb_heart_disease]
df_best_features_rfc_heart_disease = input_data_df_heart_disease[best_features_rfc_heart_disease]
df_best_features_lr_heart_disease = input_data_df_heart_disease[best_features_lr_heart_disease]
prediction1_heart_disease = loaded_model_xgb_heart_disease.predict(df_best_features_xgb_heart_disease)
prediction2_heart_disease = loaded_model_rfc_heart_disease.predict(df_best_features_rfc_heart_disease)
prediction3_heart_disease = loaded_model_lr_heart_disease.predict(df_best_features_lr_heart_disease)
return prediction1_heart_disease , prediction2_heart_disease, prediction3_heart_disease
def parkinson_disease_prediction(input_data):
df_parkinson_disease = pd.DataFrame([input_data], columns=all_features_parkinson_disease)
df_parkinson_disease[all_features_parkinson_disease] = scalers_parkinson_disease.transform(df_parkinson_disease[all_features_parkinson_disease])
df_best_features_knn_parkinson_disease = df_parkinson_disease[best_features_knn_parkinson_disease]
df_best_features_xgb_parkinson_disease = df_parkinson_disease[best_features_xgb_parkinson_disease]
df_best_features_rfc_parkinson_disease = df_parkinson_disease[best_features_rfc_parkinson_disease]
prediction1_parkinson_disease = loaded_model_knn_parkinson_disease.predict(df_best_features_knn_parkinson_disease)
prediction2_parkinson_disease = loaded_model_xgb_parkinson_disease.predict(df_best_features_xgb_parkinson_disease)
prediction3_parkinson_disease = loaded_model_rfc_parkinson_disease.predict(df_best_features_rfc_parkinson_disease)
return prediction1_parkinson_disease , prediction2_parkinson_disease, prediction3_parkinson_disease
def breast_cancer_prediction(input_data):
df_breast_cancer = pd.DataFrame([input_data], columns=all_features_breast_cancer)
df_breast_cancer[all_features_breast_cancer] = scalers_breast_cancer.transform(df_breast_cancer[all_features_breast_cancer])
df_best_features_lr_breast_cancer = df_breast_cancer[best_features_lr_breast_cancer]
df_best_features_xgb_breast_cancer = df_breast_cancer[best_features_xgb_breast_cancer]
df_best_features_knn_breast_cancer = df_breast_cancer[best_features_knn_breast_cancer]
prediction1_breast_cancer = loaded_model_lr_breast_cancer.predict(df_best_features_lr_breast_cancer)
prediction2_breast_cancer = loaded_model_xgb_breast_cancer.predict(df_best_features_xgb_breast_cancer)
prediction3_breast_cancer = loaded_model_knn_breast_cancer.predict(df_best_features_knn_breast_cancer)
return prediction1_breast_cancer , prediction2_breast_cancer, prediction3_breast_cancer
def main():
# sidebar for navigate
with st.sidebar:
selected = option_menu('Multiple Disease Prediction System using ML',
['Diabetes Prediction',
'Heart Disease Prediction',
'Parkinson Disease Prediction',
'Breast Cancer Prediction'],
icons = ['capsule','activity','person','virus'],
default_index = 0)
# Diabetes Prediction Page
if( selected == 'Diabetes Prediction'):
#giving a title
st.title('Diabetes Prediction using ML')
#getting input data from user
Pregnancies = st.number_input("Number of Pregnancies",format="%.0f")
Glucose = st.number_input("Glucose Level",format="%.2f")
BloodPressure = st.number_input("BloodPressure volume",format="%.2f")
SkinThickness = st.number_input("SkinThickness value",format="%.2f")
Insulin = st.number_input("Insulin level",format="%.2f")
BMI = st.number_input("BMI value",format="%.2f")
DiabetesPedigreeFunction = st.number_input("DiabetesPedigreeFunction value",format="%.3f")
Age = st.number_input("Age of the person",format="%.0f")
# code for prediction
diabetes_diagnosis_svc = ''
diabetes_diagnosis_lr = ''
diabetes_diagnosis_rfc = ''
diabetes_diagnosis_svc,diabetes_diagnosis_lr,diabetes_diagnosis_rfc = diabetes_prediction([Pregnancies,Glucose,BloodPressure,SkinThickness,Insulin,BMI,DiabetesPedigreeFunction,Age])
#creating a button for Prediction
if st.button("Predict Diabetes"):
if(diabetes_diagnosis_rfc[0]==0):
prediction = 'The person is not diabetic'
else:
prediction = 'The person is diabetic'
st.write(f"Prediction: {prediction}")
if st.checkbox("Show Advanced Options"):
if st.button("Predict Diabetes with Random Forest Classifier"):
if(diabetes_diagnosis_rfc[0]==0):
prediction = 'The person is not diabetic'
else:
prediction = 'The person is diabetic'
st.write(f"Prediction: {prediction}")
if st.button("Predict Diabetes with Logistic Regression Model"):
if(diabetes_diagnosis_lr[0]==0):
prediction = 'The person is not diabetic'
else:
prediction = 'The person is diabetic'
st.write(f"Prediction: {prediction}")
if st.button("Predict Diabetes with Support Vector Classifier"):
if(diabetes_diagnosis_svc[0]==0):
prediction = 'The person is not diabetic'
else:
prediction = 'The person is diabetic'
st.write(f"Prediction: {prediction}")
# Heart Disease Prediction Page
if( selected == 'Heart Disease Prediction'):
#giving a title
st.title('Heart Disease Prediction using ML')
#getting input data from user
col1 , col2 , col3 = st.columns(3)
with col1:
age = st.number_input("Age in years",format="%.0f")
with col2:
option1 = st.selectbox('Gender',('Male', 'Female'))
sex = 0 if option1 == 'Female' else 1
with col3:
option2 = st.selectbox('Chest Pain type',('0','1','2','3'))
if option2 == '0':
chest_pain = 0
elif option2 == '1':
chest_pain = 1
elif option2 == '2':
chest_pain = 2
else:
chest_pain = 3
with col1:
resting_bp = st.number_input("Resting Blood Pressure (in mm Hg)")
with col2:
serum_cholestoral = st.number_input("Serum Cholestoral in mg/dl")
with col3:
option3 = st.selectbox('Fasting Blood Sugar',('True', 'False'))
fasting_blood_sugar = 0 if option3 == 'False' else 1
with col1:
option4 = st.selectbox('Resting ECG Results',('0','1','2','3'))
if option4 == '0':
resting_ecg = 0
elif option4 == '1':
resting_ecg = 1
elif option4 == '2':
resting_ecg = 2
with col2:
max_heart_achieved = st.number_input("Maximum Heart Rate Achieved")
with col3:
option5 = st.selectbox('Exercise Induced Angina',('Yes', 'No'))
exercise_induced_angina = 0 if option5 == 'No' else 1
with col1:
oldpeak = st.number_input("Oldpeak (ST depression induced by exercise relative to rest)")
with col2:
option6 = st.selectbox('The slope of the peak exercise ST segment',('0','1','2'))
if option6 == '0':
slope_of_peak_exercise = 0
elif option6 == '1':
slope_of_peak_exercise = 1
elif option6 == '2':
slope_of_peak_exercise = 2
with col3:
option7 = st.selectbox('The slope of the peak exercise ST segment',('0','1','2','3','4'))
if option7 == '0':
number_of_major_vessels = 0
elif option7 == '1':
number_of_major_vessels = 1
elif option7 == '2':
number_of_major_vessels = 2
elif option7 == '3':
number_of_major_vessels = 3
else:
number_of_major_vessels = 4
with col1:
option7 = st.selectbox('Thal',('None','Normal','Fixed defect','Reversable defect'))
if option7 == 'None':
thal = 0
elif option7 == 'Normal':
thal = 1
elif option7 == 'Fixed defect':
thal = 2
elif option7 == 'Reversable defect':
thal = 3
# code for prediction
heart_disease_diagnosis_xgb = ''
heart_disease_diagnosis_rfc = ''
heart_disease_diagnosis_lr = ''
heart_disease_diagnosis_xgb,heart_disease_diagnosis_rfc,heart_disease_diagnosis_lr =heart_disease_prediction([age,sex,chest_pain,
resting_bp,serum_cholestoral,fasting_blood_sugar,
resting_ecg,max_heart_achieved,exercise_induced_angina,
oldpeak,slope_of_peak_exercise,
number_of_major_vessels,thal])
#creating a button for Prediction
if st.button("Predict Heart Disease"):
if(heart_disease_diagnosis_xgb[0]==0):
prediction = 'The Person does not have any Heart Disease'
else:
prediction = 'The Person have any Heart Disease'
st.write(f"Prediction: {prediction}")
if st.checkbox("Show Advanced Options"):
if st.button("Predict Heart Disease with XG Boost Classifier"):
if(heart_disease_diagnosis_xgb[0]==0):
prediction = 'The Person does not have any Heart Disease'
else:
prediction = 'The Person have any Heart Disease'
st.write(f"Prediction: {prediction}")
if st.button("Predict Heart Disease with Random Forest Classifier"):
if(heart_disease_diagnosis_rfc[0]==0):
prediction = 'The Person does not have any Heart Disease'
else:
prediction = 'The Person have any Heart Disease'
st.write(f"Prediction: {prediction}")
if st.button("Predict Heart Disease with Logistics Regression"):
if(heart_disease_diagnosis_lr[0]==0):
prediction = 'The Person does not have any Heart Disease'
else:
prediction = 'The Person have any Heart Disease'
st.write(f"Prediction: {prediction}")
# Parkinson Disease Prediction Page
if( selected == 'Parkinson Disease Prediction'):
#page title
st.title('Parkinson Disease Prediction using ML')
col1 , col2 , col3 = st.columns(3)
with col1:
Fo = st.number_input("MDVP_Fo(Hz)",format="%.6f")
with col2:
Fhi = st.number_input("MDVP_Fhi(Hz)",format="%.6f")
with col3:
Flo = st.number_input("MDVP_Flo(Hz)",format="%.6f")
with col1:
Jitter_per = st.number_input("MDVP_Jitter(%)",format="%.6f")
with col2:
Jitter_Abs = st.number_input("MDVP_Jitter(Abs)",format="%.6f")
with col3:
RAP = st.number_input("MDVP_RAP",format="%.6f")
with col1:
PPQ = st.number_input("MDVP_PPQ",format="%.6f")
with col2:
Jitter_DDP = st.number_input("Jitter_DDP",format="%.6f")
with col3:
Shimmer = st.number_input("MDVP_Shimmer",format="%.6f")
with col1:
Shimmer_dB = st.number_input("MDVP_Shimmer(dB)",format="%.6f")
with col2:
Shimmer_APQ3 = st.number_input("Shimmer_APQ3",format="%.6f")
with col3:
Shimmer_APQ5 = st.number_input("Shimmer_APQ5",format="%.6f")
with col1:
APQ = st.number_input("MDVP_APQ",format="%.6f")
with col2:
Shimmer_DDA = st.number_input("Shimmer_DDA",format="%.6f")
with col3:
NHR = st.number_input("NHR",format="%.6f")
with col1:
HNR = st.number_input("HNR",format="%.6f")
with col2:
RPDE = st.number_input("RPDE",format="%.6f")
with col3:
DFA = st.number_input("DFA",format="%.6f")
with col1:
spread1 = st.number_input("spread1",format="%.6f")
with col2:
spread2 = st.number_input("spread2",format="%.6f")
with col3:
D2 = st.number_input("D2",format="%.6f")
with col1:
PPE = st.number_input("PPE",format="%.6f")
# code for prediction
parkinson_isease_diagnosis_knn = ''
parkinson_isease_diagnosis_xgb = ''
parkinson_isease_diagnosis_rfc = ''
parkinson_isease_diagnosis_knn,parkinson_isease_diagnosis_xgb,parkinson_isease_diagnosis_rfc = parkinson_disease_prediction([Fo,Fhi,Flo,Jitter_per,Jitter_Abs,RAP,PPQ,Jitter_DDP,Shimmer,Shimmer_dB,Shimmer_APQ3,Shimmer_APQ5,APQ,Shimmer_DDA,NHR,HNR,RPDE,DFA,spread1,spread2,D2,PPE])
#creating a button for Prediction
if st.button("Predict Parkinson Disease"):
if(parkinson_isease_diagnosis_knn[0]==0):
prediction = 'The Person does not have Parkinson Disease'
else:
prediction = 'The Person have Parkinson Disease'
st.write(f"Prediction: {prediction}")
if st.checkbox("Show Advanced Options"):
if st.button("Predict Breast Cancer with K Neighbors Classifier"):
if(parkinson_isease_diagnosis_knn[0]==0):
prediction = 'The Person does not have Parkinson Disease'
else:
prediction = 'The Person have Parkinson Disease'
st.write(f"Prediction: {prediction}")
if st.button("Predict Breast Cancer with Random Forest Classifier"):
if(parkinson_isease_diagnosis_rfc[0]==0):
prediction = 'The Person does not have Parkinson Disease'
else:
prediction = 'The Person have Parkinson Disease'
st.write(f"Prediction: {prediction}")
if st.button("Predict Breast Cancer with XG Boost Classifier"):
if(parkinson_isease_diagnosis_xgb[0]==0):
prediction = 'The Person does not have Parkinson Disease'
else:
prediction = 'The Person have Parkinson Disease'
st.write(f"Prediction: {prediction}")
# Breast Cancer Prediction Page
if( selected == 'Breast Cancer Prediction'):
#page title
st.title('Breast Cancer Prediction using ML')
col1 , col2 , col3 = st.columns(3)
with col1:
mean_radius = st.number_input("mean radius",format="%.6f")
with col2:
mean_texture = st.number_input("mean texture",format="%.6f")
with col3:
mean_perimeter = st.number_input("mean_perimeter",format="%.6f")
with col1:
mean_area = st.number_input("mean_area",format="%.6f")
with col2:
mean_smoothness = st.number_input("mean_smoothness",format="%.6f")
with col3:
mean_compactness = st.number_input("mean_compactness",format="%.6f")
with col1:
mean_concavity = st.number_input("mean_concavity",format="%.6f")
with col2:
mean_concave_points = st.number_input("mean_concavepoints",format="%.6f")
with col3:
mean_symmetry = st.number_input("mean_symmetry",format="%.6f")
with col1:
mean_fractal_dimension = st.number_input("mean_fractal_dim",format="%.6f")
with col2:
radius_error = st.number_input("radius_error",format="%.6f")
with col3:
texture_error = st.number_input("texture_error",format="%.6f")
with col1:
perimeter_error = st.number_input("perimeter_error",format="%.6f")
with col2:
area_error = st.number_input("area_error",format="%.6f")
with col3:
smoothness_error = st.number_input("smoothness_error",format="%.6f")
with col1:
compactness_error = st.number_input("compactness_error",format="%.6f")
with col2:
concavity_error = st.number_input("concavity_error",format="%.6f")
with col3:
concave_points_error = st.number_input("concave_points_error",format="%.6f")
with col1:
symmetry_error = st.number_input("symmetry_error",format="%.6f")
with col2:
fractal_dimension_error = st.number_input("fractal_dim_error",format="%.6f")
with col3:
worst_radius = st.number_input("worst_radius",format="%.6f")
with col1:
worst_texture = st.number_input("worst_texture",format="%.6f")
with col2:
worst_perimeter = st.number_input("worst_perimeter",format="%.6f")
with col3:
worst_area = st.number_input("worst_area",format="%.6f")
with col1:
worst_smoothness = st.number_input("worst_smoothness",format="%.6f")
with col2:
worst_compactness = st.number_input("worst_compactness",format="%.6f")
with col3:
worst_concavity = st.number_input("worst_concavity",format="%.6f")
with col1:
worst_concave_points = st.number_input("worst_concavepoints",format="%.6f")
with col2:
worst_symmetry = st.number_input("worst_symmetry",format="%.6f")
with col3:
worst_fractal_dimension = st.number_input("worst_fractal_dim",format="%.6f")
# code for prediction
breast_cancer_diagnosis_lr = ''
breast_cancer_diagnosis_knn = ''
breast_cancer_diagnosis_xgb = ''
breast_cancer_diagnosis_lr,breast_cancer_diagnosis_knn,breast_cancer_diagnosis_xgb = breast_cancer_prediction([mean_radius,mean_texture,mean_perimeter,
mean_area,mean_smoothness,mean_compactness,
mean_concavity,mean_concave_points,mean_symmetry,
mean_fractal_dimension,radius_error,
texture_error,perimeter_error,area_error,smoothness_error,compactness_error,concavity_error,concave_points_error,symmetry_error,fractal_dimension_error,worst_radius,worst_texture,worst_perimeter,worst_area,worst_smoothness,worst_compactness,worst_concavity,worst_concave_points,worst_symmetry,worst_fractal_dimension])
#creating a button for Prediction
if st.button("Predict Breast Cancer"):
if(breast_cancer_diagnosis_xgb[0]==0):
prediction = 'The Breast Cancer is Malignant'
else:
prediction = 'The Breast Cancer is Benign'
st.write(f"Prediction: {prediction}")
if st.checkbox("Show Advanced Options"):
if st.button("Predict Breast Cancer with XG Boost Classifier"):
if(breast_cancer_diagnosis_xgb[0]==0):
prediction = 'The Breast Cancer is Malignant'
else:
prediction = 'The Breast Cancer is Benign'
st.write(f"Prediction: {prediction}")
if st.button("Predict Breast Cancer with Logistic Regression Model"):
if(breast_cancer_diagnosis_lr[0]==0):
prediction = 'The Breast Cancer is Malignant'
else:
prediction = 'The Breast Cancer is Benign'
st.write(f"Prediction: {prediction}")
if st.button("Predict Breast Cancer with K Neighbors Classifier"):
if(breast_cancer_diagnosis_knn[0]==0):
prediction = 'The Breast Cancer is Malignant'
else:
prediction = 'The Breast Cancer is Benign'
st.write(f"Prediction: {prediction}")
if __name__ == '__main__':
main()