You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is the Recommendation Engine that will be used in building the Lunchbox App, a platform for ordering food and keeping track of user expenditure and canteen sales. Regardless of whether or not this is actually implemented in all the canteens of IIT Kanpur (given the potential for frauds & cyber-attacks) I will still complete the platform.
Also, I would be open-sourcing the app so that any campus can implement a cash-less & integrated system of ordering food across their whole campus. After all, what good are IITs for if our canteens still keep track of student accounts on paper registers!
Suggesting the items that are well-received and popular among the users. Most trending items and items with the best rating rise to the top and get shortlisted for recommendation.
importpandasaspdimportnumpyasnp# Importing db of food items across all canteens registered on the platformdf1=pd.read_csv('./db/food.csv')
df1.columns= ['food_id','title','canteen_id','price', 'num_orders', 'category', 'avg_rating', 'num_rating', 'tags']
df1
A bit more personalised recommendation. We will analyse the past orders of the user and suggest back those items which are similar.
Also, since each person has a "home canteen", the user should be notified of any new items included in the menu by the vendor.
We will be use Count Vectorizer from Scikit-Learn to find similarity between items based on their title, category and tags. To bring all these properties of each item together, we create a "soup" of tags. "Soup" is a processed string correspnding to each item, formed using the constituents of tags, tile and category.
food_id
title
canteen_id
price
num_orders
category
avg_rating
num_rating
tags
soup
0
1
Lala Maggi
1
30
35
maggi
3.9
10
veg, spicy
veg spicy lala maggi
1
2
Cheese Maggi
1
25
40
maggi
3.8
15
veg
veg cheese maggi
2
3
Masala Maggi
1
25
10
maggi
3.0
10
veg, spicy
veg spicy masala maggi
Using CountVectorizer from Scikit-Learn
# Import CountVectorizer and create the count matrixfromsklearn.feature_extraction.textimportCountVectorizercount=CountVectorizer(stop_words='english')
# df1['soup']count_matrix=count.fit_transform(df1['soup'])
# Compute the Cosine Similarity matrix based on the count_matrixfromsklearn.metrics.pairwiseimportcosine_similaritycosine_sim=cosine_similarity(count_matrix, count_matrix)
These are just simple algorithms to make personalised & general recommendations to users. We can easily use collaborative filtering or incorporate neural networks to make our prediction even better. However, these are more computationally intensive methods. Kinda overkill, IMO! Let's build that app first, then move on to other features!
Star the repository and send in your PRs if you think the engine needs any improvement or help me implement some more advanced features.