Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,65 +2,26 @@ import joblib
|
|
| 2 |
import pandas as pd
|
| 3 |
import streamlit as st
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
'5th-6th': 3,
|
| 8 |
-
'7th-8th': 4,
|
| 9 |
-
'9th': 5,
|
| 10 |
-
'10th': 6,
|
| 11 |
-
'11th': 7,
|
| 12 |
-
'12th': 8,
|
| 13 |
-
'HS-grad': 9,
|
| 14 |
-
'Some-college': 10,
|
| 15 |
-
'Assoc-voc': 11,
|
| 16 |
-
'Assoc-acdm': 12,
|
| 17 |
-
'Bachelors': 13,
|
| 18 |
-
'Masters': 14,
|
| 19 |
-
'Prof-school': 15,
|
| 20 |
-
'Doctorate': 16
|
| 21 |
-
}
|
| 22 |
-
|
| 23 |
-
model = joblib.load('model.joblib')
|
| 24 |
-
unique_values = joblib.load('unique_values.joblib')
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
unique_marital_status = unique_values["marital.status"]
|
| 29 |
-
unique_relationship = unique_values["relationship"]
|
| 30 |
-
unique_occupation = unique_values["occupation"]
|
| 31 |
-
unique_sex = unique_values["sex"]
|
| 32 |
-
unique_race = unique_values["race"]
|
| 33 |
-
unique_country = unique_values["native.country"]
|
| 34 |
|
| 35 |
def main():
|
| 36 |
-
st.title("
|
| 37 |
|
| 38 |
with st.form("questionaire"):
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
Marital_Status = st.selectbox("Marital Status", unique_marital_status)
|
| 43 |
-
occupation = st.selectbox("Occupation", unique_occupation)
|
| 44 |
-
relationship = st.selectbox("Relationship", unique_relationship)
|
| 45 |
-
race = st.selectbox("Race", unique_race)
|
| 46 |
-
sex = st.selectbox("Sex", unique_sex)
|
| 47 |
-
hours_per_week = st.slider("Hours per week", min_value=1, max_value=100)
|
| 48 |
-
native_country = st.selectbox("Country", unique_country)
|
| 49 |
|
| 50 |
-
clicked = st.form_submit_button("
|
| 51 |
if clicked:
|
| 52 |
-
result=model.predict(pd.DataFrame({"
|
| 53 |
-
"
|
| 54 |
-
"
|
| 55 |
-
|
| 56 |
-
"occupation": [occupation],
|
| 57 |
-
"relationship": [relationship],
|
| 58 |
-
"race": [race],
|
| 59 |
-
"sex": [sex],
|
| 60 |
-
"hours.per.week": [hours_per_week],
|
| 61 |
-
"native.country": [native_country]}))
|
| 62 |
-
result = '>50K' if result[0] == 1 else '<=50K'
|
| 63 |
-
st.success('The predicted income is {}'.format(result))
|
| 64 |
|
| 65 |
if __name__=='__main__':
|
| 66 |
main()
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
import streamlit as st
|
| 4 |
|
| 5 |
+
model = joblib.load('modelB.joblib')
|
| 6 |
+
unique_values = joblib.load('unique_valuesB.joblib')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
+
unique_gender = unique_values["Gender"]
|
| 9 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
def main():
|
| 12 |
+
st.title("BMI Predict")
|
| 13 |
|
| 14 |
with st.form("questionaire"):
|
| 15 |
+
Gender = st.selectbox("Gender",unique_gender)
|
| 16 |
+
Height = st.slider("Height", min_value=140, max_value=199)
|
| 17 |
+
Weight = st.slider("Weight", min_value=50, max_value=160)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
clicked = st.form_submit_button("BMI")
|
| 20 |
if clicked:
|
| 21 |
+
result=model.predict(pd.DataFrame({"Gender": [Gender],
|
| 22 |
+
"Height": [Height],
|
| 23 |
+
"Weight": [Weight]}))
|
| 24 |
+
st.success('The predicted BMI is {}'.format(result))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
if __name__=='__main__':
|
| 27 |
main()
|