Spaces:
Runtime error
Runtime error
File size: 1,679 Bytes
cc02c5c 8dd8c04 cc02c5c 38434a7 1c0d9f7 cc02c5c 8dd8c04 67247e2 8dd8c04 cc02c5c 8dd8c04 cc02c5c 8dd8c04 b35cf4b cc02c5c 8dd8c04 cc02c5c d6a16ee 8dd8c04 93cec47 8dd8c04 cc02c5c b35cf4b 2896dfe b35cf4b 2896dfe b35cf4b 2896dfe b35cf4b 2896dfe b35cf4b 2896dfe 1a487f2 cc02c5c 8dd8c04 7ea50e7 |
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
model = joblib.load('model_drug.joblib')
unique_values = joblib.load('unique_values _drug.joblib')
unique_sex = unique_values["Sex"]
unique_BP = unique_values["BP"]
unique_Cholesterol = unique_values["Cholesterol"]
def main():
st.title("Drug Type")
with st.form("questionaire"):
Age = st.slider('Age',min_value=1,max_value=100)
BP = st.selectbox('Blood Pressure Levels',options=unique_BP)
Sex = st.selectbox('Sex',options=unique_sex)
Cholesterol = st.selectbox('Cholesterol',options=unique_Cholesterol)
Na_to_K =st.slider('Sodium to potassium Ration in Blood',min_value=1,max_value=40)
# clicked==True only when the button is clicked
clicked = st.form_submit_button("Predict Drug")
if clicked:
result=model.predict(pd.DataFrame({"Age": [Age],
"BP": [BP],
"Cholesterol": [Cholesterol],
"Sex": [Sex],
"Na_to_K": [Na_to_K]
}))
# Show prediction
if result==1:
result='DrugY'
elif result==2:
result='drugC'
elif result==3:
result='drugX'
elif result==4:
result='drugA'
else :
result='drugB'
st.success('Your Predicted Drug is '+result)
# Run main()
if __name__=='__main__':
main() |