-
Notifications
You must be signed in to change notification settings - Fork 0
/
mdps_public.py
166 lines (94 loc) · 4.24 KB
/
mdps_public.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
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 10 15:31:27 2022
@author: ABHISHEK SINGH
"""
import pickle
import streamlit as st
from streamlit_option_menu import option_menu
# loading the saved Model
diabetes_model = pickle.load(open('diabetic_model.sav', 'rb'))
hearts_model = pickle.load(open('heart_disease_model.sav', 'rb'))
# sidebar for navigation
with st.sidebar:
selected = option_menu('Disease Prediction System',
['Diabetic Prediction',
'Heart Disease Prediction System'],
icons=['activity', 'heart'],
default_index = 0)
# Diabetes Prediction Page
if(selected == 'Diabetic Prediction'):
# page title
st.title('Diabetic Prediction Using ML')
# getting the input data from the user
#column for input fields
col1, col2, col3 = st.columns(3)
with col1:
Pregnancies = st.text_input('Number of Pregnacies')
with col2:
Glucose = st.text_input('Glucose Level')
with col3:
BloodPressure = st.text_input('Blood Pressure value')
with col1:
SkinThikness = st.text_input('Skin Thickness Value')
with col2:
Insulin = st.text_input('Insulin level')
with col3:
BMI = st.text_input('BMI value')
with col1:
DiabetesPedigreeFunction = st.text_input('Diabetes Pedigree Function value')
with col2:
Age = st.text_input('Age of the Person')
# code for Prediction
diab_diagnosis = ''
# creating a button for Prediction
if st.button('Diabetes Test Result'):
diab_diagnosis = diabetes_model.predict([[Pregnancies, Glucose, BloodPressure, SkinThikness, Insulin, BMI, DiabetesPedigreeFunction, Age]])
if (diab_diagnosis[0] == 1):
diab_diagnosis = 'The Person Is Diabetic'
else:
diab_diagnosis = 'The Person is Not Diabetic'
st.success(diab_diagnosis)
# Heart disease Prediction Page
if(selected == 'Heart Disease Prediction System'):
# page title
st.title('Heart Disease Prediction System Using ML')
# getting the input data from the user
#column for input fields
col1, col2, col3 = st.columns(3)
with col1:
age = st.text_input('Age')
with col2:
sex = st.text_input('Sex')
with col3:
cp = st.text_input('Cheest Pain Type')
with col1:
trestbps = st.text_input('Resting Blood Pressure')
with col2:
chol = st.text_input('serum cholestoral in mg/dl')
with col3:
fbs = st.text_input('fasting blood sugar > 120 mg/dl')
with col1:
restecg = st.text_input('resting electrocardiographic results (values 0,1,2)')
with col2:
thalach = st.text_input('maximum heart rate achieved')
with col3:
exang = st.text_input('exercise induced angina')
with col1:
oldpeak = st.text_input('oldpeak = ST depression induced by exercise relative to rest')
with col2:
slope = st.text_input('the slope of the peak exercise ST segment')
with col3:
ca = st.text_input('number of major vessels (0-3) colored by flourosopy')
with col1:
thal = st.text_input('thal: 0 = normal; 1 = fixed defect; 2 = reversable defect')
# code for Prediction
diab_diagnosis = ''
# creating a button for Prediction
if st.button('Heart Disease Test Result'):
diab_diagnosis = hearts_model.predict([[age, sex, cp, trestbps, chol, fbs, restecg, thalach, exang, oldpeak, slope, ca, thal]])
if (diab_diagnosis[0] == 1):
diab_diagnosis = 'The Person has Heart Disease'
else:
diab_diagnosis = 'The Person does not have a heart Disease'
st.success(diab_diagnosis)