NYC Data Science Academy| Blog
Bootcamps
Lifetime Job Support Available Financing Available
Bootcamps
Data Science with Machine Learning Flagship ๐Ÿ† Data Analytics Bootcamp Artificial Intelligence Bootcamp New Release ๐ŸŽ‰
Free Lesson
Intro to Data Science New Release ๐ŸŽ‰
Find Inspiration
Find Alumni with Similar Background
Job Outlook
Occupational Outlook Graduate Outcomes Must See ๐Ÿ”ฅ
Alumni
Success Stories Testimonials Alumni Directory Alumni Exclusive Study Program
Courses
View Bundled Courses
Financing Available
Bootcamp Prep Popular ๐Ÿ”ฅ Data Science Mastery Data Science Launchpad with Python View AI Courses Generative AI for Everyone New ๐ŸŽ‰ Generative AI for Finance New ๐ŸŽ‰ Generative AI for Marketing New ๐ŸŽ‰
Bundle Up
Learn More and Save More
Combination of data science courses.
View Data Science Courses
Beginner
Introductory Python
Intermediate
Data Science Python: Data Analysis and Visualization Popular ๐Ÿ”ฅ Data Science R: Data Analysis and Visualization
Advanced
Data Science Python: Machine Learning Popular ๐Ÿ”ฅ Data Science R: Machine Learning Designing and Implementing Production MLOps New ๐ŸŽ‰ Natural Language Processing for Production (NLP) New ๐ŸŽ‰
Find Inspiration
Get Course Recommendation Must Try ๐Ÿ’Ž An Ultimate Guide to Become a Data Scientist
For Companies
For Companies
Corporate Offerings Hiring Partners Candidate Portfolio Hire Our Graduates
Students Work
Students Work
All Posts Capstone Data Visualization Machine Learning Python Projects R Projects
Tutorials
About
About
About Us Accreditation Contact Us Join Us FAQ Webinars Subscription An Ultimate Guide to
Become a Data Scientist
    Login
NYC Data Science Acedemy
Bootcamps
Courses
Students Work
About
Bootcamps
Bootcamps
Data Science with Machine Learning Flagship
Data Analytics Bootcamp
Artificial Intelligence Bootcamp New Release ๐ŸŽ‰
Free Lessons
Intro to Data Science New Release ๐ŸŽ‰
Find Inspiration
Find Alumni with Similar Background
Job Outlook
Occupational Outlook
Graduate Outcomes Must See ๐Ÿ”ฅ
Alumni
Success Stories
Testimonials
Alumni Directory
Alumni Exclusive Study Program
Courses
Bundles
financing available
View All Bundles
Bootcamp Prep
Data Science Mastery
Data Science Launchpad with Python NEW!
View AI Courses
Generative AI for Everyone
Generative AI for Finance
Generative AI for Marketing
View Data Science Courses
View All Professional Development Courses
Beginner
Introductory Python
Intermediate
Python: Data Analysis and Visualization
R: Data Analysis and Visualization
Advanced
Python: Machine Learning
R: Machine Learning
Designing and Implementing Production MLOps
Natural Language Processing for Production (NLP)
For Companies
Corporate Offerings
Hiring Partners
Candidate Portfolio
Hire Our Graduates
Students Work
All Posts
Capstone
Data Visualization
Machine Learning
Python Projects
R Projects
About
Accreditation
About Us
Contact Us
Join Us
FAQ
Webinars
Subscription
An Ultimate Guide to Become a Data Scientist
Tutorials
Data Analytics
  • Learn Pandas
  • Learn NumPy
  • Learn SciPy
  • Learn Matplotlib
Machine Learning
  • Boosting
  • Random Forest
  • Linear Regression
  • Decision Tree
  • PCA
Interview by Companies
  • JPMC
  • Google
  • Facebook
Artificial Intelligence
  • Learn Generative AI
  • Learn ChatGPT-3.5
  • Learn ChatGPT-4
  • Learn Google Bard
Coding
  • Learn Python
  • Learn SQL
  • Learn MySQL
  • Learn NoSQL
  • Learn PySpark
  • Learn PyTorch
Interview Questions
  • Python Hard
  • R Easy
  • R Hard
  • SQL Easy
  • SQL Hard
  • Python Easy
Data Science Blog > Python > Using Data Science for Food Trends

Using Data Science for Food Trends

Ben Berger
Posted on Oct 6, 2020

The restaurant industry is notoriously competitive, and New York City is surely one of the toughest places for this industry according to data. As the effects of COVID-19 continue to batter all industries, restaurants are suffering immensely. The idea crossed my mind to try and take a snapshot of restaurants currently serving food in Manhattan and see if there were any glaring commonalities or trends among popular restaurants.

