# -*- coding: utf-8 -*- """app Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/1FxKIGQzWkYp6AR9LCDf1hHJfeiAgni2N """ import joblib import pandas as pd import streamlit as st model = joblib.load('model.joblib') unique_values = joblib.load('unique_values.joblib') unique_class = unique_values["workclass"] unique_education = unique_values["education"] unique_marital_status = unique_values["marital.status"] unique_relationship = unique_values["relationship"] unique_occupation = unique_values["occupation"] unique_sex = unique_values["sex"] unique_race = unique_values["race"] unique_country = unique_values["native.country"] def main(): st.title("Adult Income Analysis") with st.form("questionaire"): age = st.slider("Age", min_value=10, max_value=100) workclass = st.selectbox("Workclass", unique_class) education = st.selectbox("Education", unique_education) Marital_Status = st.selectbox("Marital Status", unique_marital_status) occupation = st.selectbox("Occupation", unique_occupation) relationship = st.selectbox("Relationship", unique_relationship) race = st.selectbox("Race", unique_race) sex = st.selectbox("Sex", unique_sex) hours_per_week = st.slider("Hours per week", min_value=1, max_value=100) native_country = st.selectbox("Country", unique_country) clicked = st.form_submit_button("Predict income") if clicked: result=model.predict(pd.DataFrame({"age": [age], "workclass": [workclass], "education": [education], "marital.status": [Marital_Status], "occupation": [occupation], "relationship": [relationship], "sex": [sex], "race": [race], "hours.per.week": [hours_per_week], "native.country": [native_country]})) result = '>50K' if result[0] == 1 else '<=50K' st.success('The predicted income is {}'.format(result)) if __name__=='__main__': main()