-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
186 lines (162 loc) · 8.57 KB
/
app.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
# app.py
import streamlit as st
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
# Load the diabetes dataset
df = pd.read_csv("diabetes.csv")
# Customizing Streamlit theme for dark mode
st.markdown(
"""
<style>
body {
color: white;
background-color: #1E1E1E;
}
.sidebar .sidebar-content {
background-color: #1E1E1E;
}
.Widget>label {
color: white;
}
.stButton>button {
color: black;
}
</style>
""",
unsafe_allow_html=True
)
# Page 1: Project Description
def project_description():
st.title("Predictive Health Analytics for Diabetes Risk Assessment and Personalized Reporting")
# Our Mission
st.header("Our Mission")
st.write("Welcome to DiabSynth, the frontier of predictive health analytics, where the synergy of algorithms and empathy "
"transforms the very fabric of diabetes care. Within our consortium, trailblazing minds, visionary engineers, "
"and dedicated healthcare aficionados unite with unwavering determination. Our collective mission is nothing short "
"of redefining the boundaries of healthcare technology, ushering in a new era in diabetes management that transcends the ordinary.")
# Our Vision
st.header("Our Vision")
st.write("Our vision transcends the confines of algorithms and raw data. DiabSynth aspires to manifest a world where individuals "
"don't merely receive healthcare insights but hold the knowledge and tools to seize control of their well-being. In our "
"revolutionary pursuit, we propel beyond the conventional boundaries, determined to bridge the formidable gap between "
"sophisticated machine learning techniques and pragmatic, user-friendly medical reporting.")
# Page 2: Team Members Details
def team_member_details():
st.title("Team Members")
team_members = [
{"name": "Sudarsanam Bharath", "role": "Team Lead", "bio": "Hey everyone, I'm Bharath, a skilled multitasker capable of getting the work done before due with high accuracy and consistency. I'm a tech enthusiast with a primary goal of learning almost every technology possible that the market requires. Revolutionary in thought and code, I spearhead our machine learning endeavor. With a background in Full Stack Development, Machine Learning & Advanced algorithms, UI&UX Design, and API's Development, I bring a visionary approach to decoding the complexities of diabetes analytics.", "image": "bharath.jpg"},
{"name": "Pooja Chinta", "role": "Data Insights Specialist", "bio": "I am Pooja, an undergraduate at MLR Institute of Technology, donning the role of a Data Insights Specialist in this project. With a keen focus on unraveling the stories hidden within vast datasets, I bring a meticulous approach to Data Analytics, Data Extraction, and Data Preprocessing. My expertise lies in transforming raw data into actionable insights, navigating the complexities of diverse datasets to extract meaningful narratives.", "image": "pooja.jpg"},
{"name": "Yenuganti Sai Kumar", "role": "Research Coordinator", "bio": "I'm honored to take on the pivotal role of Research Coordinator in the DiabSynth project. As a dedicated and insightful team member, my focus is on delving into the latest advancements in predictive health analytics. I take the lead in ensuring our team is well-informed about cutting-edge research, industry trends, and regulatory developments, contributing valuable insights to shape DiabSynth's innovative approach.", "image": "sai_kumar.jpg"},
{"name": "Talari Lakshmi", "role": "User Experience Advocate", "bio": "I, as the User Experience Advocate within the DiabSynth project, am dedicated to championing the end-user perspective. My role ensures that DiabSynth's reports go beyond technical accuracy to resonate with users, contributing to a positive and user-friendly experience. My advocacy for user-centric design principles is integral to DiabSynth's mission of providing actionable insights for proactive diabetes management.", "image": "lakshmi.jpg"}
]
for member in team_members:
st.subheader(member["name"])
st.write(f"**Role:** {member['role']}")
st.write(member["bio"])
# Page 3: Diabetes Prediction
def diabetes_prediction():
st.title('Diabetes Checkup')
st.sidebar.header('Patient Data')
st.subheader('Training Data Stats')
st.write(df.describe())
# X AND Y DATA
x = df.drop(['Outcome'], axis=1)
y = df['Outcome']
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2, random_state=0)
# FUNCTION
def user_report():
pregnancies = st.sidebar.slider('Pregnancies', 0, 17, 3)
glucose = st.sidebar.slider('Glucose', 0, 200, 120)
bp = st.sidebar.slider('Blood Pressure', 0, 122, 70)
skinthickness = st.sidebar.slider('Skin Thickness', 0, 100, 20)
insulin = st.sidebar.slider('Insulin', 0, 846, 79)
bmi = st.sidebar.slider('BMI', 0, 67, 20)
dpf = st.sidebar.slider('Diabetes Pedigree Function', 0.0, 2.4, 0.47)
age = st.sidebar.slider('Age', 21, 88, 33)
user_report_data = {
'Pregnancies': pregnancies,
'Glucose': glucose,
'BloodPressure': bp,
'SkinThickness': skinthickness,
'Insulin': insulin,
'BMI': bmi,
'DiabetesPedigreeFunction': dpf,
'Age': age
}
report_data = pd.DataFrame(user_report_data, index=[0])
return report_data
# PATIENT DATA
user_data = user_report()
st.subheader('Patient Data')
st.write(user_data)
# MODEL
rf = RandomForestClassifier()
rf.fit(x_train, y_train)
user_result = rf.predict(user_data)
# VISUALIZATIONS
st.title('Visualised Patient Report')
# COLOR FUNCTION
color = 'red' if user_result[0] == 1 else 'blue'
# Age vs Pregnancies
st.header('Pregnancy count Graph (Others vs Yours)')
fig_preg = plt.figure()
ax1 = sns.scatterplot(x='Age', y='Pregnancies', data=df, hue='Outcome', palette='Greens')
ax2 = sns.scatterplot(x=user_data['Age'], y=user_data['Pregnancies'], s=150, color=color)
plt.xticks(np.arange(10, 100, 5))
plt.yticks(np.arange(0, 20, 2))
plt.title('0 - Healthy & 1 - Unhealthy')
st.pyplot(fig_preg)
# Add similar blocks for other visualizations...
# OUTPUT
st.subheader('Your Report: ')
output = 'You are not Diabetic' if user_result[0] == 0 else 'You are Diabetic'
st.title(output)
st.subheader('Accuracy: ')
st.write(str(accuracy_score(y_test, rf.predict(x_test)) * 100) + '%')
# Page 4: Contact Us
def contact_us():
st.title("Contact Us")
st.write("Feel free to reach out to us with any questions or feedback!")
# Simple contact form
name = st.text_input("Your Name:")
email = st.text_input("Your Email:")
message = st.text_area("Message:")
if st.button("Submit"):
# Perform any desired action with the form data (e.g., send an email)
st.success("Ticket Raised!!.. we will get back to you asap")
# Main App
def main():
st.sidebar.title("DiabSynth Navigator")
page = st.sidebar.radio("Choose a Path", ["Project Description", "Home", "About", "Contact", "Blogs and References", "Diabetes Prediction"])
# Page routing
if page == "Project Description":
project_description()
# Include your Home page content here
elif page == "About":
st.markdown("[Click Here for About:](https://diabsynth.netlify.app/homepage/about)")
# Include your About page content here
elif page == "Diabetes Prediction":
diabetes_prediction()
# Include your Diabetes Prediction page content here
elif page == "Contact":
st.markdown("[Click Here for Contact:](https://diabsynth.netlify.app/homepage/contact)")
# Include your Contact page content here
elif page == "Blogs and References":
st.markdown("[Click Here for Blogs and Reference:](https://diabsynth.netlify.app/homepage/faq)")
elif page == "Project Description":
project_description()
elif page == "Home":
st.markdown("[Click Here for Home:](https://diabsynth.netlify.app/homepage/index.html)")
elif page == "Team Members":
team_member_details()
elif page == "Diabetes Prediction":
diabetes_prediction()
elif page == "Contact Us":
contact_us()
if __name__ == "__main__":
main()