|
|
|
"""Copy of app |
|
|
|
Automatically generated by Colaboratory. |
|
|
|
Original file is located at |
|
https://colab.research.google.com/drive/1R-sJnRs7vjJiKyChrebsPbJW374OmZQr |
|
""" |
|
|
|
import joblib |
|
import pandas as pd |
|
import streamlit as st |
|
|
|
EDU_DICT = {"Bachelor's": 1, |
|
"Master's": 2, |
|
"PhD": 3, |
|
} |
|
|
|
model = joblib.load('model.joblib') |
|
unique_values = joblib.load('unique_values.joblib') |
|
|
|
unique_Gender = unique_values["Gender"] |
|
unique_Job_Title = unique_values["Job Title"] |
|
unique_Education_Level = unique_values["Education Level"] |
|
|
|
def main(): |
|
st.title("Job's Salary Analysis") |
|
with st.form("questionaire"): |
|
Age = st.slider("Age", min_value=23, max_value=53) |
|
Gender = st.selectbox("Gender", unique_Gender) |
|
Education = st.selectbox("Education Level", unique_Education_Level) |
|
Job_Title = st.selectbox("Job Title", unique_Job_Title) |
|
Years_of_Experience = st.slider("Years of Experience", min_value=0, max_value=25) |
|
|
|
clicked = st.form_submit_button("Predict Salary") |
|
if clicked: |
|
result=model.predict(pd.DataFrame({"Age": [Age], |
|
"Gender": [Gender], |
|
"Job Title": [Job_Title], |
|
"Years of Experience": [Years_of_Experience], |
|
"Education Level": [EDU_DICT[Education]] |
|
})) |
|
result = '>100K' if result[0] == 1 else '<=100K' |
|
st.success('The predicted salary is {}'.format(result)) |
|
|
|
if __name__=='__main__': |
|
main() |
|
|
|
|