rushankg commited on
Commit
38e0a38
·
1 Parent(s): b25a689

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -6,13 +6,13 @@ import numpy as np
6
 
7
  cosine_scores = pickle.load(open('cosine_scores.pkl','rb'))
8
  coursedf = pd.read_pickle('course_df.pkl') # course_df uses titles to generate course recommendations
9
- #course_df_new = pd.read_pickle('course_df_new.pkl') #course_df_new makes recommendations using the entire description
10
 
11
  course_title_list = [i + ": " + j for i, j in zip(coursedf['ref'].to_list(), coursedf['title'].to_list())]
12
 
13
  def get_random_course():
14
  row=coursedf.sample(1)
15
- return row['ref']+": "+row['title']
16
 
17
  def recommend(index):
18
  pairs = {}
@@ -42,7 +42,7 @@ if maincol1.button('Recommend by title',use_container_width=True):
42
  course_id=coursedf.iloc[index,0]
43
  st.subheader(course_id+": "+result)
44
  with st.expander("See description"):
45
- st.write(course_df.iloc[index,3]) #Using the new coursedf because it has proper descriptions for each course
46
  link = "[ExploreCourses](https://explorecourses.stanford.edu/search?q="+course_id+"+"+result.replace(" ","+")+")"
47
  st.markdown(link, unsafe_allow_html=True)
48
  link = "[Carta](https://carta-beta.stanford.edu/results/"+course_id+")"
@@ -51,17 +51,17 @@ if maincol1.button('Recommend by title',use_container_width=True):
51
 
52
  if maincol2.button('Recommend by description',use_container_width=True):
53
  index_new=np.where((coursedf['ref']+": "+coursedf['title']) == selected_course)[0][0]
54
- rec_list=course_df.iloc[index_new,2]
55
- for result in rec_list[1:]:
56
  index=np.where(coursedf['title'] == result)[0][0]
57
  course_id=coursedf.iloc[index,0]
58
  st.subheader(course_id+": "+result)
59
  with st.expander("See description"):
60
- st.write(course_df.iloc[index,3]) #Using the new coursedf because it has proper descriptions for each course
61
  link = "[ExploreCourses](https://explorecourses.stanford.edu/search?q="+course_id+"+"+result.replace(" ","+")+")"
62
  st.markdown(link, unsafe_allow_html=True)
63
  link = "[Carta](https://carta-beta.stanford.edu/results/"+course_id+")"
64
  st.markdown(link, unsafe_allow_html=True)
65
  st.divider()
66
 
67
- st.write('© 2023 Rushank Goyal. All rights reserved. Source for the all-MiniLM-L6-v2 model: Wang, Wenhui, et al. "MiniLM: Deep Self-Attention Distillation for Task-Agnostic Compression of Pre-Trained Transformers." arXiv, 25 Feb. 2020, doi:10.48550/arXiv.2002.10957.')
 
6
 
7
  cosine_scores = pickle.load(open('cosine_scores.pkl','rb'))
8
  coursedf = pd.read_pickle('course_df.pkl') # course_df uses titles to generate course recommendations
9
+ course_df_new = pd.read_pickle('course_df_new.pkl') #course_df_new makes recommendations using the entire description
10
 
11
  course_title_list = [i + ": " + j for i, j in zip(coursedf['ref'].to_list(), coursedf['title'].to_list())]
12
 
13
  def get_random_course():
14
  row=coursedf.sample(1)
15
+ return row['ref'], row['title']
16
 
17
  def recommend(index):
18
  pairs = {}
 
42
  course_id=coursedf.iloc[index,0]
43
  st.subheader(course_id+": "+result)
44
  with st.expander("See description"):
45
+ st.write(course_df_new.iloc[index,3]) #Using the new coursedf because it has proper descriptions for each course
46
  link = "[ExploreCourses](https://explorecourses.stanford.edu/search?q="+course_id+"+"+result.replace(" ","+")+")"
47
  st.markdown(link, unsafe_allow_html=True)
48
  link = "[Carta](https://carta-beta.stanford.edu/results/"+course_id+")"
 
51
 
52
  if maincol2.button('Recommend by description',use_container_width=True):
53
  index_new=np.where((coursedf['ref']+": "+coursedf['title']) == selected_course)[0][0]
54
+ rec_list=course_df_new.iloc[index_new,2]
55
+ for result in rec_list:
56
  index=np.where(coursedf['title'] == result)[0][0]
57
  course_id=coursedf.iloc[index,0]
58
  st.subheader(course_id+": "+result)
59
  with st.expander("See description"):
60
+ st.write(course_df_new.iloc[index,3]) #Using the new coursedf because it has proper descriptions for each course
61
  link = "[ExploreCourses](https://explorecourses.stanford.edu/search?q="+course_id+"+"+result.replace(" ","+")+")"
62
  st.markdown(link, unsafe_allow_html=True)
63
  link = "[Carta](https://carta-beta.stanford.edu/results/"+course_id+")"
64
  st.markdown(link, unsafe_allow_html=True)
65
  st.divider()
66
 
67
+ st.write('© 2023 Rushank Goyal. All rights reserved. Source for the all-MiniLM-L6-v2 model: Wang, Wenhui, et al. "MiniLM: Deep Self-Attention Distillation for Task-Agnostic Compression of Pre-Trained Transformers." arXiv, 25 Feb. 2020, doi:10.48550/arXiv.2002.10957.')