Update app.py
Browse files
app.py
CHANGED
|
@@ -20,8 +20,8 @@ EDU_DICT = {'Preschool': 1,
|
|
| 20 |
'Doctorate': 16
|
| 21 |
}
|
| 22 |
|
| 23 |
-
model =
|
| 24 |
-
unique_values =
|
| 25 |
|
| 26 |
unique_class = unique_values["workclass"]
|
| 27 |
unique_education = unique_values["education"]
|
|
@@ -33,19 +33,19 @@ unique_race = unique_values["race"]
|
|
| 33 |
unique_country = unique_values["native.country"]
|
| 34 |
|
| 35 |
def main():
|
| 36 |
-
st.title("Adult Income")
|
| 37 |
|
| 38 |
with st.form("questionaire"):
|
| 39 |
-
age =
|
| 40 |
-
workclass =
|
| 41 |
-
education =
|
| 42 |
-
Marital_Status =
|
| 43 |
-
occupation =
|
| 44 |
-
relationship =
|
| 45 |
-
race =
|
| 46 |
-
sex =
|
| 47 |
-
hours_per_week =
|
| 48 |
-
native_country =
|
| 49 |
|
| 50 |
# clicked==True only when the button is clicked
|
| 51 |
clicked = st.form_submit_button("Predict income")
|
|
@@ -61,5 +61,9 @@ def main():
|
|
| 61 |
"hours.per.week": [hours_per_week],
|
| 62 |
"native.country": [native_country]}))
|
| 63 |
# Show prediction
|
|
|
|
|
|
|
| 64 |
|
| 65 |
# Run main()
|
|
|
|
|
|
|
|
|
| 20 |
'Doctorate': 16
|
| 21 |
}
|
| 22 |
|
| 23 |
+
model = joblib.load('model.joblib')
|
| 24 |
+
unique_values = joblib.load('unique_values.joblib')
|
| 25 |
|
| 26 |
unique_class = unique_values["workclass"]
|
| 27 |
unique_education = unique_values["education"]
|
|
|
|
| 33 |
unique_country = unique_values["native.country"]
|
| 34 |
|
| 35 |
def main():
|
| 36 |
+
st.title("Adult Income") #<-Apps' name
|
| 37 |
|
| 38 |
with st.form("questionaire"):
|
| 39 |
+
age = st.slider('Age',min_value=10,max_value=100)
|
| 40 |
+
workclass = st.selectbox('work class',options=unique_class)
|
| 41 |
+
education = st.selectbox('education',options=unique_education)
|
| 42 |
+
Marital_Status = st.selectbox('marital status',options=unique_marital_status)
|
| 43 |
+
occupation = st.selectbox('occupation',options=unique_occupation)
|
| 44 |
+
relationship = st.selectbox('relationship',options=unique_relationship)
|
| 45 |
+
race = st.selectbox('race',options=unique_race)
|
| 46 |
+
sex = st.selectbox('sex',options=unique_sex)
|
| 47 |
+
hours_per_week = ('hours_per_week',min_value=1,max_value=100)
|
| 48 |
+
native_country = st.selectbox('country',options=unique_marital_country)
|
| 49 |
|
| 50 |
# clicked==True only when the button is clicked
|
| 51 |
clicked = st.form_submit_button("Predict income")
|
|
|
|
| 61 |
"hours.per.week": [hours_per_week],
|
| 62 |
"native.country": [native_country]}))
|
| 63 |
# Show prediction
|
| 64 |
+
result ='>50k' if result[0]==1 else '<=50k'
|
| 65 |
+
st.success("Your prediction income is" +result)
|
| 66 |
|
| 67 |
# Run main()
|
| 68 |
+
if __name__=="__main__":
|
| 69 |
+
main()
|