import joblib import pandas as pd import streamlit as st EDU_DICT = {'18-24': 1, '25-29': 2, '30-34': 3, '35-39': 4, '40-44': 5, '45-49': 6, '50-54': 7, '55-59': 8, '60-64': 9, '65-69': 10, '70-74': 11, '75-79': 12, '80+': 13 } model = joblib.load('model_n.joblib') unique_values = joblib.load('unique_values_n.joblib') #unique_General_Health = unique_values["General_Health"] unique_Checkup = unique_values["Checkup"] unique_Exercise = unique_values["Exercise"] unique_Heart_Disease = unique_values["Heart_Disease"] unique_Skin_Cancer = unique_values["Skin_Cancer"] unique_Other_Cancer = unique_values["Other_Cancer"] unique_Depression = unique_values["Depression"] unique_Diabetes = unique_values["Diabetes"] unique_Arthritis = unique_values["Arthritis"] unique_Sex = unique_values["Sex"] unique_Age_Category = unique_values["Age_Category"] unique_Smoking_History = unique_values["Smoking_History"] def main(): st.title("General Health analysis") with st.form("questionaire"): Checkup = st.selectbox("Checkup", unique_Checkup) Exercise = st.selectbox("Exercise", unique_Exercise) Heart_Disease = st.selectbox("Heart Disease", unique_Heart_Disease) Skin_Cancer = st.selectbox("Skin Cancer", unique_Skin_Cancer) Other_Cancer = st.selectbox("Other Cancer", unique_Other_Cancer) Depression = st.selectbox("Depression", unique_Depression) Diabetes = st.selectbox("Diabetes", unique_Diabetes) Arthritis = st.selectbox("Arthritis", unique_Arthritis) Sex = st.selectbox("Sex", unique_Sex) Age_Category = st.selectbox("Age Category", unique_Age_Category) BMI = st.slider("BMI", min_value=1, max_value=50) Smoking_History = st.selectbox("Smoking History", unique_Smoking_History) Alcohol_Consumption = st.slider("Alcohol Consumption", min_value=0, max_value=100) Fruit_Consumption = st.slider("Fruit Consumption", min_value=0, max_value=100) Green_Vegetables_Consumption = st.slider("Green Vegetables Consumption", min_value=0, max_value=100) FriedPotato_Consumption = st.slider("Fried Potato Consumption", min_value=0, max_value=100) Weight_kg = st.slider("Weight_(kg)", min_value=30, max_value=150) Height_cm = st.slider("Height_(cm)", min_value=100, max_value=200) clicked = st.form_submit_button("Predict General Health") if clicked: result=model.predict(pd.DataFrame({"Checkup": [Checkup], "Exercise": [Exercise], "Heart_Disease": [Heart_Disease], "Skin_Cancer": [Skin_Cancer], "Other_Cancer": [Other_Cancer], "Depression": [Depression], "Diabetes": [Diabetes], "Arthritis": [Arthritis], "Sex": [Sex], "Age_Category": [EDU_DICT[Age_Category]], "BMI": [BMI], "Smoking_History": [Smoking_History], "Alcohol_Consumption": [Alcohol_Consumption], "Fruit_Consumption": [Fruit_Consumption], "Green_Vegetables_Consumption": [Green_Vegetables_Consumption], "FriedPotato_Consumption": [FriedPotato_Consumption], "Weight_kg": [Weight_kg], "Height_cm": [Height_cm]})) result = 'Very Good' if result[0] == 1 else 'Poor' st.success('The predicted General Health is {}'.format(result)) if __name__=='__main__': main()