wahab5763 commited on
Commit
d2fb654
·
verified ·
1 Parent(s): cf6bf4f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +111 -0
app.py ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ from datasets import load_dataset
4
+ from transformers import pipeline
5
+
6
+ # Constants
7
+ universities_url = "https://www.4icu.org/top-universities-world/"
8
+
9
+ # Load datasets with caching to optimize performance
10
+ @st.cache_resource
11
+ def load_datasets():
12
+ ds_jobs = load_dataset("lukebarousse/data_jobs")
13
+ ds_courses = load_dataset("azrai99/coursera-course-dataset")
14
+ ds_custom_courses = pd.read_csv("final_cleaned_merged_coursera_courses.csv")
15
+ ds_custom_jobs = pd.read_csv("merged_data_science_jobs.csv")
16
+ ds_custom_universities = pd.read_csv("merged_university_data_cleaned (1).csv")
17
+ return ds_jobs, ds_courses, ds_custom_courses, ds_custom_jobs, ds_custom_universities
18
+
19
+ ds_jobs, ds_courses, ds_custom_courses, ds_custom_jobs, ds_custom_universities = load_datasets()
20
+
21
+ # Initialize the pipeline with caching, using an accessible model like 'google/flan-t5-large'
22
+ @st.cache_resource
23
+ def load_pipeline():
24
+ return pipeline("text2text-generation", model="google/flan-t5-large")
25
+
26
+ qa_pipeline = load_pipeline()
27
+
28
+ # Streamlit App Interface
29
+ st.title("Career Counseling Application")
30
+ st.subheader("Build Your Profile and Discover Tailored Career Recommendations")
31
+
32
+ # Sidebar for Profile Setup
33
+ st.sidebar.header("Profile Setup")
34
+ educational_background = st.sidebar.text_input("Educational Background (e.g., Degree, Major)")
35
+ interests = st.sidebar.text_input("Interests (e.g., AI, Data Science, Engineering)")
36
+ tech_skills = st.sidebar.text_area("Technical Skills (e.g., Python, SQL, Machine Learning)")
37
+ soft_skills = st.sidebar.text_area("Soft Skills (e.g., Communication, Teamwork)")
38
+
39
+ # Save profile data for session-based recommendations
40
+ if st.sidebar.button("Save Profile"):
41
+ st.session_state.profile_data = {
42
+ "educational_background": educational_background,
43
+ "interests": interests,
44
+ "tech_skills": tech_skills,
45
+ "soft_skills": soft_skills
46
+ }
47
+ st.sidebar.success("Profile saved successfully!")
48
+
49
+ # Intelligent Q&A Section
50
+ st.header("Intelligent Q&A")
51
+ question = st.text_input("Ask a career-related question:")
52
+ if question:
53
+ answer = qa_pipeline(question)[0]["generated_text"]
54
+ st.write("Answer:", answer)
55
+
56
+ # Career and Job Recommendations Section
57
+ st.header("Career and Job Recommendations")
58
+ if "profile_data" in st.session_state:
59
+ job_recommendations = []
60
+ for job in ds_jobs["train"]:
61
+ job_skills = job.get("job_skills", "") or ""
62
+ if any(skill.lower() in job_skills.lower() for skill in st.session_state.profile_data["tech_skills"].split(",")):
63
+ job_recommendations.append(job.get("job_title_short", "Unknown Job Title"))
64
+
65
+ for _, job in ds_custom_jobs.iterrows():
66
+ job_skills = job.get("skills", "") or ""
67
+ if any(skill.lower() in job_skills.lower() for skill in st.session_state.profile_data["tech_skills"].split(",")):
68
+ job_recommendations.append(job.get("job_title", "Unknown Job Title"))
69
+
70
+ if job_recommendations:
71
+ st.subheader("Job Recommendations")
72
+ st.write("Based on your profile, here are some potential job roles:")
73
+ for job in job_recommendations[:5]: # Limit to top 5 job recommendations
74
+ st.write("- ", job)
75
+ else:
76
+ st.write("No specific job recommendations found matching your profile.")
77
+
78
+ # Course Suggestions Section
79
+ st.header("Course Suggestions")
80
+ if "profile_data" in st.session_state:
81
+ course_recommendations = [
82
+ course.get("Title", "Unknown Course Title") for course in ds_courses["train"]
83
+ if any(interest.lower() in course.get("Title", "").lower() for interest in st.session_state.profile_data["interests"].split(","))
84
+ ]
85
+
86
+ course_recommendations.extend([
87
+ row["course_title"] for _, row in ds_custom_courses.iterrows()
88
+ if any(interest.lower() in row["course_title"].lower() for interest in st.session_state.profile_data["interests"].split(","))
89
+ ])
90
+
91
+ if course_recommendations:
92
+ st.subheader("Recommended Courses")
93
+ st.write("Here are some courses related to your interests:")
94
+ for course in course_recommendations[:5]: # Limit to top 5 course recommendations
95
+ st.write("- ", course)
96
+ else:
97
+ st.write("No specific courses found matching your interests.")
98
+
99
+ # University Recommendations Section
100
+ st.header("Top Universities")
101
+ st.write("For further education, you can explore the top universities worldwide:")
102
+ st.write(f"[View Top Universities Rankings]({universities_url})")
103
+
104
+ st.subheader("Custom University Data")
105
+ if not ds_custom_universities.empty:
106
+ st.write("Here are some recommended universities based on custom data:")
107
+ st.dataframe(ds_custom_universities.head())
108
+
109
+ # Conclusion
110
+ st.write("Thank you for using the Career Counseling Application!")
111
+