mopaoleonel commited on
Commit
3bf542c
·
verified ·
1 Parent(s): f20ffdb

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +121 -0
  2. model_dump.pkl +3 -0
app.py ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from PIL import Image
3
+ import pandas as pd
4
+ import numpy as np
5
+ import matplotlib.pyplot as plt
6
+ import seaborn as sns
7
+ import pickle
8
+ import base64
9
+ from streamlit_option_menu import option_menu # Import the option_menu
10
+
11
+ def load_data(data):
12
+ df = pd.read_csv(data)
13
+ return df
14
+
15
+ def filedownload(df):
16
+ csv = df.to_csv(index=False)
17
+ b64 = base64.b64encode(csv.encode()).decode() # strings <-> bytes conversions
18
+ href = f'<a href="data:file/csv;base64,{b64}" download="diabete_predictions.csv">Download CSV File</a>'
19
+ return href
20
+
21
+ st.sidebar.image('images/photo_2025-05-23_18-50-58.jpg')
22
+
23
+ def main():
24
+ st.markdown("<h1 style='text-align: center; color:brown;'>Diabete Prediction</h1>", unsafe_allow_html=True)
25
+ st.markdown("<h3 style='text-align: center; color: white;'>Diabete Study in Cameroun</h3>", unsafe_allow_html=True)
26
+
27
+ # Replace st.sidebar.selectbox with option_menu
28
+ with st.sidebar: # Use a 'with' block for the sidebar to ensure the menu is placed there
29
+ selected = option_menu(
30
+ menu_title=None, # No title for the menu
31
+ options=["Home", "Analysis", "Data Visualisation", "Machine Learning", "About"], # Your menu options
32
+ icons=["house", "clipboard-data", "bar-chart", "robot", "info-circle"], # Optional: icons for each option
33
+ menu_icon="cast", # Optional: icon for the menu itself
34
+ default_index=0, # Default selected option
35
+ styles={
36
+ "container": {"padding": "5px!important", "background-color": "#fafafa"},
37
+ "icon": {"color": "brown", "font-size": "20px"},
38
+ "nav-link": {"font-size": "16px", "text-align": "left", "margin":"0px", "--hover-color": "#eee"},
39
+ "nav-link-selected": {"background-color": "brown"},
40
+ }
41
+ )
42
+
43
+ data = load_data("diabetes.csv")
44
+
45
+ if selected == "Home": # Use 'selected' instead of 'choice'
46
+ left, middle, right = st.columns((2,3,2))
47
+ with middle:
48
+ st.image("images/photo_2025-05-23_18-49-29.jpg", width=400)
49
+ st.write('This is an app that will analyse diabetes Datas with some python tools that can optimize decisions')
50
+ st.subheader('Diabetis Information')
51
+ st.write('In Cameroon, the prevalence of diabetes in adults in urban areas is currently estimated at 6 – 8%, with as much as 80% of people living with diabetes who are currently undiagnosed in the population. Further, according to data from Cameroon in 2002, only about a quarter of people with known diabetes actually had adequate control of their blood glucose levels. The burden of diabetes in Cameroon is not only high but is also rising rapidly. Data in Cameroonian adults based on three cross-sectional surveys over a 10-year period (1994–2004) showed an almost 10-fold increase in diabetes prevalence.')
52
+
53
+ elif selected == "Analysis":
54
+ st.subheader("Diabetes Analysis")
55
+ st.dataframe(data.head())
56
+
57
+ if st.checkbox("Summary"):
58
+ st.write(data.describe())
59
+
60
+ if st.checkbox("Correlation"):
61
+ fig = plt.figure(figsize=(15,15))
62
+ sns.heatmap(data.corr(), annot=True) # Removed st.write around sns.heatmap
63
+ st.pyplot(fig)
64
+
65
+ if st.checkbox("Column Names"):
66
+ st.write(data.columns)
67
+ st.markdown(filedownload(data), unsafe_allow_html=True)
68
+
69
+ elif selected == "Data Visualisation": # Corrected to "Data Visualisation" as in the options
70
+ st.subheader("Data Visualisation")
71
+ if st.checkbox("Countplot"):
72
+ fig = plt.figure(figsize=(15,15))
73
+ sns.countplot(x=data['Age']) # Removed st.write around sns.countplot
74
+ st.pyplot(fig)
75
+
76
+ if st.checkbox("Caterplot"):
77
+ fig = plt.figure(figsize=(15,15))
78
+ sns.scatterplot(x='Glucose', y='Age', data=data, hue='Outcome') # Removed st.write around sns.scatterplot
79
+ st.pyplot(fig)
80
+
81
+ elif selected == "Machine Learning":
82
+ st.subheader("Machine Learning")
83
+ tab1,tab2,tab3=st.tabs([":clipboard: data",":bar_chart: Visualisation",":mask: Prediction"])
84
+ uploaded_file = st.sidebar.file_uploader("Upload your input CSV file", type=["csv"])
85
+
86
+ if uploaded_file:
87
+ df = load_data(uploaded_file)
88
+ with tab1:
89
+ st.subheader("Loaded Data")
90
+ st.write(df)
91
+ with tab2:
92
+ st.subheader("Histogram glucose")
93
+ fig = plt.figure(figsize=(8,8))
94
+ sns.histplot(data=df, x='Glucose')
95
+ st.pyplot(fig)
96
+ with tab3:
97
+ model = pickle.load(open('model_dump.pkl','rb'))
98
+ prediction = model.predict(df)
99
+ st.subheader("Prediction")
100
+ #transformation de l'arrey predict en datafram
101
+ pp = pd.DataFrame(prediction, columns=['prediction'])
102
+ #concatenation avec le df de depart
103
+
104
+ ndf = pd.concat([df,pp],axis=1)
105
+ #ndf.Prediction = ndf.prediction.map({0:'NO diabete',1:'diabete'})
106
+ ndf.prediction.replace(0,'NO diabete Risk', inplace=True)
107
+ ndf.prediction.replace(1,'diabete Risk', inplace=True)
108
+ st.write(ndf)
109
+
110
+ button = st.button("Download")
111
+ if button:
112
+ st.markdown(filedownload(ndf), unsafe_allow_html=True)
113
+ st.write("Downloading..")
114
+ elif selected == "About": # Added the "About" section
115
+ st.subheader("About This Application")
116
+ st.write("This application was developed to analyze diabetes data, provide insights through visualizations, and predict diabetes risk using machine learning models.")
117
+ st.write("It serves as a tool to help understand and manage diabetes prevalence in regions like Cameroon.")
118
+
119
+
120
+ if __name__ == '__main__':
121
+ main()
model_dump.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4e2309032256d1b72706608262ecbe9bc7db9f1681b2a9112f2e4623004ea315
3
+ size 1883055