Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,60 @@
|
|
1 |
import streamlit as st
|
2 |
import difflib
|
3 |
import pandas as pd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
# Assuming you have 'lpi_df' and 'similarity' defined before this point
|
6 |
|
7 |
lpi_df = pd.read_csv('Learning_Pathway_Index.csv')
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
st.title('Course Recommendation App')
|
11 |
|
|
|
1 |
import streamlit as st
|
2 |
import difflib
|
3 |
import pandas as pd
|
4 |
+
import numpy as np
|
5 |
+
import matplotlib.pyplot as plt
|
6 |
+
import seaborn as sns
|
7 |
+
import plotly.express as px
|
8 |
+
import warnings
|
9 |
+
warnings.filterwarnings("ignore")
|
10 |
+
%matplotlib inline
|
11 |
+
|
12 |
+
|
13 |
+
# for text data preprocessing
|
14 |
+
import re
|
15 |
+
from nltk.corpus import stopwords
|
16 |
+
from nltk.stem.porter import PorterStemmer
|
17 |
+
from wordcloud import WordCloud
|
18 |
+
from sklearn.feature_extraction.text import TfidfVectorizer
|
19 |
+
from sklearn.metrics.pairwise import cosine_similarity
|
20 |
|
21 |
# Assuming you have 'lpi_df' and 'similarity' defined before this point
|
22 |
|
23 |
lpi_df = pd.read_csv('Learning_Pathway_Index.csv')
|
24 |
|
25 |
+
lpi_df['combined_features'] = lpi_df['Course_Learning_Material']+' '+lpi_df['Source']+' '+lpi_df['Course_Level']+' '+lpi_df['Type']+' '+lpi_df['Module']+' '+lpi_df['Difficulty_Level']+' '+lpi_df['Keywords_Tags_Skills_Interests_Categories']
|
26 |
+
|
27 |
+
combined_features = lpi_df['combined_features']
|
28 |
+
|
29 |
+
porter_stemmer = PorterStemmer()
|
30 |
+
|
31 |
+
|
32 |
+
def stemming(content):
|
33 |
+
stemmed_content = re.sub('[^a-zA-Z]',' ',content)
|
34 |
+
stemmed_content = stemmed_content.lower()
|
35 |
+
stemmed_content = stemmed_content.split()
|
36 |
+
stemmed_content = [porter_stemmer.stem(word) for word in stemmed_content if not word in stopwords.words('english')]
|
37 |
+
stemmed_content = ' '.join(stemmed_content)
|
38 |
+
return stemmed_content
|
39 |
+
|
40 |
+
combined_features = combined_features.apply(stemming)
|
41 |
+
|
42 |
+
|
43 |
+
vectorizer = TfidfVectorizer()
|
44 |
+
|
45 |
+
vectorizer.fit(combined_features)
|
46 |
+
|
47 |
+
combined_features = vectorizer.transform(combined_features)
|
48 |
+
|
49 |
+
similarity = cosine_similarity(combined_features)
|
50 |
+
|
51 |
+
|
52 |
+
|
53 |
+
|
54 |
+
|
55 |
+
|
56 |
+
|
57 |
+
|
58 |
|
59 |
st.title('Course Recommendation App')
|
60 |
|