Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import pandas as pd
|
|
| 3 |
import os
|
| 4 |
|
| 5 |
# Load data
|
| 6 |
-
|
| 7 |
similarity = pd.read_pickle('similarity.pkl')
|
| 8 |
|
| 9 |
# st.write("DataFrame Columns:", df.columns)
|
|
@@ -20,7 +20,7 @@ def login_frm():
|
|
| 20 |
st.error("Invalid username or password")
|
| 21 |
|
| 22 |
# Recommendation Function
|
| 23 |
-
def recommendation(applicants, companies,
|
| 24 |
try:
|
| 25 |
recommendations = {}
|
| 26 |
applicants['User ID'] = np.arange(len(applicants))
|
|
@@ -33,40 +33,6 @@ def recommendation(applicants, companies, similarity_scores, num_recommendations
|
|
| 33 |
except IndexError:
|
| 34 |
return []
|
| 35 |
|
| 36 |
-
# def job_details_frm(index):
|
| 37 |
-
# job = df.iloc[index]
|
| 38 |
-
# st.write(f"## {job['Title']}")
|
| 39 |
-
# st.write(f"### Description:")
|
| 40 |
-
# st.markdown(f"{job['Description'].replace('\r', '').replace('\n\n\n', ' ')}", unsafe_allow_html=True)
|
| 41 |
-
# st.write(f"### Requirements:")
|
| 42 |
-
# st.markdown(f"{job['Requirements'].replace('\r', '').replace('\n\n\n', ' ')}", unsafe_allow_html=True)
|
| 43 |
-
# st.write(f"### Location: {job['City']}, {job['State']}, {job['Country']}")
|
| 44 |
-
# if st.button('Back to recommendations'):
|
| 45 |
-
# st.session_state['view'] = 'home'
|
| 46 |
-
|
| 47 |
-
# def save_favorite_job(job):
|
| 48 |
-
# if 'favorites' not in st.session_state:
|
| 49 |
-
# st.session_state['favorites'] = []
|
| 50 |
-
# st.session_state['favorites'].append(job)
|
| 51 |
-
# st.success("Job saved to favorites!")
|
| 52 |
-
|
| 53 |
-
# def view_favorites_frm():
|
| 54 |
-
# st.write("## Favorite Jobs")
|
| 55 |
-
# if 'favorites' in st.session_state and st.session_state['favorites']:
|
| 56 |
-
# for idx, job in enumerate(st.session_state['favorites']):
|
| 57 |
-
# st.write(f"## {idx+1}. {job['Title']}")
|
| 58 |
-
# st.write(f"### Description:")
|
| 59 |
-
# st.markdown(f"{job['Description'].replace('\r', '')}", unsafe_allow_html=True)
|
| 60 |
-
# st.write(f"### Requirements:")
|
| 61 |
-
# st.markdown(f"{job['Requirements'].replace('\r', '')}", unsafe_allow_html=True)
|
| 62 |
-
# st.write(f"### Location: {job['City']}, {job['State']}, {job['Country']}")
|
| 63 |
-
# if st.button('Back to recommendations'):
|
| 64 |
-
# st.session_state['view'] = 'home'
|
| 65 |
-
# else:
|
| 66 |
-
# st.write("No favorite jobs saved.")
|
| 67 |
-
# if st.button('Back to recommendations'):
|
| 68 |
-
# st.session_state['view'] = 'home'
|
| 69 |
-
|
| 70 |
def send_email(job):
|
| 71 |
# Dummy function to simulate email sending
|
| 72 |
st.success(f"Job details sent to your email: {job['Title']}")
|
|
@@ -93,10 +59,6 @@ def side_bar():
|
|
| 93 |
|
| 94 |
if st.sidebar.button('Home'):
|
| 95 |
st.session_state['view'] = 'home'
|
| 96 |
-
|
| 97 |
-
# Button to view favorite jobs
|
| 98 |
-
if st.sidebar.button('View Favorites'):
|
| 99 |
-
st.session_state['view'] = 'favorites'
|
| 100 |
|
| 101 |
st.sidebar.button('Logout', on_click=lambda: st.session_state.update({'authenticated': False}))
|
| 102 |
|
|
@@ -105,31 +67,31 @@ def home_frm():
|
|
| 105 |
|
| 106 |
col1, col2 = st.columns([1, 1])
|
| 107 |
# Job Search and Filter
|
| 108 |
-
hard_skills = col1.text_input('Hard Skill')
|
| 109 |
-
soft_skills = col2.text_input('Soft Skill')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
|
| 111 |
|
| 112 |
-
#
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
# st.markdown(f"{job['Description'][:300]}...", unsafe_allow_html=True)
|
| 124 |
-
# with ex_col2:
|
| 125 |
-
# st.button("Save to Favorites", on_click=save_favorite_job, args=(job,), key=f'save_{idx}')
|
| 126 |
-
# st.button("Email Job Details", on_click=send_email, args=(job,), key=f'email_{idx}')
|
| 127 |
-
# if st.button('View Job Details', key=f'view_{idx}'):
|
| 128 |
-
# st.session_state['view'] = 'details'
|
| 129 |
-
# st.session_state['job_index'] = job.name
|
| 130 |
-
# st.button("Export Recommendations", on_click=export_recommendations, args=(jobs,), key='export')
|
| 131 |
-
# else:
|
| 132 |
-
# st.write("No recommendations found.")
|
| 133 |
|
| 134 |
def prepare():
|
| 135 |
# Initialize session state
|
|
|
|
| 3 |
import os
|
| 4 |
|
| 5 |
# Load data
|
| 6 |
+
companies = pd.read_pickle('jobs-data.pkl')
|
| 7 |
similarity = pd.read_pickle('similarity.pkl')
|
| 8 |
|
| 9 |
# st.write("DataFrame Columns:", df.columns)
|
|
|
|
| 20 |
st.error("Invalid username or password")
|
| 21 |
|
| 22 |
# Recommendation Function
|
| 23 |
+
def recommendation(applicants, companies, similarity, num_recommendations=3):
|
| 24 |
try:
|
| 25 |
recommendations = {}
|
| 26 |
applicants['User ID'] = np.arange(len(applicants))
|
|
|
|
| 33 |
except IndexError:
|
| 34 |
return []
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
def send_email(job):
|
| 37 |
# Dummy function to simulate email sending
|
| 38 |
st.success(f"Job details sent to your email: {job['Title']}")
|
|
|
|
| 59 |
|
| 60 |
if st.sidebar.button('Home'):
|
| 61 |
st.session_state['view'] = 'home'
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
st.sidebar.button('Logout', on_click=lambda: st.session_state.update({'authenticated': False}))
|
| 64 |
|
|
|
|
| 67 |
|
| 68 |
col1, col2 = st.columns([1, 1])
|
| 69 |
# Job Search and Filter
|
| 70 |
+
hard_skills = col1.text_input('Hard Skill, separated by a comma') # hard_skills = "Python, Machine Learning, Data Analysis"
|
| 71 |
+
soft_skills = col2.text_input('Soft Skill, separated by a comma') # "Teamwork, Communication, Problem-solving"
|
| 72 |
+
|
| 73 |
+
applicants= {
|
| 74 |
+
'hard_skill': [
|
| 75 |
+
hard_skills
|
| 76 |
+
],
|
| 77 |
+
'soft_skill': [
|
| 78 |
+
soft_skills
|
| 79 |
+
]
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
|
| 83 |
|
| 84 |
+
# Get recommendations
|
| 85 |
+
if hard_skills and soft_skills:
|
| 86 |
+
jobs = recommendation(applicants)
|
| 87 |
+
jobs = jobs.tolist()
|
| 88 |
+
if jobs:
|
| 89 |
+
st.write("Recommended Jobs:")
|
| 90 |
+
for idx, job in enumerate(jobs):
|
| 91 |
+
with st.expander(f"{idx+1}. {job}"):
|
| 92 |
+
st.button("Export Recommendations", on_click=export_recommendations, args=(jobs,), key='export')
|
| 93 |
+
else:
|
| 94 |
+
st.write("No recommendations found.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
|
| 96 |
def prepare():
|
| 97 |
# Initialize session state
|