File size: 1,595 Bytes
11c72ff
 
 
3e9e049
11c72ff
a7e08b8
6c5babb
1d4c717
 
 
 
 
121936c
1d4c717
 
aea5318
11c72ff
 
 
 
 
 
 
 
4370125
11c72ff
aea5318
11c72ff
 
 
 
 
 
 
4370125
11c72ff
1d4c717
 
121936c
11c72ff
 
 
 
 
 
 
 
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
import joblib
import pandas as pd
import streamlit as st
import category_encoders as ce

model = joblib.load('model_tree.joblib')
unique_values = joblib.load('unique_values.joblib')
SEX_DICT = {'M':1,
            'F':2}
BP_DICT = {'LOW':1,
           'NORMAL':2,
           'HIGH':3}
Cholesterol_DICT = {'NORMAL':1,
               'HIGH':2}
               
unique_Sex = unique_values['Sex'] 
unique_BP = unique_values['BP']
unique_Cholesterol = unique_values['Cholesterol']


def main():
    st.title("Medicine Suggestion") #<-Apps' name

    with st.form("questionaire"):
        Age = st.slider('Age',min_value=10,max_value=100)
        Na_to_K = st.slider('Na_to_K',min_value=1,max_value=50)
        Sex = st.selectbox('Sex',options=unique_Sex)
        BP = st.selectbox('BP',options=unique_BP)
        Cholesterol = st.selectbox('Cholesterol',options=unique_Cholesterol)
        

        # clicked==True only when the button is clicked
        clicked = st.form_submit_button("Predict medicine")
        if clicked:
            result=model.predict(pd.DataFrame({"Age": [Age],
                                               "Na_to_K": [Na_to_K],
                                               "Sex": [SEX_DICT[Sex]],
                                               "BP": [BP_DICT[BP]],
                                               "Cholesterol": [Cholesterol_DICT[Cholesterol]]
                                               }))
            # Show prediction
            result = result[0]
            st.success("You should get " +result)

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