minjibi commited on
Commit
5af097e
·
1 Parent(s): 2cc4027

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -0
app.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import joblib
2
+ import pandas as pd
3
+ import streamlit as st
4
+
5
+ model = joblib.load('dia1.joblib')
6
+
7
+ def main():
8
+ st.title("💀Predicting Diabetes💀")
9
+
10
+ with st.form("questionaire"):
11
+ Pregnancies = st.slider('Pregnancy:',min_value=0,max_value=10)
12
+ Age = st.slider('Age:',min_value=0,max_value=100)
13
+ Glucose = st.number_input('Glucose')
14
+ BloodPressure = st.number_input('BloodPressure(mm Hg)')
15
+ SkinThickness = st.number_input('SkinThickness(mm)')
16
+ Insulin = st.number_input('Insulin(mu U/ml)')
17
+ Weight = st.number_input('Weight(kg)')
18
+ Height = st.number_input('Height(cm)')
19
+
20
+ # clicked==True only when the button is clicked
21
+ clicked = st.form_submit_button("Predict Diabetes")
22
+ if clicked:
23
+ result=model.predict(pd.DataFrame({"Pregnancies": [Pregnancies],
24
+ "Glucose": [Glucose],
25
+ "BloodPressure": [BloodPressure],
26
+ "SkinThickness": [SkinThickness],
27
+ "Insulin": [Insulin],
28
+ "BMI": [Weight / (Height/100)**2],
29
+ "Age": [Age]}))
30
+
31
+ result2=model.predict_proba(pd.DataFrame({"Pregnancies": [Pregnancies],
32
+ "Glucose": [Glucose],
33
+ "BloodPressure": [BloodPressure],
34
+ "SkinThickness": [SkinThickness],
35
+ "Insulin": [Insulin],
36
+ "BMI": [Weight / (Height/100)**2],
37
+ "Age": [Age]}))
38
+
39
+ # Show prediction
40
+ #sen = 'You have diabetes' if result[0]==1 else "You don't have diabetes"
41
+ if result[0]==1:
42
+ sen = (f'You have diabetes with a probability = {round(result2[0][1]*100,2)}%')
43
+ else :
44
+ sen = (f'You do not have diabetes with a probability = {round(result2[0][0]*100,2)}%')
45
+ st.success(sen)
46
+
47
+ # Run main()
48
+ if __name__ == '__main__':
49
+ main()