Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import difflib
|
| 3 |
+
|
| 4 |
+
# Assuming you have 'lpi_df' and 'similarity' defined before this point
|
| 5 |
+
|
| 6 |
+
st.title('Course Recommendation App')
|
| 7 |
+
|
| 8 |
+
user_input = st.text_input('Enter What You Want to Learn : ')
|
| 9 |
+
|
| 10 |
+
if user_input:
|
| 11 |
+
list_of_all_titles = lpi_df['Module'].tolist()
|
| 12 |
+
find_close_match = difflib.get_close_matches(user_input, list_of_all_titles)
|
| 13 |
+
|
| 14 |
+
if find_close_match:
|
| 15 |
+
close_match = find_close_match[0]
|
| 16 |
+
index_of_the_course = lpi_df[lpi_df.Module == close_match].index.values[0]
|
| 17 |
+
similarity_score = list(enumerate(similarity[index_of_the_course]))
|
| 18 |
+
sorted_similar_course = sorted(similarity_score, key=lambda x: x[1], reverse=True)
|
| 19 |
+
|
| 20 |
+
st.write('Courses suggested for you :')
|
| 21 |
+
|
| 22 |
+
i = 1
|
| 23 |
+
for course in sorted_similar_course:
|
| 24 |
+
index = course[0]
|
| 25 |
+
title_from_index = lpi_df[lpi_df.index == index]['Module'].values[0]
|
| 26 |
+
if i < 30:
|
| 27 |
+
st.write(f"{i}. {title_from_index}")
|
| 28 |
+
i += 1
|
| 29 |
+
|
| 30 |
+
if i == 1:
|
| 31 |
+
st.write('No close matches found.')
|
| 32 |
+
else:
|
| 33 |
+
st.write('No close matches found.')
|
| 34 |
+
|