-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
190 lines (176 loc) · 7.59 KB
/
Copy pathapp.py
File metadata and controls
190 lines (176 loc) · 7.59 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
import os
import pickle
import streamlit as st
from streamlit_option_menu import option_menu
# Set page configuration
st.set_page_config(page_title="Prediction of Disease Outbreaks", layout="wide", page_icon="🔬")
# Custom CSS for styling
st.markdown("""
<style>
.stButton > button {
background-color: #4CAF50;
color: white;
font-size: 18px;
border-radius: 10px;
padding: 10px 20px;
margin-top: 20px;
}
.stButton > button:hover {
background-color: #45a049;
color: #06402B;
border : 2px solid #06402B;
}
.sidebar .sidebar-content {
background-color: #f5f5f5;
}
.stTextInput input {
font-size: 16px;
padding: 10px;
border-radius: 5px;
}
.stTitle {
font-size: 28px;
font-weight: bold;
}
.stSubheader {
font-size: 22px;
}
</style>
""", unsafe_allow_html=True)
# Getting the working directory of the main.py
working_dir = os.path.dirname(os.path.abspath(__file__))
# Loading the saved models
diabetes_model = pickle.load(open(f'{working_dir}/diabetes_model.sav', 'rb'))
heart_disease_model = pickle.load(open(f'{working_dir}/heart_disease_model.sav', 'rb'))
parkinsons_model = pickle.load(open(f'{working_dir}/parkinsons_model.sav', 'rb'))
# Sidebar for navigation
with st.sidebar:
selected = option_menu('Prediction of Disease Outbreaks System',
['Diabetes Prediction',
'Heart Disease Prediction',
'Parkinsons Prediction'],
menu_icon='hospital-fill',
icons=['activity', 'heart', 'person'],
default_index=0)
# Diabetes Prediction Page
if selected == 'Diabetes Prediction':
st.title('Diabetes Prediction using Machine Learning')
col1, col2, col3 = st.columns(3)
with col1:
Pregnancies = st.number_input('Number of Pregnancies', min_value=0, step=1)
with col2:
Glucose = st.number_input('Glucose Level', min_value=0, step=1)
with col3:
BloodPressure = st.number_input('Blood Pressure Value', min_value=0, step=1)
with col1:
SkinThickness = st.number_input('Skin Thickness Value', min_value=0, step=1)
with col2:
Insulin = st.number_input('Insulin Level', min_value=0, step=1)
with col3:
BMI = st.number_input('BMI Value', min_value=0.0, step=0.1)
with col1:
DiabetesPedigreeFunction = st.number_input('Diabetes Pedigree Function Value', min_value=0.0, step=0.01)
with col2:
Age = st.number_input('Age of the Person', min_value=0, step=1)
# Prediction Button
if st.button('Diabetes Test Result'):
user_input = [Pregnancies, Glucose, BloodPressure, SkinThickness, Insulin, BMI, DiabetesPedigreeFunction, Age]
diab_prediction = diabetes_model.predict([user_input])
if diab_prediction[0] == 1:
st.success('The person is diabetic')
else:
st.success('The person is not diabetic')
# Heart Disease Prediction Page
if selected == 'Heart Disease Prediction':
st.title('Heart Disease Prediction using Machine Learning')
col1, col2, col3 = st.columns(3)
with col1:
age = st.number_input('Age', min_value=0, step=1)
with col2:
sex = st.number_input('Sex (1 = male, 0 = female)', min_value=0, max_value=1)
with col3:
cp = st.number_input('Chest Pain Types', min_value=0, step=1)
with col1:
trestbps = st.number_input('Resting Blood Pressure', min_value=0, step=1)
with col2:
chol = st.number_input('Serum Cholestoral in mg/dl', min_value=0, step=1)
with col3:
fbs = st.number_input('Fasting Blood Sugar > 120 mg/dl (1 = true; 0 = false)', min_value=0, max_value=1)
with col1:
restecg = st.number_input('Resting Electrocardiographic Results', min_value=0, step=1)
with col2:
thalach = st.number_input('Maximum Heart Rate Achieved', min_value=0, step=1)
with col3:
exang = st.number_input('Exercise Induced Angina (1 = yes; 0 = no)', min_value=0, max_value=1)
with col1:
oldpeak = st.number_input('ST Depression Induced by Exercise', min_value=0.0, step=0.1)
with col2:
slope = st.number_input('Slope of the Peak Exercise ST Segment', min_value=0, step=1)
with col3:
ca = st.number_input('Number of Major Vessels Colored by Fluoroscopy', min_value=0, step=1)
with col1:
thal = st.number_input('Thalassemia (1 = normal; 2 = fixed defect; 3 = reversible defect)', min_value=0, max_value=3)
# Prediction Button
if st.button('Heart Disease Test Result'):
user_input = [age, sex, cp, trestbps, chol, fbs, restecg, thalach, exang, oldpeak, slope, ca, thal]
heart_prediction = heart_disease_model.predict([user_input])
if heart_prediction[0] == 1:
st.success('The person is having heart disease')
else:
st.success('The person does not have any heart disease')
# Parkinson's Disease Prediction Page
if selected == "Parkinsons Prediction":
st.title("Parkinson's Disease Prediction using Machine Learning")
col1, col2, col3, col4, col5 = st.columns(5)
with col1:
fo = st.number_input('MDVP:Fo(Hz)', min_value=0.0, step=0.01)
with col2:
fhi = st.number_input('MDVP:Fhi(Hz)', min_value=0.0, step=0.01)
with col3:
flo = st.number_input('MDVP:Flo(Hz)', min_value=0.0, step=0.01)
with col4:
Jitter_percent = st.number_input('MDVP:Jitter(%)', min_value=0.0, step=0.01)
with col5:
Jitter_Abs = st.number_input('MDVP:Jitter(Abs)', min_value=0.0, step=0.01)
with col1:
RAP = st.number_input('MDVP:RAP', min_value=0.0, step=0.01)
with col2:
PPQ = st.number_input('MDVP:PPQ', min_value=0.0, step=0.01)
with col3:
DDP = st.number_input('Jitter:DDP', min_value=0.0, step=0.01)
with col4:
Shimmer = st.number_input('MDVP:Shimmer', min_value=0.0, step=0.01)
with col5:
Shimmer_dB = st.number_input('MDVP:Shimmer(dB)', min_value=0.0, step=0.01)
with col1:
APQ3 = st.number_input('Shimmer:APQ3', min_value=0.0, step=0.01)
with col2:
APQ5 = st.number_input('Shimmer:APQ5', min_value=0.0, step=0.01)
with col3:
APQ = st.number_input('MDVP:APQ', min_value=0.0, step=0.01)
with col4:
DDA = st.number_input('Shimmer:DDA', min_value=0.0, step=0.01)
with col5:
NHR = st.number_input('NHR', min_value=0.0, step=0.01)
with col1:
HNR = st.number_input('HNR', min_value=0.0, step=0.01)
with col2:
RPDE = st.number_input('RPDE', min_value=0.0, step=0.01)
with col3:
DFA = st.number_input('DFA', min_value=0.0, step=0.01)
with col4:
spread1 = st.number_input('spread1', step=0.01)
with col5:
spread2 = st.number_input('spread2', min_value=0.0, step=0.01)
with col1:
D2 = st.number_input('D2', min_value=0.0, step=0.01)
with col2:
PPE = st.number_input('PPE', min_value=0.0, step=0.01)
# Prediction Button
if st.button("Parkinson's Test Result"):
user_input = [fo, fhi, flo, Jitter_percent, Jitter_Abs, RAP, PPQ, DDP, Shimmer, Shimmer_dB, APQ3, APQ5, APQ, DDA, NHR, HNR, RPDE, DFA, spread1, spread2, D2, PPE]
parkinsons_prediction = parkinsons_model.predict([user_input])
if parkinsons_prediction[0] == 1:
st.success("The person has Parkinson's disease")
else:
st.success("The person does not have Parkinson's disease")