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()