Diff of /Main1.py [000000] .. [6b894f]

Switch to unified view

a b/Main1.py
1
import tkinter as tk
2
from tkinter import Message ,Text
3
from PIL import Image, ImageTk
4
import pandas as pd
5
from tkinter import *
6
7
import tkinter.ttk as ttk
8
import tkinter.font as font
9
import tkinter.messagebox as tm
10
import matplotlib.pyplot as plt
11
import csv
12
import numpy as np
13
from PIL import Image, ImageTk
14
from tkinter import filedialog
15
import tkinter.messagebox as tm
16
17
import DTALG as DT
18
import LogisticRegression as LR
19
import svmalgo as svm
20
import XGboostalgo as xgbalgo
21
import RandomForest as RF
22
import Predict as pred
23
24
bgcolor="#DAF7A6"
25
bgcolor1="#B7C526"
26
fgcolor="black"
27
28
  
29
30
31
32
def Home():
33
    global window
34
    def clear():
35
        print("Clear1")
36
          
37
        txt1.delete(0, 'end')
38
        txt2.delete(0, 'end')
39
        txt3.delete(0, 'end')
40
        txt4.delete(0, 'end')    
41
        txt5.delete(0, 'end')
42
        txt6.delete(0, 'end')
43
        txt7.delete(0, 'end')
44
        txt8.delete(0, 'end')    
45
        txt9.delete(0, 'end')
46
        txt10.delete(0, 'end')
47
       
48
        
49
50
    window = tk.Tk()
51
    
52
    window.title("Heart Disease Prediction")
53
     
54
    window.geometry('1280x720')
55
    window.configure(background=bgcolor)
56
    #window.attributes('-fullscreen', True)
57
58
    window.grid_rowconfigure(0, weight=1)
59
    window.grid_columnconfigure(0, weight=1)
60
    
61
62
    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')) 
63
    message1.place(x=100, y=1)
64
65
    
66
67
    lbl1 = tk.Label(window, text="Enter Age in months",width=20  ,height=2  ,fg=fgcolor  ,bg=bgcolor ,font=('times', 15, ' bold ') ) 
68
    lbl1.place(x=50, y=100)
69
    
70
    txt1 = tk.Entry(window,width=20,bg="white" ,fg="black",font=('times', 15, ' bold '))
71
    txt1.place(x=300, y=115)
72
73
    lbl2 = tk.Label(window, text="Weight",width=20  ,height=2  ,fg=fgcolor  ,bg=bgcolor ,font=('times', 15, ' bold ') ) 
74
    lbl2.place(x=50, y=170)
75
    
76
    txt2 = tk.Entry(window,width=20,bg="white" ,fg="black",font=('times', 15, ' bold '))
77
    txt2.place(x=300, y=175)
78
    lbl3 = tk.Label(window, text="Height ",width=20  ,height=2  ,fg=fgcolor  ,bg=bgcolor ,font=('times', 15, ' bold ') ) 
79
    lbl3.place(x=50, y=230)
80
    
81
    txt3 = tk.Entry(window,width=20,bg="white" ,fg="black",font=('times', 15, ' bold '))
82
    txt3.place(x=300, y=235)
83
    
84
    lbl4 = tk.Label(window, text="Gender",width=20  ,height=2  ,fg=fgcolor  ,bg=bgcolor ,font=('times', 15, ' bold ') ) 
85
    lbl4.place(x=50, y=285)
86
    
87
    txt4 = tk.Entry(window,width=20,bg="white" ,fg="black",font=('times', 15, ' bold '))
88
    txt4.place(x=300, y=290)
89
90
    lbl5 = tk.Label(window, text="Heart Rate ",width=20  ,height=2  ,fg=fgcolor  ,bg=bgcolor ,font=('times', 15, ' bold ') ) 
91
    lbl5.place(x=50, y=350)
92
    
93
    txt5 = tk.Entry(window,width=20,bg="white" ,fg="black",font=('times', 15, ' bold '))
