File size: 2,289 Bytes
5af097e
 
 
 
 
 
 
 
 
 
d90a861
 
 
5af097e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import joblib
import pandas as pd
import streamlit as st

model = joblib.load('dia1.joblib')

def main():
    st.title("💀Predicting Diabetes💀")

    with st.form("questionaire"):
        Pregnancies = st.slider('Pregnancy(times)',min_value=0,max_value=10)
        Age = st.slider('Age',min_value=0,max_value=100)
        Glucose = st.number_input('Glucose(mg/dl)')
        BloodPressure = st.number_input('BloodPressure(mm Hg)')
        SkinThickness = st.number_input('SkinThickness(mm)')
        Insulin = st.number_input('Insulin(mu U/ml)')
        Weight = st.number_input('Weight(kg)')
        Height = st.number_input('Height(cm)')

        # clicked==True only when the button is clicked
        clicked = st.form_submit_button("Predict Diabetes")
        if clicked:
            result=model.predict(pd.DataFrame({"Pregnancies": [Pregnancies],
                                               "Glucose": [Glucose],
                                               "BloodPressure": [BloodPressure],
                                               "SkinThickness": [SkinThickness],
                                               "Insulin": [Insulin],
                                               "BMI": [Weight / (Height/100)**2],
                                               "Age": [Age]}))

            result2=model.predict_proba(pd.DataFrame({"Pregnancies": [Pregnancies],
                                               "Glucose": [Glucose],
                                               "BloodPressure": [BloodPressure],
                                               "SkinThickness": [SkinThickness],
                                               "Insulin": [Insulin],
                                               "BMI": [Weight / (Height/100)**2],
                                               "Age": [Age]}))
            
            # Show prediction
            #sen = 'You have diabetes' if result[0]==1 else "You don't have diabetes"
            if result[0]==1:
                sen = (f'You have diabetes with a probability = {round(result2[0][1]*100,2)}%')
            else :
                sen = (f'You do not have diabetes with a probability = {round(result2[0][0]*100,2)}%')
            st.success(sen)

# Run main()
if __name__ == '__main__':
    main()