Spaces:
Runtime error
Runtime error
File size: 2,633 Bytes
71a3d2d 1cd6d8b 71a3d2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
import joblib
import pandas as pd
import streamlit as st #<-
model = joblib.load('model (1).joblib') #<-
unique_values = joblib.load('unique_values (1).joblib') #<-
unique_job_title = unique_values["job_title"]
unique_experience_level = unique_values["experience_level"]
unique_employment_type = unique_values["employment_type"]
unique_employee_residence= unique_values["employee_residence"]
unique_company_location = unique_values["company_location"]
unique_company_size = unique_values["company_size"]
def main(): #<- defined main
st.title("Rate of your Job's Salary") #<- app name
with st.form("questionaire"): #<- input from user
job_title=st.selectbox('job_title',options=unique_job_title) #<-
experience_level=st.selectbox('experience_level',options=unique_experience_level) #<-
employment_type=st.selectbox('employment_type',options=unique_employment_type)
employee_residence=st.selectbox('employee_residence',options=unique_employee_residence)
company_location=st.selectbox('company_location',options=unique_company_location)
company_size =st.selectbox('company_size',options=unique_company_size)
work_Year= st.number_input('work_year',min_value=2019,max_value=2022)
#<-
remote_ratio=st.radio(
"Select your remote_ratio 👇",
[0,50,100])
salary_in_usd=st.slider('salary_in_usd',min_value=0, max_value=600000) #<-
# clicked==True only when the button is clicked
clicked = st.form_submit_button("Show my job salary Rate")
if clicked:
result=model.predict(pd.DataFrame({"job_title": [job_title],
"experience_level": [experience_level],
"employment_type": [employment_type],
"employee_residence": [employee_residence],
"company_location": [company_location],
"company_size": [company_size],
"work_Year": [work_Year],
"remote_ratio": [remote_ratio],
"salary_in_usd": [salary_in_usd]}))
# Show prediction
result= '<300k' if result[0]=='<300k'else '>=300k'
#print report
st.success("Your job salary rating is "+result)
# Run main()
#when import but dont wanna run main so..
if __name__== "__main__":
main()
|