rushankg commited on
Commit
72f2133
·
1 Parent(s): e915650

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -5,8 +5,8 @@ import torch
5
  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
 
@@ -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_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,13 +51,13 @@ 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_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+")"
 
5
  import numpy as np
6
 
7
  cosine_scores = pickle.load(open('cosine_scores.pkl','rb'))
8
+ coursedf = pd.read_pickle('course_df_new.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
 
 
42
  course_id=coursedf.iloc[index,0]
43
  st.subheader(course_id+": "+result)
44
  with st.expander("See description"):
45
+ st.write(coursedf.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=coursedf.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(coursedf.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+")"