https://github.com/fyt3rp4til/mood-based-food-recommender-zomato-dataset
https://github.com/fyt3rp4til/mood-based-food-recommender-zomato-dataset
kmeans-clustering natural-language-processing nltk numpy pandas sklearn stopwords wordnetlemmatizer
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/fyt3rp4til/mood-based-food-recommender-zomato-dataset
- Owner: FYT3RP4TIL
- Created: 2024-11-21T10:15:55.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-11-21T10:38:58.000Z (6 months ago)
- Last Synced: 2025-03-17T04:48:15.326Z (about 2 months ago)
- Topics: kmeans-clustering, natural-language-processing, nltk, numpy, pandas, sklearn, stopwords, wordnetlemmatizer
- Language: Jupyter Notebook
- Homepage:
- Size: 1.84 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# π½οΈ Mood-Driven Food Recommender - Zomato Dataset
## π― Project Overview
This data science project explores the fascinating relationship between human emotions and food choices using comprehensive datasets from Zomato (restaurant data) and a food choices survey.## π οΈ Technologies Used
- π Python
- π Pandas
- π’ NumPy
- π€ Scikit-learn
- π Matplotlib
- π Seaborn
### π Key Features
- π Analyze restaurant cuisine trends in New Delhi
- πΊοΈ Map restaurant ratings across different city clusters
- π Identify comfort foods for various emotional states
- π² Provide restaurant recommendations based on mood## π Datasets Used
1. **Zomato Restaurants Dataset**
- π Location: New Delhi, India
- ποΈ Contains details about 3,975 restaurants
- π Includes information like cuisine types, ratings, and geolocation2. **Food Choices Survey Dataset**
- π₯ 125 survey respondents
- π 61 variables capturing food preferences, emotional states, and eating habits### What Are the Most Famous Cuisines in Delhi ?
```python
from collections import Counter
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as snsCnt_cuisine = Counter()
res_data['Cuisines'].str.split(',').apply(lambda cuisines: Cnt_cuisine.update([c.strip() for c in cuisines]))
cnt = pd.DataFrame.from_dict(Cnt_cuisine, orient='index', columns=['cnt'])
cnt.sort_values('cnt', ascending=False, inplace=True)tmp_cnt = cnt.head(10)
print(tmp_cnt)
print()with plt.style.context('bmh'):
plt.figure(figsize=(12, 8))ax1 = plt.subplot2grid((2, 2), (0, 0))
sns.barplot(
x=tmp_cnt.index,
y='cnt',
data=tmp_cnt,
ax=ax1,
palette=sns.color_palette('Blues_d', 10),
hue=tmp_cnt.index,
dodge=False,
legend=False
)
ax1.set_title('# Cuisine')
ax1.tick_params(axis='x', rotation=70)ax2 = plt.subplot2grid((2, 2), (0, 1))
sns.countplot(
x=res_data['fusion_num'],
ax=ax2,
palette=sns.color_palette('Blues_d', res_data['fusion_num'].nunique()),
hue=res_data['fusion_num'],
dodge=False,
legend=False
)
ax2.set_title('# Cuisine Provided')
ax2.set_ylabel('')plt.tight_layout()
plt.show()print()
print('# Unique Cuisine:', len(Cnt_cuisine))```
```
Top 10 cnt
North Indian 1791
Chinese 1268
Fast Food 1001
Mughlai 485
Italian 355
Continental 340
Bakery 308
South Indian 306
Desserts 300
Cafe 290# Unique Cuisine: 78
```
## π Key Functions
### π½οΈ Top Comfort Foods Finder
```python
def find_top_comfort_foods(mood, top_n=10):
"""
Find top comfort foods for a specific mood
Args:
mood (str): Emotional state to search
top_n (int): Number of top foods to return
Returns:
List of top comfort foods
"""
top_comfort_foods = search_comfort(mood)
return top_comfort_foods[:top_n]
```
### πΊοΈ K-Means Restaurant Clustering
```python
def cluster_restaurant_ratings(data, n_clusters=7):
"""
Cluster restaurants based on location and ratings
Args:
data (DataFrame): Restaurant dataset
n_clusters (int): Number of geographical clusters
Returns:
DataFrame with cluster information and median ratings
"""
kmeans = KMeans(n_clusters=n_clusters).fit(data[['Longitude', 'Latitude']])
data['cluster'] = kmeans.labels_
cluster_stats = data.groupby('cluster')[['Longitude', 'Latitude', 'Aggregate rating']].agg({
'Longitude': 'mean',
'Latitude': 'mean',
'Aggregate rating': 'median'
}).reset_index()
return cluster_stats
```
## π¦ Mood-Based Comfort Food Insights
### π’ Sad Mood Top 3 Comfort Foods:
1. Ice Cream
2. Pizza
3. Chips### π Happy Mood Top 3 Comfort Foods:
1. Pizza
2. Ice Cream
3. Chicken Wings### π½οΈ Hunger Top 3 Comfort Foods:
1. Mac and Cheese
2. Burger
3. Ice Cream## π½οΈ Restaurant Recommendation Based on Happy Mood
### Code Explanation
The code snippet demonstrates how to find top restaurants serving comfort foods associated with a "happy" mood:
```python
def get_happy_mood_restaurants(res_data):
"""
Find top-rated restaurants serving comfort foods for a happy mood
Args:
res_data (DataFrame): Restaurant dataset containing cuisines and ratings
Returns:
DataFrame: Top 3 highest-rated restaurants serving happy mood comfort foods
"""
# Identify top comfort foods for happy mood
happy_foods = ['pizza', 'ice cream', 'chicken wings']
# Filter restaurants based on happy mood comfort foods
happy_restaurants = res_data[
res_data['Cuisines'].str.contains('|'.join(happy_foods), case=False)
].sort_values(by='Aggregate rating', ascending=False).head(3)
return happy_restaurants# Example usage
happy_restaurants = get_happy_mood_restaurants(res_data)
print(happy_restaurants[['Restaurant Name', 'Cuisines', 'Aggregate rating']])
```### Insights from Results
1. **Owl is Well**
- Rating: 4.5/5
- Cuisines: Burger, American, Fast Food, Italian, Pizza
- Location: Greater Kailash (GK) 1, New Delhi2. **Civil House**
- Rating: 4.2/5
- Cuisines: European, Continental, Pizza
- Location: Khan Market, New Delhi3. **Tossin Pizza**
- Rating: 4.1/5
- Cuisines: Pizza, Italian
- Location: Safdarjung Enclave, New Delhi### Mood-Food Correlation Methodology
1. **Data Collection**:
- Survey of 125 respondents
- Collected data on food preferences and emotional states2. **Comfort Food Identification**:
- Analyzed correlation between emotions and food choices
- Created mapping of comfort foods for different moods3. **Restaurant Recommendation Algorithm**:
- Match comfort foods with restaurant cuisines
- Rank restaurants based on aggregate ratings
- Provide top recommendations for each mood### Potential Future Improvements
- Implement machine learning model for more personalized recommendations
- Include more granular mood categories
- Add user preference learning mechanism
- Integrate real-time restaurant availability