[6b894f]: / Web / code.txt

Download this file

253 lines (189 with data), 9.0 kB

  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
import tkinter as tk
from tkinter import Message ,Text
from PIL import Image, ImageTk
import pandas as pd
from tkinter import *
import tkinter.ttk as ttk
import tkinter.font as font
import tkinter.messagebox as tm
import matplotlib.pyplot as plt
import csv
import numpy as np
from PIL import Image, ImageTk
from tkinter import filedialog
import tkinter.messagebox as tm
import DTALG as DT
import LogisticRegression as LR
import svmalgo as svm
import XGboostalgo as xgbalgo
import RandomForest as RF
import Predict as pred
bgcolor="#DAF7A6"
bgcolor1="#B7C526"
fgcolor="black"
def Home():
global window
def clear():
print("Clear1")
txt1.delete(0, 'end')
txt2.delete(0, 'end')
txt3.delete(0, 'end')
txt4.delete(0, 'end')
txt5.delete(0, 'end')
txt6.delete(0, 'end')
txt7.delete(0, 'end')
txt8.delete(0, 'end')
txt9.delete(0, 'end')
txt10.delete(0, 'end')
window = tk.Tk()
window.title("Heart Disease Prediction")
window.geometry('1280x720')
window.configure(background=bgcolor)
#window.attributes('-fullscreen', True)
window.grid_rowconfigure(0, weight=1)
window.grid_columnconfigure(0, weight=1)
message1 = tk.Label(window, text="Early Detection of Cardiac Arrest in Newborn Babies" ,bg=bgcolor ,fg=fgcolor ,width=50 ,height=2,font=('times', 30, 'italic bold underline'))
message1.place(x=100, y=1)
lbl1 = tk.Label(window, text="Enter Age in months",width=20 ,height=2 ,fg=fgcolor ,bg=bgcolor ,font=('times', 15, ' bold ') )
lbl1.place(x=50, y=100)
txt1 = tk.Entry(window,width=20,bg="white" ,fg="black",font=('times', 15, ' bold '))
txt1.place(x=300, y=115)
lbl2 = tk.Label(window, text="Weight",width=20 ,height=2 ,fg=fgcolor ,bg=bgcolor ,font=('times', 15, ' bold ') )
lbl2.place(x=50, y=170)
txt2 = tk.Entry(window,width=20,bg="white" ,fg="black",font=('times', 15, ' bold '))
txt2.place(x=300, y=175)
lbl3 = tk.Label(window, text="Height ",width=20 ,height=2 ,fg=fgcolor ,bg=bgcolor ,font=('times', 15, ' bold ') )
lbl3.place(x=50, y=230)
txt3 = tk.Entry(window,width=20,bg="white" ,fg="black",font=('times', 15, ' bold '))
txt3.place(x=300, y=235)
lbl4 = tk.Label(window, text="Gender",width=20 ,height=2 ,fg=fgcolor ,bg=bgcolor ,font=('times', 15, ' bold ') )
lbl4.place(x=50, y=285)
txt4 = tk.Entry(window,width=20,bg="white" ,fg="black",font=('times', 15, ' bold '))
txt4.place(x=300, y=290)
lbl5 = tk.Label(window, text="Heart Rate ",width=20 ,height=2 ,fg=fgcolor ,bg=bgcolor ,font=('times', 15, ' bold ') )
lbl5.place(x=50, y=350)
txt5 = tk.Entry(window,width=20,bg="white" ,fg="black",font=('times', 15, ' bold '))
txt5.place(x=300, y=365)
lbl6 = tk.Label(window, text="Oxygen Saturation ",width=20 ,height=2 ,fg=fgcolor ,bg=bgcolor ,font=('times', 15, ' bold ') )
lbl6.place(x=50, y=420)
txt6 = tk.Entry(window,width=20,bg="white" ,fg="black",font=('times', 15, ' bold '))
txt6.place(x=300, y=435)
lbl7 = tk.Label(window, text="Respiratory Rate",width=20 ,height=2 ,fg=fgcolor ,bg=bgcolor ,font=('times', 15, ' bold ') )
lbl7.place(x=550, y=100)
txt7 = tk.Entry(window,width=20,bg="white" ,fg="black",font=('times', 15, ' bold '))
txt7.place(x=800, y=115)
lbl8 = tk.Label(window, text="Systolic Blood Pressure",width=20 ,height=2 ,fg=fgcolor ,bg=bgcolor ,font=('times', 15, ' bold ') )
lbl8.place(x=550, y=170)
txt8 = tk.Entry(window,width=20,bg="white" ,fg="black",font=('times', 15, ' bold '))
txt8.place(x=800, y=175)
lbl9 = tk.Label(window, text="Diastolic Blood Pressure ",width=20 ,height=2 ,fg=fgcolor ,bg=bgcolor ,font=('times', 15, ' bold ') )
lbl9.place(x=550, y=230)
txt9 = tk.Entry(window,width=20,bg="white" ,fg="black",font=('times', 15, ' bold '))
txt9.place(x=800, y=235)
lbl10 = tk.Label(window, text="Mean Blood Pressure",width=20 ,height=2 ,fg=fgcolor ,bg=bgcolor ,font=('times', 15, ' bold ') )
lbl10.place(x=550, y=285)
txt10 = tk.Entry(window,width=20,bg="white" ,fg="black",font=('times', 15, ' bold '))
txt10.place(x=800, y=290)
def LRprocess():
sym="Child_Heart_Stage_dataset.csv"
if sym != "":
LR.process(sym)
tm.showinfo("Input", "Logistic Regression Successfully Finished")
else:
tm.showinfo("Input error", "Select Dataset File")
def RFprocess():
sym="Child_Heart_Stage_dataset.csv"
if sym != "":
RF.process(sym)
tm.showinfo("Input", "Random Forest Successfully Finished")
else:
tm.showinfo("Input error", "Select Dataset File")
def DTProcess():
sym="Child_Heart_Stage_dataset.csv"
if sym != "":
DT.process(sym)
tm.showinfo("Input", "Decision Tree Successfully Finished")
else:
tm.showinfo("Input error", "Select Dataset File")
def svmprocess():
sym="Child_Heart_Stage_dataset.csv"
if sym != "":
svm.process(sym)
tm.showinfo("Input", "SVM Finished Success")
else:
tm.showinfo("Input error", "Select Dataset File")
def xgbProcess():
sym="Child_Heart_Stage_dataset.csv"
if sym != "":
xgbalgo.process(sym)
tm.showinfo("Input", "XgBoost Finished Success")
else:
tm.showinfo("Input error", "Select Dataset File")
def Predictprocess():
sym="Child_Heart_Stage_dataset.csv"
a1=txt1.get()
a2=txt2.get()
a3=txt3.get()
a4=txt4.get()
if a4=="male":
a4=1
else:
a4=0
a5=txt5.get()
a6=txt6.get()
a7=txt7.get()
a8=txt8.get()
a9=txt9.get()
a10=txt10.get()
if a1 == "":
tm.showinfo("Insert error", "Enter Age")
elif a2 == "":
tm.showinfo("Insert error", "Enter Weight")
elif a3 == "":
tm.showinfo("Insert error", "Enter Height")
elif a4 == "":
tm.showinfo("Insert error", "Enter Gender")
elif a5 == "":
tm.showinfo("Insert error", "Enter Heart Rate")
elif a6 == "":
tm.showinfo("Insert error", "Enter oxygen saturation")
elif a7 == "":
tm.showinfo("Insert error", "Enter Respiratory Rate")
elif a8 == "":
tm.showinfo("Insert error", "Enter Systolic Blood Pressure")
elif a9 == "":
tm.showinfo("Insert error", "Enter Diastolic Blood Pressure")
elif a10=="":
tm.showinfo("Insert error", "Enter Mean Blood Pressure")
else:
print("a1==",a1)
print("a2==",a2)
print("a3==",a3)
print("a4==",a4)
print("a5==",a5)
print("a6==",a6)
print("a7==",a7)
print("a8==",a8)
print("a9==",a9)
print("a10==",a10)
res,treat = pred.process(sym,float(a1),float(a2),float(a3),float(a4),float(a5),float(a6),float(a7),float(a8),float(a9),float(a10))
print(res)
if res!="":
tm.showinfo("Result", str(res))
tm.showinfo("Recommended Treatment", str(treat))
else:
tm.showinfo("Input error", "Select Dataset File")
clearButton = tk.Button(window, text="Clear", command=clear ,fg=fgcolor ,bg=bgcolor1 ,width=14 ,height=2 ,activebackground = "Red" ,font=('times', 15, ' bold '))
clearButton.place(x=10, y=500)
proc = tk.Button(window, text="Random Forest", command=RFprocess ,fg=fgcolor ,bg=bgcolor1 ,width=14 ,height=2, activebackground = "Red" ,font=('times', 15, ' bold '))
proc.place(x=210, y=500)
LRbutton = tk.Button(window, text="SVM", command=svmprocess ,fg=fgcolor ,bg=bgcolor1 ,width=14 ,height=2, activebackground = "Red" ,font=('times', 15, ' bold '))
LRbutton.place(x=410, y=500)
RFbutton = tk.Button(window, text="XG Boost", command=xgbProcess ,fg=fgcolor ,bg=bgcolor1 ,width=14 ,height=2, activebackground = "Red" ,font=('times', 15, ' bold '))
RFbutton.place(x=610, y=500)
PRbutton = tk.Button(window, text="Predict", command=Predictprocess ,fg=fgcolor ,bg=bgcolor1 ,width=14 ,height=2, activebackground = "Red" ,font=('times', 15, ' bold '))
PRbutton.place(x=810, y=500)
quitWindow = tk.Button(window, text="Quit", command=window.destroy ,fg=fgcolor ,bg=bgcolor1 ,width=15 ,height=2, activebackground = "Red" ,font=('times', 15, ' bold '))
quitWindow.place(x=1010, y=500)
window.mainloop()
Home()