Spaces:
Build error
Build error
Hong
commited on
Commit
•
08af8da
1
Parent(s):
71dd65b
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import json
|
4 |
+
from utils import (
|
5 |
+
get_prob,
|
6 |
+
device,
|
7 |
+
get_prob_lists,
|
8 |
+
compare_sentence,
|
9 |
+
query_jds,
|
10 |
+
query,
|
11 |
+
tfidf_score,
|
12 |
+
tfidf_matrix,
|
13 |
+
)
|
14 |
+
from ast import literal_eval
|
15 |
+
from stqdm import stqdm
|
16 |
+
|
17 |
+
with open("data/joblists.txt") as file:
|
18 |
+
lines = file.readlines()
|
19 |
+
jobs = [line.rstrip() for line in lines]
|
20 |
+
|
21 |
+
DB = pd.read_csv("data/JDs_final.csv").dropna()
|
22 |
+
data = pd.read_csv("data/processed_courses_data.csv")
|
23 |
+
|
24 |
+
|
25 |
+
def get_recommendation(DB, data, jobname, by="course_info"):
|
26 |
+
JD_sentences = query_jds(DB, jobname).description.values
|
27 |
+
DB["Query_Score"] = DB.description.progress_apply(
|
28 |
+
lambda x: compare_sentence(x, jobs[0])
|
29 |
+
)
|
30 |
+
target = DB.sort_values(by="Query_Score", ascending=False)[:10]
|
31 |
+
JD_sentences = target.description.values
|
32 |
+
data["Recommendation_score"] = data[by].progress_apply(
|
33 |
+
lambda x: compare_sentence(x, JD_sentences)
|
34 |
+
)
|
35 |
+
return data.sort_values(by="Recommendation_score", ascending=False)[:26][
|
36 |
+
["Course_Name", "course_info", "syllabus", "div", "Recommendation_score"]
|
37 |
+
]
|
38 |
+
|
39 |
+
|
40 |
+
st.title("Course Recommender🤔")
|
41 |
+
|
42 |
+
if device == "cpu":
|
43 |
+
processor = "🖥️"
|
44 |
+
else:
|
45 |
+
processor = "💽"
|
46 |
+
|
47 |
+
option = st.checkbox("💻From referece IT jobs?")
|
48 |
+
if option:
|
49 |
+
job = st.selectbox("Choose your job", jobs)
|
50 |
+
|
51 |
+
else:
|
52 |
+
job = st.text_input("Put job you are interested")
|
53 |
+
|
54 |
+
btn = st.button("Run recommendation!")
|
55 |
+
stqdm.pandas()
|
56 |
+
|
57 |
+
if btn:
|
58 |
+
with st.spinner("⌛Generating Recommendation!"):
|
59 |
+
recommendation = get_recommendation(DB, data, job)
|
60 |
+
st.success("Recommended course for {} ".format(job))
|
61 |
+
st.write(recommendation)
|