Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import joblib
|
| 2 |
import pandas as pd
|
| 3 |
-
|
| 4 |
|
| 5 |
EDU_DICT = {'Preschool': 1,
|
| 6 |
'1st-4th': 2,
|
|
@@ -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"]
|
|
@@ -36,16 +36,16 @@ 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")
|
|
@@ -60,6 +60,9 @@ def main():
|
|
| 60 |
"sex": [sex],
|
| 61 |
"hours.per.week": [hours_per_week],
|
| 62 |
"native.country": [native_country]}))
|
| 63 |
-
# Show prediction
|
| 64 |
|
| 65 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import joblib
|
| 2 |
import pandas as pd
|
| 3 |
+
import streamlit as st
|
| 4 |
|
| 5 |
EDU_DICT = {'Preschool': 1,
|
| 6 |
'1st-4th': 2,
|
|
|
|
| 20 |
'Doctorate': 16
|
| 21 |
}
|
| 22 |
|
| 23 |
+
model = jobjib.load('model.jobjib')
|
| 24 |
+
unique_values = jobjib.load('unique_valie.jobjib')
|
| 25 |
|
| 26 |
unique_class = unique_values["workclass"]
|
| 27 |
unique_education = unique_values["education"]
|
|
|
|
| 36 |
st.title("Adult Income")
|
| 37 |
|
| 38 |
with st.form("questionaire"):
|
| 39 |
+
age = st.slider("Age", min-value=10, max_value=100)
|
| 40 |
+
workclass = st.selectbox("Workclass", option=unique_class)
|
| 41 |
+
education = st.selectbox("Education", option=unique_education )
|
| 42 |
+
Marital_Status = st.selectbox("Marital_Status", option=unique_ Marital_Status)
|
| 43 |
+
occupation = st.selectbox("Occupation", option=unique_occupation)
|
| 44 |
+
relationship = st.selectbox("Relationship", option=unique_relationship)
|
| 45 |
+
race = st.selectbox("Race", option=unique_race)
|
| 46 |
+
sex = st.selectbox("Sex", option=unique_sex)
|
| 47 |
+
hours_per_week = st.slider("Hours_per_week", min-value=1, max_value=100)
|
| 48 |
+
native_country = st.selectbox("Native_country", option=unique_native_country)
|
| 49 |
|
| 50 |
# clicked==True only when the button is clicked
|
| 51 |
clicked = st.form_submit_button("Predict income")
|
|
|
|
| 60 |
"sex": [sex],
|
| 61 |
"hours.per.week": [hours_per_week],
|
| 62 |
"native.country": [native_country]}))
|
|
|
|
| 63 |
|
| 64 |
+
# Show prediction
|
| 65 |
+
result = '>50K' if result[0] == 1 else '<50K'
|
| 66 |
+
st.success("Your predicted income is "+resule"")
|
| 67 |
+
if __name__ = "__main__":
|
| 68 |
+
main()
|