If you were to start a restaurant on the island right now, what could you do to give you the best chance of success (other than of course be sure of the quality of food, ambiance and all the other intangibles that make a restaurant successful)? Genre, price point and location were among the features that I wanted to investigate. It occurred to me that restaurant rating/review websites might provide the 'snapshot' that I was looking for.

 

Data

I decided to scrape OpenTable.com to gather data on Manhattan restaurants. I used OpenTable as opposed to Yelp or other review sites because OpenTable, depending on the filter, would provide me with a list of restaurants that are currently taking reservations. My thinking was that this would do a better job of providing an accurate snapshot of restaurants currently doing business.

I set a filter on the site to show only restaurants in Manhattan that were taking evening reservations two weeks in the future. Again, as restaurants have been struggling for survival during the pandemic, many have limited their usual hours of business; this window seemed to be the time when most restaurants would be operating.

The data available on each restaurant after doing the filtering was just what I had hoped for: The name of the restaurant, the average rating of the restaurant (in stars), the number of reviews for the restaurant, how expensive the restaurant is (number of 'dollar signs'), the genre of the food and the location of the restaurant. There was also an area under these metrics where a takeout phone number was posted if available, as well as a list of delivery partners currently operating with the restaurant (Postmates, UberEats, etc.). This seemed like enough data to do some interesting exploration of Manhattan's restaurants.

 

Scraping the Data

Using Scrapy, I was able to build a spider that iterated through roughly 1,200 restaurant listings and pull the metrics listed above from the website. There were a few notable hiccups during this process. One was that the dynamic nature of the site caused different restaurants to be shown each time the site was reloaded. This meant that the order of the restaurants shown when the data was scraped could be different than what I was looking at on the website.

This made spot checking my results a bit tricky. Another issue was the presence of 'Featured Restaurants' at the top of each page, which would also change each time pages were loaded and serve as duplicates to other restaurants. The solution to this was simply making the spider more specific as to where exactly in the page it began drilling down to extract the information.

After scraping the website and eyeing over the data, another issue presented itself: roughly a quarter of the restaurants did not have any ratings or reviews. These restaurants had all the other data but did not include  the pieces that could give us a sense of 'popularity' or 'success.' This will be touched on more later, but it is important to note early on that a decision had to be made about what to do with those missing values.

Methods, Analysis

  • My initial exploration consisted of answering some of the basic questions that come to mind with this exercise: 
  • Do certain neighborhoods have more popular/successful restaurants than others?
  •  Do certain genres generally perform better than others? 
  • How do delivery/takeout options affect the success of a restaurant? 

Before jumping into these, I had to address how I judged 'success.' Number of ratings is nice to judge how established and popular a restaurant is, though it can be a 'lagging' indicator that also is heavily skewed towards expensive restaurants. Ratings, on the other hand, help judge the overall quality of the restaurant but can be distorted if there are a small number of reviews for the restaurant.

I decided to combine these metrics into one measure of success. Because the number of reviews was a relatively large number that had quite a few outliers (restaurants with thousands of reviews), I decided to take the log of the number of reviews and multiply that by the average rating. This is the performance metric I used for the majority of my analysis.

The other important aspect of my analysis was deciding how to interpret the missing values in my data. Instead of trying to impute the average ratings or number of reviews for restaurants that were missing them, I decided to carve these observations out of the data set and analyze them in tandem with the other restaurants. My intuition is that if these restaurants are taking reservations and have their information posted to a site like OpenTable, they are likely in business but are either new or haven't seen much business in general.

The figure above shows the average popularity metric of restaurants in a given neighborhood. And, while interesting to see which neighborhoods outperform the others, this analysis becomes much more interesting when you bring in the 'null' data.

This figure shows the count of 'null' restaurants for each neighborhood. This adds another angle to the analysis. It would be easy to assume that 'Garment District / Flower District' might be rated so low because of a lack of restaurants, but it's harder to make that excuse when it has the fifth most 'null' restaurants in the data. Similar dynamics can be seen in Murray Hill, Chelsea and Times Square.

And while it may be too much of a leap to say that those neighborhoods have 'bad' restaurants, it can provide some insight: those neighborhoods could be very saturated with restaurants of all sorts, which makes it harder for any one of them to succeed. In the age of COVID, would you want to start a restaurant in these traditionally commercial heavy areas? Of course we're not able to factor in things like how pricey a square foot of space is between these parts of the cities, but it raises some important questions.

The next thing I wanted to look at was delivery/takeout options. Does increasing access to your food as well as overall visibility seem to correlate with more success?

