Downloads · 30 days
0
amitbenavraham/swiggy-rating-predictor
swiggy-rating-predictor is a machine learning model from amitbenavraham. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
Reichman University | Adelson School of Entrepreneurship | Introduction to Data Science | 2026
Downloads · 30 days
0
Access
Public
Updated May 6, 2026
Repo size
158 MB
Likes
0
Public
Click a slice to open those files.
.mp495.5 MB · 83%
From the Hugging Face model README
Reichman University | Adelson School of Entrepreneurship | Introduction to Data Science | 2026
<video src="https://huggingface.co/amitbenavraham/swiggy-rating-predictor/resolve/main/presentation.mp4" controls="controls" style="max-width: 720px;"></video>
This project applies a full end-to-end data science pipeline to the Swiggy Restaurants Dataset — a dataset of over 107,000 restaurants across India, collected from the Swiggy food delivery platform.
"Can we predict a restaurant's rating based on its features — cuisine, price, location, and popularity?"
| Research Question | Can we predict a restaurant's rating based on its features? |
| Dataset | Swiggy Restaurants Dataset — Kaggle |
| Dataset Size | ~107,000 restaurants across India |
| Target Variable | Rating — customer rating (1.0–5.0) |
| Task Types | Regression + Classification + Clustering |
Rating — customer rating (1.0–5.0)Rating converted to 3 balanced classes — Low, Medium, HighRating values — our target variableAverage Price from text format (e.g. "₹250 for two") to numericNumber of Ratings from text format (e.g. "10+ ratings") to numericCuisine, Location, Pure VegThe Rating distribution is slightly left-skewed, with most values
between 3.5 and 4.5. Ratings outside the valid 1.0–5.0 range were
treated as invalid and removed during cleaning. No extreme outliers
were found in numeric features.
Decision: Keep all valid data — no artificial capping was applied.
Answer: All top 10 cuisine types have very similar average ratings, clustered tightly around 4.0. South Indian and Chinese cuisines rank slightly higher, but the differences are minimal — confirming that cuisine type alone does not determine a restaurant's success on Swiggy.
Answer: There is almost no correlation between price and rating (r = 0.06). Expensive restaurants (₹1,000+) are rated no higher than budget ones (₹100–300). Swiggy customers rate based on experience, not price tag.
Answer: Pure vegetarian and non-vegetarian restaurants receive nearly identical average ratings (~4.0). Being vegetarian gives no rating advantage on Swiggy — quality matters more than dietary category.
Answer: The top 10 cities each have between 1,400–1,600 restaurants on Swiggy. Kanchipuram and Kanpur lead slightly. Swiggy has broad and balanced geographic coverage across India — no single city dominates the platform.
Answer: Restaurants with more ratings tend to cluster around stable scores of 3.5–4.5, while restaurants with very few ratings show more extreme and unreliable scores. Popularity stabilizes ratings — but does not guarantee higher ones. Social proof plays a role in anchoring expectations.
Note: The interactive version of this heatmap is available in the notebook.
Average Price has very weak correlation with Rating (r = 0.06)Number of Ratings has slightly more influence on Rating (r = 0.07)This finding motivated the entire feature engineering approach in Part 4.
Before building complex models, we established a Linear Regression baseline using only raw features — no engineering, no transformations. This gives us a clear reference point to measure how much our improvements actually help.
| Metric | Value |
|---|---|
| MAE | 0.3635 |
| RMSE | 0.4916 |
| R² | 0.0114 |
The baseline explains only 1.1% of the variance in ratings — a humble but expected result. Most restaurants cluster tightly between 3.5–4.5, leaving little signal for a simple linear model to learn from.
The model struggles to predict outside the 4.0–4.5 range — confirming that raw features alone are not enough. Most predictions cluster around the mean, missing the full range of actual ratings.
All feature importance values are extremely low — confirming that raw features alone are not enough to predict restaurant ratings. This motivated the entire feature engineering approach in Part 4.
Challenge set: Can we do significantly better with feature engineering and more powerful models?
Raw data alone is rarely enough. i have engineered 4 new features designed to capture patterns the original columns couldn't express:
| Feature | Description | Intuition |
|---|---|---|
Is_Expensive | Price above ₹300 | Captures the premium restaurant segment |
Has_Many_Offers | 4 or more offers available | Captures promotional activity level |
Is_Popular | More than 50 ratings | Captures established vs new restaurants |
Cluster | K-Means cluster ID (k=4) | Groups similar restaurants by behavioral profile |
Applied K-Means clustering on Average Price, Number of Ratings, and Number of Offers to automatically group restaurants into 4 behavioral profiles — unsupervised learning working alongside our supervised models:
Used the Elbow Method to scientifically validate K=4 as the optimal number of clusters — the inertia drops sharply before K=4 and plateaus after, confirming our choice.
Number of Ratings — remained the top feature in both regression and classificationLocation — consistently the second most important featureCluster — contributed meaningful predictive signal, proving clustering added real valueIs_Expensive, Is_Popular) helped the model distinguish restaurant segmentsBusiness Insight: WHERE a restaurant is located and HOW POPULAR it already is matter far more than what it serves or how expensive it is. Location and reputation drive ratings more than menu or pricing strategy.
Trained 3 different regression models on the engineered dataset and compared them against the baseline — an iterative improvement process:
| Model | MAE | R² |
|---|---|---|
| Linear Regression (Baseline) | 0.3635 | 0.0114 |
| Linear Regression (Improved) | 0.3623 | 0.0160 |
| Random Forest | 0.3481 | 0.0510 |
| Gradient Boosting ✅ | 0.3463 | 0.0776 |
🏆 Winner: Gradient Boosting (MAE = 0.3463, R² = 0.0776)
Why Gradient Boosting wins: It builds trees iteratively, each one correcting the mistakes of the previous — better at capturing the subtle patterns in tightly-clustered restaurant ratings.
Top predictors:
Number of Ratings (#1) — more reviewed restaurants are more predictableLocation (#2) — where a restaurant is matters more than what it servesCuisine (#3) — cuisine type has some influenceCluster (#4) — our engineered feature added real predictive value!Used GridSearchCV with 3-fold cross validation to find optimal parameters:
learning_rate=0.05, max_depth=5, n_estimators=100The winning Gradient Boosting Regressor was saved and uploaded to this HuggingFace repository.
| Model | Gradient Boosting Regressor |
| File | swiggy_model.pkl |
| MAE | 0.3463 |
| R² | 0.0776 |
Converted Rating into 3 meaningful classes using quantile binning:
| Class | Definition | % of Data |
|---|---|---|
| 0 — Low | Bottom 33% | 33.8% |
| 1 — Medium | Middle 33% | 42.6% |
| 2 — High | Top 33% | 23.7% |
Why quantile binning? Creates balanced classes automatically and divides restaurants into meaningful Low / Medium / High groups.
Why F1 over accuracy? The dataset has mild class imbalance — a model predicting "Medium" for everything would get 42% accuracy without learning anything. F1 (weighted) is a fairer metric.
Why Recall matters more here: It's worse to miss a truly great restaurant (False Negative) than to occasionally recommend a mediocre one (False Positive). False Negative is more critical — predicting LOW when the restaurant is actually HIGH means hiding good restaurants from users.
Trained 3 different classification models to predict restaurant rating classes (Low / Medium / High):
| Model | Accuracy | F1 (weighted) |
|---|---|---|
| Logistic Regression | 0.43 | 0.33 |
| Random Forest | 0.45 | 0.46 |
| Gradient Boosting ✅ | 0.50 | 0.46 |
🏆 Winner: Gradient Boosting Classifier — best accuracy AND best F1 score.
Key observations:
Number of Ratings (#1) — most reviewed restaurants are most predictableCuisine_encoded (#2) — cuisine type plays a strong role in rating classLocation_encoded (#3) — where a restaurant is mattersCluster (#4) — our engineered feature contributed real signal!Applied GridSearchCV with 12 combinations and 3-fold cross validation:
| Before Tuning | After Tuning | |
|---|---|---|
| F1 (weighted) | 0.46 | 0.58 |
| Accuracy | 0.50 | 0.50 |
| Best Params | — | n_estimators=200, max_depth=None, min_samples_split=5 |
+26% improvement in F1 score from tuning alone.
| Model | Accuracy | F1 (weighted) |
|---|---|---|
| Logistic Regression | 0.43 | 0.33 |
| Random Forest | 0.45 | 0.46 |
| Gradient Boosting | 0.50 | 0.46 |
| Gradient Boosting (Tuned) ✅ | 0.50 | 0.58 |
This consistency across both regression and classification models confirms that our feature engineering choices were solid and well-justified.
| File | Description |
|---|---|
README.md | This file |
Copy_of_Assignment_2_...ipynb | Full Colab notebook with all code and outputs |
swiggy_model.pkl | Winning Gradient Boosting Regression model |
swiggy_classifier.pkl | Winning Gradient Boosting Classification model |
This project demonstrates a complete data science pipeline applied to the Swiggy Restaurants Dataset — over 107,000 restaurants across India. Starting from raw restaurant data, we built a system that predicts customer ratings and classifies restaurants into Low, Medium, and High rated groups.
The combination of feature engineering, clustering, and hyperparameter tuning resulted in a ~600% improvement over the baseline regression model (R² from 0.0114 → 0.0776), and a 26% improvement in classification F1 (0.46 → 0.58) through tuning alone.
Author: Amit Ben Avraham | Reichman University — Adelson School of Entrepreneurship | Introduction to Data Science | 2026
This project was completed with assistance from Claude (Anthropic) for code debugging, chart design, and README writing. All analysis, decisions, and interpretations are my own.