Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,27 @@ Ending Credits
- Made using Python and Streamlit
- @Author : [Sagar Bapodara](https://www.linkedin.com/in/sagar-bapodara/)


# Contribution
The contributed project is made on Flask Framework, which is combination of the the original project of Sagar Bapodara & the final year students of Shah and Anchor Kutchhi Engineering college.

## 🔗 Contributors
[[Nimit More]](https://github.com/nimitmore27)

[[Shradha Jaiswal]](https://github.com/Jaiswalshradha)

[[Shrushti Thakur]](https://github.com/shrushti0502)

[[Hetal Paramar]](https://github.com/Hetsss)

### Demo
Clone this repository or Download the files into your local system.

- Extract the ZIP file (if you directly download from Github Web)
- Make sure all the files are in the same folder/directory
- Open your Command Prompt (CMD) in the same directory
- Type the following command (for web app) :

```bash
python app.py
```
68 changes: 68 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics.pairwise import linear_kernel
from flask import Flask,request,render_template
import pickle

app=Flask(__name__)
# Contributed Code
with open("./models/combined_df.pkl","rb") as f:
combined_df=pickle.load(f)

courses = combined_df[['Course Name', 'Course Description']].to_dict(orient='records')
tfidf = TfidfVectorizer(stop_words='english')
tfidf_matrix = tfidf.fit_transform([course['Course Description'] for course in courses])

def get_recommendations(user_description, n=5):
recommended_courses = []
course_title = ''
user_vector = tfidf.transform([user_description])
cosine_sim = linear_kernel(user_vector, tfidf_matrix)
for idx in cosine_sim.argsort()[0][::-1][:n]:
course_title = courses[idx]['Course Name']
recommended_courses.append(course_title)
filtered_df = combined_df[combined_df['Course Name'].isin(recommended_courses)]
return filtered_df

# Sagar Bapodara Code
courses_list = pickle.load(open('./models/courses.pkl','rb'))
similarity = pickle.load(open('./models/similarity.pkl','rb'))

def recommend(course):
index = courses_list[courses_list['course_name'] == course].index[0]
distances = sorted(list(enumerate(similarity[index])), reverse=True, key=lambda x: x[1])
recommended_course_names = []
for i in distances[1:7]:
course_name = courses_list.iloc[i[0]].course_name
recommended_course_names.append(course_name)

return recommended_course_names

# Routings
@app.route("/", methods=["GET","POST"])
def index():
if request.method == "POST":
des = request.form.get("des")
num = request.form.get("num")
if not num:
num = 5
recommendations = get_recommendations(des,int(num))
params={"title":"Home", "result":{'active':True,"data" : recommendations}}
return render_template("index.html", params=params)
params={"title":"Home","result":{'active':False}}
return render_template("index.html", params=params)


@app.route('/SagarBapodara',methods=['GET','POST'])
def main():
course_list = courses_list['course_name'].values
if request.method == "POST":
des = request.form.get("des")
recommended_course_names = recommend(des)
params={"title":"Home", "result":{'active':True,"data" : recommended_course_names},"course_list":course_list}
return render_template('sagar.html',params=params)
params = {"titile":"Sagar Bapodara's Project", "result":{'active':False}, "course_list":course_list}
return render_template('sagar.html',params=params)


if __name__ == "__main__":
app.run(debug=True)
3,533 changes: 3,533 additions & 0 deletions datasets/Coursera.csv

Large diffs are not rendered by default.

7,122 changes: 7,122 additions & 0 deletions datasets/combined_df.csv

Large diffs are not rendered by default.

Loading