The box plot above shows restaurants bucketed into groups that have both takeout and delivery, just delivery, just takeout or neither. The mean popularity score of restaurants with both options is 25.76 which was significantly higher than the neither group at the 95% confidence interval. It's also worth pointing out that the standard deviation for both was 7.89, as opposed to neither's at 10.61. It's worth noting that 38% of the dataset had neither takeout nor delivery options. And while this could be causing the higher variation and lower average success, bringing in the null data might help bring more clarity.

The figure above shows the count of restaurants in the null set with the same groupings as before. What stands out is the large proportion of review-less restaurants have neither delivery/takeout options; 85% of the null set vs. 38% among restaurants with reviews. These results certainly align with common sense: as in-person dining has been heavily restricted due to the virus, restaurants need to find options to serve their customers by any means.

When it came to price point and genre, the data was extremely uneven. A handful of genres made up the majority of the observations, as did lower-cost restaurants. So instead of doing a similar analysis to what was done with location and delivery, I took a more specific approach: are restaurants that are unique within a given area more or less likely to be successful?

If you're the only Italian or expensive restaurant in a neighborhood, are you on average more successful than restaurants in characteristically-denser places? To do this, I took the three most common food genres, American, Italian and French, and took the number of those types in a neighborhood and divided it by the total number of restaurants in the neighborhood. The expectation would be to see a downward trend in the popularity, as the 'density' of a certain characteristic gets larger.

Unfortunately, we don't see the expected trend among all genres. While American restaurants appear to have this trend, Italian food seems to outperform as density becomes higher and French food has no discernible trend. While we don't see the results we expected, these charts raise an important aspect of this exploration: the restaurant industry is a notoriously idiosyncratic ecosystem.

It could very well be that each genre has its own 'culture' and characteristics. It could be that Italian restaurants are often in Italian neighborhoods, thus one of these restaurants could capitalize on the trends of a given place. It could be that French food is generally very expensive, and there simply aren't enough of the restaurants in a given area to show a trend.

I did a similar exercise with the price level of each restaurant. Each restaurant had either two, three or four dollar signs; two was the cheapest and four the most expensive.

Similar to genre, we don't see a consistent trend between price levels. But there are valuable things to note here. We see that the densities gradually become smaller as the price level goes up, which we'd expect. To extend that insight, it would make sense that of any of the three price levels, the cheapest restaurants would show the downward trend we'd expect. Cheaper restaurants with less novelty and distinguishing characteristics will have a harder time succeeding with more competition in the immediate area.

 

Conclusions

While it's difficult to make any hard conclusion from this exploration, there are some insights that could inform the decisions of a prospective restaurant owner. Midtown-area neighborhoods lag in popularity and also see the largest number of either new or struggling restaurants. It could be that these neighborhoods are least favorable in eyeing potential locations for a new business.

Delivery and carryout options appear to be associated with successful restaurants, and a lack of those options is notably present in struggling ones. Given the current state of the virus, including delivery and takeout options seems like an obvious choice. While our gut would tell us that you'd want to establish a restaurant with unique characteristics from those around it, we find conflicting trends when it comes to genre and price point. A deeper dive is needed to make sense of each characteristicโ€™s effect.

What's Next?

There are a number of ways to extend this project. One would certainly be to find a larger, more reliable list of operating restaurants, as this data was heavily skewed among almost all the features. This, combined with demographic data, could provide a more nuanced view of these trends. Another fascinating avenue for future work would be to try and get a glimpse of the success of each restaurant before and after the virus hit.

If we could find the number of reviews or average ratings for restaurants during a time immediately before the virus hit and after restaurants began reopening, we could get a better sense of which types of restaurants have fared better than others.

The skills I demoed here can be learned through taking Data Science with Machine Learning bootcamp with NYC Data Science Academy.

About Author

Ben Berger

Degree in environmental economics from Bates College. ~2 years in sell side Sales & Trading. Interested in the music industry, sustainability/cleantech.
View all posts by Ben Berger >

Related Articles

Capstone
Catching Fraud in the Healthcare System
Capstone
The Convenience Factor: How Grocery Stores Impact Property Values
Capstone
Acquisition Due Dilligence Automation for Smaller Firms
Machine Learning
Pandemic Effects on the Ames Housing Market and Lifestyle
Machine Learning
The Ames Data Set: Sales Price Tackled With Diverse Models

Leave a Comment

No comments found.

View Posts by Categories

