Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,13 +6,15 @@ import time
|
|
6 |
# Load datasets from CSV files
|
7 |
@st.cache_resource
|
8 |
def load_csv_datasets():
|
9 |
-
jobs_data = pd.read_csv("
|
10 |
courses_data = pd.read_csv("courses_data.csv")
|
11 |
return jobs_data, courses_data
|
12 |
|
13 |
jobs_data, courses_data = load_csv_datasets()
|
|
|
14 |
# Constants
|
15 |
universities_url = "https://www.4icu.org/top-universities-world/"
|
|
|
16 |
# Initialize the text generation pipeline
|
17 |
@st.cache_resource
|
18 |
def load_pipeline():
|
@@ -126,26 +128,64 @@ if "profile_data" in st.session_state:
|
|
126 |
# Extracting user profile data
|
127 |
profile = st.session_state.profile_data
|
128 |
user_tech_skills = set(skill.strip().lower() for skill in profile["tech_skills"].split(","))
|
|
|
129 |
user_interests = set(interest.strip().lower() for interest in profile["interests"].split(","))
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
|
136 |
# Course Recommendations using RAG technique
|
137 |
course_recommendations = courses_data[courses_data['Course Name'].apply(
|
138 |
lambda name: any(interest in name.lower() for interest in user_interests)
|
139 |
)]
|
140 |
|
141 |
-
# Display Job Recommendations
|
142 |
-
st.subheader("Job Recommendations")
|
143 |
-
if not job_recommendations.empty:
|
144 |
-
for _, row in job_recommendations.head(5).iterrows():
|
145 |
-
st.write(f"- **{row['Job Title']}**: {row['Description']}")
|
146 |
-
else:
|
147 |
-
st.write("No specific job recommendations found matching your profile.")
|
148 |
-
|
149 |
# Display Course Recommendations
|
150 |
st.subheader("Recommended Courses")
|
151 |
if not course_recommendations.empty:
|
@@ -155,7 +195,6 @@ if "profile_data" in st.session_state:
|
|
155 |
st.write("No specific course recommendations found matching your interests.")
|
156 |
st.write("Here are some general course recommendations aligned with your profile:")
|
157 |
|
158 |
-
# Suggest 3 fallback courses aligned with the user's educational background or technical skills
|
159 |
fallback_courses = courses_data[
|
160 |
courses_data['Course Name'].apply(
|
161 |
lambda name: any(
|
@@ -174,6 +213,6 @@ if "profile_data" in st.session_state:
|
|
174 |
# University Recommendations Section
|
175 |
st.header("Top Universities")
|
176 |
st.write("For further education, you can explore the top universities worldwide:")
|
177 |
-
st.write(f"[View Top Universities Rankings]({universities_url})")
|
178 |
|
179 |
st.write("Thank you for using the Career Counseling Application with RAG!")
|
|
|
6 |
# Load datasets from CSV files
|
7 |
@st.cache_resource
|
8 |
def load_csv_datasets():
|
9 |
+
jobs_data = pd.read_csv("job_descriptions.csv")
|
10 |
courses_data = pd.read_csv("courses_data.csv")
|
11 |
return jobs_data, courses_data
|
12 |
|
13 |
jobs_data, courses_data = load_csv_datasets()
|
14 |
+
|
15 |
# Constants
|
16 |
universities_url = "https://www.4icu.org/top-universities-world/"
|
17 |
+
|
18 |
# Initialize the text generation pipeline
|
19 |
@st.cache_resource
|
20 |
def load_pipeline():
|
|
|
128 |
# Extracting user profile data
|
129 |
profile = st.session_state.profile_data
|
130 |
user_tech_skills = set(skill.strip().lower() for skill in profile["tech_skills"].split(","))
|
131 |
+
user_soft_skills = set(skill.strip().lower() for skill in profile["soft_skills"].split(","))
|
132 |
user_interests = set(interest.strip().lower() for interest in profile["interests"].split(","))
|
133 |
+
user_answers = st.session_state.get('answers', {})
|
134 |
+
|
135 |
+
# Job Recommendations using refined scoring logic
|
136 |
+
def match_job_criteria(row, profile, user_answers):
|
137 |
+
job_title = row['Job Title'].lower()
|
138 |
+
job_description = row['Job Description'].lower()
|
139 |
+
qualifications = row['Qualifications'].lower()
|
140 |
+
skills = row['skills'].lower()
|
141 |
+
role = row['Role'].lower()
|
142 |
+
|
143 |
+
educational_background = profile['educational_background'].lower()
|
144 |
+
tech_skills = set(skill.strip().lower() for skill in profile["tech_skills"].split(","))
|
145 |
+
soft_skills = set(skill.strip().lower() for skill in profile["soft_skills"].split(","))
|
146 |
+
interests = set(interest.strip().lower() for interest in profile["interests"].split(","))
|
147 |
+
user_answers_text = ' '.join(user_answers.values()).lower()
|
148 |
+
|
149 |
+
score = 0
|
150 |
+
|
151 |
+
if educational_background in qualifications or educational_background in job_description:
|
152 |
+
score += 2
|
153 |
+
if any(skill in skills for skill in tech_skills):
|
154 |
+
score += 3
|
155 |
+
if any(skill in job_description or role for skill in soft_skills):
|
156 |
+
score += 1
|
157 |
+
if any(interest in job_title or job_description for interest in interests):
|
158 |
+
score += 2
|
159 |
+
if any(answer in job_description or qualifications for answer in user_answers_text.split()):
|
160 |
+
score += 2
|
161 |
+
|
162 |
+
return score >= 5
|
163 |
+
|
164 |
+
# Get unique job recommendations
|
165 |
+
job_recommendations = jobs_data[jobs_data.apply(lambda row: match_job_criteria(row, profile, user_answers), axis=1)]
|
166 |
+
unique_jobs = job_recommendations.drop_duplicates(subset=['Job Title'])
|
167 |
+
|
168 |
+
# Display Job Recommendations in a table with bullet points
|
169 |
+
st.subheader("Job Recommendations")
|
170 |
+
if not unique_jobs.empty:
|
171 |
+
job_list = unique_jobs.head(5)[['Job Title', 'Job Description']].reset_index(drop=True)
|
172 |
+
job_list.index += 1 # Start index from 1
|
173 |
+
job_list.columns = ["Job Title", "Description"]
|
174 |
+
st.table(job_list)
|
175 |
+
else:
|
176 |
+
st.write("No specific job recommendations found matching your profile.")
|
177 |
+
st.write("Here are some general job recommendations:")
|
178 |
+
fallback_jobs = jobs_data.drop_duplicates(subset=['Job Title']).head(3)
|
179 |
+
fallback_list = fallback_jobs[['Job Title', 'Job Description']].reset_index(drop=True)
|
180 |
+
fallback_list.index += 1 # Start index from 1
|
181 |
+
fallback_list.columns = ["Job Title", "Description"]
|
182 |
+
st.table(fallback_list)
|
183 |
|
184 |
# Course Recommendations using RAG technique
|
185 |
course_recommendations = courses_data[courses_data['Course Name'].apply(
|
186 |
lambda name: any(interest in name.lower() for interest in user_interests)
|
187 |
)]
|
188 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
# Display Course Recommendations
|
190 |
st.subheader("Recommended Courses")
|
191 |
if not course_recommendations.empty:
|
|
|
195 |
st.write("No specific course recommendations found matching your interests.")
|
196 |
st.write("Here are some general course recommendations aligned with your profile:")
|
197 |
|
|
|
198 |
fallback_courses = courses_data[
|
199 |
courses_data['Course Name'].apply(
|
200 |
lambda name: any(
|
|
|
213 |
# University Recommendations Section
|
214 |
st.header("Top Universities")
|
215 |
st.write("For further education, you can explore the top universities worldwide:")
|
216 |
+
st.write(f"[View Top Universities Rankings]({universities_url})")
|
217 |
|
218 |
st.write("Thank you for using the Career Counseling Application with RAG!")
|