94
    txt5.place(x=300, y=365)
95
    lbl6 = tk.Label(window, text="Oxygen Saturation ",width=20  ,height=2  ,fg=fgcolor  ,bg=bgcolor ,font=('times', 15, ' bold ') ) 
96
    lbl6.place(x=50, y=420)
97
    
98
    txt6 = tk.Entry(window,width=20,bg="white" ,fg="black",font=('times', 15, ' bold '))
99
    txt6.place(x=300, y=435)
100
    lbl7 = tk.Label(window, text="Respiratory Rate",width=20  ,height=2  ,fg=fgcolor  ,bg=bgcolor ,font=('times', 15, ' bold ') ) 
101
    lbl7.place(x=550, y=100)
102
    
103
    txt7 = tk.Entry(window,width=20,bg="white" ,fg="black",font=('times', 15, ' bold '))
104
    txt7.place(x=800, y=115)
105
106
    lbl8 = tk.Label(window, text="Systolic Blood Pressure",width=20  ,height=2  ,fg=fgcolor  ,bg=bgcolor ,font=('times', 15, ' bold ') ) 
107
    lbl8.place(x=550, y=170)
108
    
109
    txt8 = tk.Entry(window,width=20,bg="white" ,fg="black",font=('times', 15, ' bold '))
110
    txt8.place(x=800, y=175)
111
    lbl9 = tk.Label(window, text="Diastolic Blood Pressure ",width=20  ,height=2  ,fg=fgcolor  ,bg=bgcolor ,font=('times', 15, ' bold ') ) 
112
    lbl9.place(x=550, y=230)
113
    
114
    txt9 = tk.Entry(window,width=20,bg="white" ,fg="black",font=('times', 15, ' bold '))
115
    txt9.place(x=800, y=235)
116
    
117
    lbl10 = tk.Label(window, text="Mean Blood Pressure",width=20  ,height=2  ,fg=fgcolor  ,bg=bgcolor ,font=('times', 15, ' bold ') ) 
118
    lbl10.place(x=550, y=285)
119
    
120
    txt10 = tk.Entry(window,width=20,bg="white" ,fg="black",font=('times', 15, ' bold '))
121
    txt10.place(x=800, y=290)
122
123
    
124
125
126
127
        
128
129
    def LRprocess():
130
        sym="Child_Heart_Stage_dataset.csv"
131
        if sym != "":
132
            LR.process(sym)
133
            tm.showinfo("Input", "Logistic Regression Successfully Finished")
134
        else:
135
            tm.showinfo("Input error", "Select Dataset File")
136
137
    def RFprocess():
138
        sym="Child_Heart_Stage_dataset.csv"
139
        if sym != "":
140
            RF.process(sym)
141
            tm.showinfo("Input", "Random Forest Successfully Finished")
142
        else:
143
            tm.showinfo("Input error", "Select Dataset File")
144
145
    def DTProcess():
146
        sym="Child_Heart_Stage_dataset.csv"
147
        if sym != "":
148
            DT.process(sym)
149
            tm.showinfo("Input", "Decision Tree Successfully Finished")
150
        else:
151
            tm.showinfo("Input error", "Select Dataset File")
152
153
    def svmprocess():
154
        sym="Child_Heart_Stage_dataset.csv"
155
        if sym != "":
156
            svm.process(sym)
157
            tm.showinfo("Input", "SVM Finished Success")
158
        else:
159
            tm.showinfo("Input error", "Select Dataset File")
160
    def xgbProcess():
161
        sym="Child_Heart_Stage_dataset.csv"
162
        if sym != "":
163
            xgbalgo.process(sym)
164
            tm.showinfo("Input", "XgBoost Finished Success")
165
        else:
166
            tm.showinfo("Input error", "Select Dataset File")
167
168
    def Predictprocess():
169
                sym="Child_Heart_Stage_dataset.csv"
170
                a1=txt1.get()
