Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
import streamlit as st
|
2 |
from datasets import load_dataset
|
|
|
3 |
from transformers import pipeline
|
|
|
4 |
|
5 |
# Constants
|
6 |
universities_url = "https://www.4icu.org/top-universities-world/"
|
@@ -10,9 +12,12 @@ universities_url = "https://www.4icu.org/top-universities-world/"
|
|
10 |
def load_datasets():
|
11 |
ds_jobs = load_dataset("lukebarousse/data_jobs")
|
12 |
ds_courses = load_dataset("azrai99/coursera-course-dataset")
|
13 |
-
|
|
|
|
|
|
|
14 |
|
15 |
-
ds_jobs, ds_courses = load_datasets()
|
16 |
|
17 |
# Initialize the pipeline with caching, using an accessible model like 'google/flan-t5-large'
|
18 |
@st.cache_resource
|
@@ -34,55 +39,105 @@ soft_skills = st.sidebar.text_area("Soft Skills (e.g., Communication, Teamwork)"
|
|
34 |
|
35 |
# Save profile data for session-based recommendations
|
36 |
if st.sidebar.button("Save Profile"):
|
37 |
-
st.
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
44 |
|
45 |
# Intelligent Q&A Section
|
46 |
st.header("Intelligent Q&A")
|
47 |
question = st.text_input("Ask a career-related question:")
|
48 |
if question:
|
49 |
-
|
50 |
-
|
|
|
|
|
51 |
|
52 |
# Career and Job Recommendations Section
|
53 |
-
st.header("
|
54 |
if "profile_data" in st.session_state:
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
71 |
# Course Suggestions Section
|
72 |
-
st.header("
|
73 |
if "profile_data" in st.session_state:
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
|
87 |
# University Recommendations Section
|
88 |
st.header("Top Universities")
|
@@ -91,3 +146,7 @@ st.write(f"[View Top Universities Rankings]({universities_url})")
|
|
91 |
|
92 |
# Conclusion
|
93 |
st.write("Thank you for using the Career Counseling Application!")
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
from datasets import load_dataset
|
3 |
+
import pandas as pd
|
4 |
from transformers import pipeline
|
5 |
+
import time
|
6 |
|
7 |
# Constants
|
8 |
universities_url = "https://www.4icu.org/top-universities-world/"
|
|
|
12 |
def load_datasets():
|
13 |
ds_jobs = load_dataset("lukebarousse/data_jobs")
|
14 |
ds_courses = load_dataset("azrai99/coursera-course-dataset")
|
15 |
+
ds_custom_courses = pd.read_csv("final_cleaned_merged_coursera_courses.csv")
|
16 |
+
ds_custom_jobs = pd.read_csv("merged_data_science_jobs.csv")
|
17 |
+
ds_custom_universities = pd.read_csv("merged_university_data_cleaned (1).csv")
|
18 |
+
return ds_jobs, ds_courses, ds_custom_courses, ds_custom_jobs, ds_custom_universities
|
19 |
|
20 |
+
ds_jobs, ds_courses, ds_custom_courses, ds_custom_jobs, ds_custom_universities = load_datasets()
|
21 |
|
22 |
# Initialize the pipeline with caching, using an accessible model like 'google/flan-t5-large'
|
23 |
@st.cache_resource
|
|
|
39 |
|
40 |
# Save profile data for session-based recommendations
|
41 |
if st.sidebar.button("Save Profile"):
|
42 |
+
with st.spinner('Saving your profile...'):
|
43 |
+
time.sleep(2) # Simulate processing time
|
44 |
+
st.session_state.profile_data = {
|
45 |
+
"educational_background": educational_background,
|
46 |
+
"interests": interests,
|
47 |
+
"tech_skills": tech_skills,
|
48 |
+
"soft_skills": soft_skills
|
49 |
+
}
|
50 |
+
st.sidebar.success("Profile saved successfully!")
|
51 |
|
52 |
# Intelligent Q&A Section
|
53 |
st.header("Intelligent Q&A")
|
54 |
question = st.text_input("Ask a career-related question:")
|
55 |
if question:
|
56 |
+
with st.spinner('Processing your question...'):
|
57 |
+
answer = qa_pipeline(question)[0]["generated_text"]
|
58 |
+
time.sleep(2) # Simulate processing time
|
59 |
+
st.write("Answer:", answer)
|
60 |
|
61 |
# Career and Job Recommendations Section
|
62 |
+
st.header("Job Recommendations")
|
63 |
if "profile_data" in st.session_state:
|
64 |
+
with st.spinner('Generating job recommendations...'):
|
65 |
+
time.sleep(2) # Simulate processing time
|
66 |
+
job_recommendations = []
|
67 |
+
|
68 |
+
# Find jobs from ds_jobs
|
69 |
+
for job in ds_jobs["train"]:
|
70 |
+
job_title = job.get("job_title_short", "Unknown Job Title")
|
71 |
+
job_skills = job.get("job_skills", "") or ""
|
72 |
+
if any(skill.lower() in job_skills.lower() for skill in st.session_state.profile_data["tech_skills"].split(",")):
|
73 |
+
job_recommendations.append(job_title)
|
74 |
+
|
75 |
+
# Find jobs from ds_custom_jobs
|
76 |
+
for _, job in ds_custom_jobs.iterrows():
|
77 |
+
job_title = job.get("job_title", "Unknown Job Title")
|
78 |
+
job_skills = job.get("skills", "") or ""
|
79 |
+
if any(skill.lower() in job_skills.lower() for skill in st.session_state.profile_data["tech_skills"].split(",")):
|
80 |
+
job_recommendations.append(job_title)
|
81 |
+
|
82 |
+
# Remove duplicates and keep the unique job titles
|
83 |
+
job_recommendations = list(set(job_recommendations))
|
84 |
+
|
85 |
+
if job_recommendations:
|
86 |
+
st.subheader("Based on your profile, here are some potential job roles:")
|
87 |
+
for job in job_recommendations[:5]: # Limit to top 5 job recommendations
|
88 |
+
st.write("- ", job)
|
89 |
+
else:
|
90 |
+
st.write("No specific job recommendations found matching your profile. Here are some general recommendations:")
|
91 |
+
for job in ["Data Analyst", "Software Engineer", "Project Manager", "Research Scientist", "Business Analyst"][:5]:
|
92 |
+
st.write("- ", job)
|
93 |
|
94 |
# Course Suggestions Section
|
95 |
+
st.header("Recommended Courses")
|
96 |
if "profile_data" in st.session_state:
|
97 |
+
with st.spinner('Finding courses related to your profile...'):
|
98 |
+
time.sleep(2) # Simulate processing time
|
99 |
+
course_recommendations = []
|
100 |
+
|
101 |
+
# Find relevant courses in ds_courses
|
102 |
+
for course in ds_courses["train"]:
|
103 |
+
if any(interest.lower() in course.get("Course Name", "").lower() for interest in st.session_state.profile_data["interests"].split(",")):
|
104 |
+
course_recommendations.append({
|
105 |
+
"name": course.get("Course Name", "Unknown Course Title"),
|
106 |
+
"url": course.get("Links", "#")
|
107 |
+
})
|
108 |
+
|
109 |
+
# Find relevant courses in ds_custom_courses
|
110 |
+
for _, row in ds_custom_courses.iterrows():
|
111 |
+
if any(interest.lower() in row["Course Name"].lower() for interest in st.session_state.profile_data["interests"].split(",")):
|
112 |
+
course_recommendations.append({
|
113 |
+
"name": row["Course Name"],
|
114 |
+
"url": row.get("Links", "#")
|
115 |
+
})
|
116 |
+
|
117 |
+
# Remove duplicates from course recommendations by converting to a set of tuples and back to a list
|
118 |
+
course_recommendations = list({(course["name"], course["url"]) for course in course_recommendations})
|
119 |
+
|
120 |
+
# If there are fewer than 5 exact matches, add nearly related courses
|
121 |
+
if len(course_recommendations) < 5:
|
122 |
+
for course in ds_courses["train"]:
|
123 |
+
if len(course_recommendations) >= 5:
|
124 |
+
break
|
125 |
+
if any(skill.lower() in course.get("Course Name", "").lower() for skill in st.session_state.profile_data["tech_skills"].split(",")):
|
126 |
+
course_recommendations.append((course.get("Course Name", "Unknown Course Title"), course.get("Links", "#")))
|
127 |
+
|
128 |
+
for _, row in ds_custom_courses.iterrows():
|
129 |
+
if len(course_recommendations) >= 5:
|
130 |
+
break
|
131 |
+
if any(skill.lower() in row["Course Name"].lower() for skill in st.session_state.profile_data["tech_skills"].split(",")):
|
132 |
+
course_recommendations.append((row["Course Name"], row.get("Links", "#")))
|
133 |
+
|
134 |
+
# Remove duplicates again after adding nearly related courses
|
135 |
+
course_recommendations = list({(name, url) for name, url in course_recommendations})
|
136 |
+
|
137 |
+
if course_recommendations:
|
138 |
+
st.write("Here are the top 5 courses related to your interests:")
|
139 |
+
for course in course_recommendations[:5]: # Limit to top 5 course recommendations
|
140 |
+
st.write(f"- [{course[0]}]({course[1]})")
|
141 |
|
142 |
# University Recommendations Section
|
143 |
st.header("Top Universities")
|
|
|
146 |
|
147 |
# Conclusion
|
148 |
st.write("Thank you for using the Career Counseling Application!")
|
149 |
+
'''
|
150 |
+
|
151 |
+
with open('app.py', 'w') as f:
|
152 |
+
f.write(code)
|