File size: 4,224 Bytes
d93d2b0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b490245
 
d93d2b0
 
 
 
 
 
 
d7f3b30
d93d2b0
 
 
 
 
 
 
 
 
 
 
 
 
d081c81
b490245
 
d93d2b0
 
 
 
 
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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_ == st.slider("Weight_(kg)", min_value=100, max_value=200)
        Height_ == 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_],
                                               "Height_(cm)": [Height_]}))
            result = 'Very Good' if result[0] == 1 else 'Poor'
            st.success('The predicted General Health is {}'.format(result))

if __name__=='__main__':
    main()