171
                a2=txt2.get()
172
                a3=txt3.get()
173
                a4=txt4.get()
174
                if a4=="male":
175
                        a4=1
176
                else:
177
                        a4=0
178
                a5=txt5.get()
179
                a6=txt6.get()
180
                a7=txt7.get()
181
                a8=txt8.get()
182
                a9=txt9.get()
183
                a10=txt10.get()
184
                if a1 == "":
185
                        tm.showinfo("Insert error", "Enter Age")
186
                elif a2 == "":
187
                        tm.showinfo("Insert error", "Enter Weight")
188
                elif a3 == "":
189
                        tm.showinfo("Insert error", "Enter Height")
190
                elif a4 == "":
191
                        tm.showinfo("Insert error", "Enter Gender")
192
                elif a5 == "":
193
                        tm.showinfo("Insert error", "Enter Heart Rate")
194
                elif a6 == "":
195
                        tm.showinfo("Insert error", "Enter oxygen saturation")
196
                elif a7 == "":
197
                        tm.showinfo("Insert error", "Enter Respiratory Rate")
198
                elif a8 == "":
199
                        tm.showinfo("Insert error", "Enter Systolic Blood Pressure")
200
                elif a9 == "":
201
                        tm.showinfo("Insert error", "Enter Diastolic Blood Pressure")
202
                elif a10=="":
203
                        tm.showinfo("Insert error", "Enter Mean Blood Pressure")
204
                else:
205
                        print("a1==",a1)
206
                        print("a2==",a2)
207
                        print("a3==",a3)
208
                        print("a4==",a4)
209
                        print("a5==",a5)
210
                        print("a6==",a6)
211
                        print("a7==",a7)
212
                        print("a8==",a8)
213
                        print("a9==",a9)
214
                        print("a10==",a10)
215
                        
216
                        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))
217
                        print(res)
218
                        if res!="":
219
                                tm.showinfo("Result", str(res))
220
                                tm.showinfo("Recommended Treatment", str(treat))
221
                        else:
222
                                tm.showinfo("Input error", "Select Dataset File")
223
                        
224
                                
225
226
    
227
228
    clearButton = tk.Button(window, text="Clear", command=clear  ,fg=fgcolor  ,bg=bgcolor1  ,width=14  ,height=2 ,activebackground = "Red" ,font=('times', 15, ' bold '))
229
    clearButton.place(x=10, y=500)
230
     
231
    proc = tk.Button(window, text="Random Forest", command=RFprocess  ,fg=fgcolor   ,bg=bgcolor1   ,width=14  ,height=2, activebackground = "Red" ,font=('times', 15, ' bold '))
232
    proc.place(x=210, y=500)
233
    
234
235
    LRbutton = tk.Button(window, text="SVM", command=svmprocess  ,fg=fgcolor   ,bg=bgcolor1   ,width=14  ,height=2, activebackground = "Red" ,font=('times', 15, ' bold '))
236
    LRbutton.place(x=410, y=500)
237
238
239
    RFbutton = tk.Button(window, text="XG Boost", command=xgbProcess  ,fg=fgcolor   ,bg=bgcolor1 ,width=14  ,height=2, activebackground = "Red" ,font=('times', 15, ' bold '))
240
    RFbutton.place(x=610, y=500)
241
242
    
243
244
    PRbutton = tk.Button(window, text="Predict", command=Predictprocess  ,fg=fgcolor   ,bg=bgcolor1   ,width=14  ,height=2, activebackground = "Red" ,font=('times', 15, ' bold '))
245
    PRbutton.place(x=810, y=500)
246
247
    quitWindow = tk.Button(window, text="Quit", command=window.destroy  ,fg=fgcolor   ,bg=bgcolor1  ,width=15  ,height=2, activebackground = "Red" ,font=('times', 15, ' bold '))
248
    quitWindow.place(x=1010, y=500)
249
250
    window.mainloop()
251
Home()
252