File size: 1,402 Bytes
11c72ff
 
 
 
a7e08b8
12c1860
11c72ff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9f42ce1
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
import joblib
import pandas as pd
import streamlit as st

model = joblib.load('model_tree.joblib')
unique_values = {"Sex":['M','F'],"BP":["LOW","NORMAL",'HIGH'],'Cholesterol':["LOW","NORMAL",'HIGH']}

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],
                                               "BP": [BP],
                                               "Cholesterol": [Cholesterol]
                                               }))
            # Show prediction
            result = result[0]
            st.success("You should get " +result)

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