All Posts 2399 posts
AI 7 posts
AI Agent 2 posts
AI-based hotel recommendation 1 posts
AIForGood 1 posts
Alumni 60 posts
Animated Maps 1 posts
APIs 41 posts
Artificial Intelligence 2 posts
Artificial Intelligence 2 posts
AWS 13 posts
Banking 1 posts
Big Data 50 posts
Branch Analysis 1 posts
Capstone 206 posts
Career Education 7 posts
CLIP 1 posts
Community 72 posts
Congestion Zone 1 posts
Content Recommendation 1 posts
Cosine SImilarity 1 posts
Data Analysis 5 posts
Data Engineering 1 posts
Data Engineering 3 posts
Data Science 7 posts
Data Science News and Sharing 73 posts
Data Visualization 324 posts
Events 5 posts
Featured 37 posts
Function calling 1 posts
FutureTech 1 posts
Generative AI 5 posts
Hadoop 13 posts
Image Classification 1 posts
Innovation 2 posts
Kmeans Cluster 1 posts
LLM 6 posts
Machine Learning 364 posts
Marketing 1 posts
Meetup 144 posts
MLOPs 1 posts
Model Deployment 1 posts
Nagamas69 1 posts
NLP 1 posts
OpenAI 5 posts
OpenNYC Data 1 posts
pySpark 1 posts
Python 16 posts
Python 458 posts
Python data analysis 4 posts
Python Shiny 2 posts
R 404 posts
R Data Analysis 1 posts
R Shiny 560 posts
R Visualization 445 posts
RAG 1 posts
RoBERTa 1 posts
semantic rearch 2 posts
Spark 17 posts
SQL 1 posts
Streamlit 2 posts
Student Works 1687 posts
Tableau 12 posts
TensorFlow 3 posts
Traffic 1 posts
User Preference Modeling 1 posts
Vector database 2 posts
Web Scraping 483 posts
wukong138 1 posts

Our Recent Popular Posts

AI 4 AI: ChatGPT Unifies My Blog Posts
by Vinod Chugani
Dec 18, 2022
Meet Your Machine Learning Mentors: Kyle Gallatin
by Vivian Zhang
Nov 4, 2020
NICU Admissions and CCHD: Predicting Based on Data Analysis
by Paul Lee, Aron Berke, Bee Kim, Bettina Meier and Ira Villar
Jan 7, 2020

View Posts by Tags

#python #trainwithnycdsa 2019 2020 Revenue 3-points agriculture air quality airbnb airline alcohol Alex Baransky algorithm alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus ames dataset ames housing dataset apartment rent API Application artist aws bank loans beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep boston safety Bundles cake recipe California Cancer Research capstone car price Career Career Day ChatGPT citibike classic cars classpass clustering Coding Course Demo Course Report covid 19 credit credit card crime frequency crops D3.js data data analysis Data Analyst data analytics data for tripadvisor reviews data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization database Deep Learning Demo Day Discount disney dplyr drug data e-commerce economy employee employee burnout employer networking environment feature engineering Finance Financial Data Science fitness studio Flask flight delay football gbm Get Hired ggplot2 googleVis H20 Hadoop hallmark holiday movie happiness healthcare frauds higgs boson Hiring hiring partner events Hiring Partners hotels housing housing data housing predictions housing price hy-vee Income industry Industry Experts Injuries Instructor Blog Instructor Interview insurance italki Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter las vegas airport lasso regression Lead Data Scienctist Lead Data Scientist leaflet league linear regression Logistic Regression machine learning Maps market matplotlib Medical Research Meet the team meetup methal health miami beach movie music Napoli NBA netflix Networking neural network Neural networks New Courses NHL nlp NYC NYC Data Science nyc data science academy NYC Open Data nyc property NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time performance phoenix pollutants Portfolio Development precision measurement prediction Prework Programming public safety PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R Data Analysis R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn seafood type Selenium sentiment analysis sentiment classification Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau teachers team team performance TensorFlow Testimonial tf-idf Top Data Science Bootcamp Top manufacturing companies Transfers tweets twitter videos visualization wallstreet wallstreetbets web scraping Weekend Course What to expect whiskey whiskeyadvocate wildfire word cloud word2vec XGBoost yelp youtube trending ZORI

NYC Data Science Academy

NYC Data Science Academy teaches data science, trains companies and their employees to better profit from data, excels at big data project consulting, and connects trained Data Scientists to our industry.

NYC Data Science Academy is licensed by New York State Education Department.

Get detailed curriculum information about our
amazing bootcamp!

Please enter a valid email address
Sign up completed. Thank you!

Offerings

  • HOME
  • DATA SCIENCE BOOTCAMP
  • ONLINE DATA SCIENCE BOOTCAMP
  • Professional Development Courses
  • CORPORATE OFFERINGS
  • HIRING PARTNERS
  • About

  • About Us
  • Alumni
  • Blog
  • FAQ
  • Contact Us
  • Refund Policy
  • Join Us
  • SOCIAL MEDIA

    ยฉ 2025 NYC Data Science Academy
    All rights reserved. | Site Map
    Privacy Policy | Terms of Service
    Bootcamp Application