Data Analysis of Hygiene on The Restaurant in Manhattan

Posted on Jul 25, 2016
The skills the author demoed here can be learned through taking Data Science with Machine Learning bootcamp with NYC Data Science Academy.

The food quality issue is getting more and more important; can how we eat healthier in a second? We do it with data. With the data analysis and visualization, we are more than ever capable of precisely finding the right way to a good restaurant.

Data Preparation

  • Dataset

The dataset DOHMH New York City Restaurant Inspection Results released by New York City Department of Health and Mental Hygiene, containing the results of restaurant inspections that are conducted once a year. The whole data set contains 450781 historical inspection records of 24765 restaurants. Every year, each restaurant is assigned a score and grade according to that score, which reflects the health and hygiene of that restaurant.

  • Data Preparation

Sample of dataset

The following features of the original dataset were picked up to draw a picture of New York City’s restaurant sanitation, and the two main tricks were played onto the dataset: the data of grading was converted into time format for getting the latest grade and the street, building, and borough were combined and then used to fetch geographical coordinates of each restaurant, with an R package named 'Rgooglemaps'.

Data Plots

  • Latest Restaurant Grades


Pretty good! This bar plot indicates that most of the restaurant are graded as A for all boroughs. Since 75% restaurants are graded A, and it seems that we are quite safe when having dinner in New York City.

  • Data on Overall Sanitation Condition of Restaurants

History means a lot. We are definitely unwilling to have dinner at a restaurant that was once infamous. To fully analyze the overall sanitation of restaurants, the historical records should be taken into consideration, and here comes the result.


By applying the grading rules of DOHMH, the overall score was used to add a new variable called overall grade into the original dataset, supporting the analysis of grade change.

The scatterplot shows the distribution of different groups of the restaurants. There are many blue and green dots which represent A and B restaurants, and the green army occupies a huge area, which means that most restaurants have an issue on food security in the past, so there are so many restaurants graded as A but has a B overall grade.

The following are three heatmaps that drilldown the analysis on a group level , based on their overall sanitary conditions.


The center of A restaurants is located nearby Times Square and extends to cover the upper east side of Manhattan and the Columbia University area.


For B group, the center obviously moves toward the southwest. There are two high-density areas of B restaurants located on the upper east and Greenwich, which means the upper east Manhattan has more B restaurant.


The C group heatmap is greatly different from the previous two. The center is further south and there is a separate group that covers northwest Manhattan.

From three heatmaps above we can draw two conclusions:  that we’d better go midtown to north if we are seeking a great restaurant, even though that area is basically full of restaurants from every group; and people in Harlem are suffering from food sanitary problems.

  • Data on Restaurant Sanitation Change

Indeed, while the distribution matters so do changes in grades. The scatterplot below was generated based on a comparison between “overall grade” and latest grade from each restaurant. This captures the trend of how restaurants’ sanitation condition changes over time. Overall grade was then compared to most recent grade.


The red dots indicate the restaurant grade is getting worse, while the green means improvement. We can see that most all restaurants remain the same grade over time, but almost all restaurants whose grade changed are getting worse, what a pity!


  • For Restaurants Owner

As the boss of a restaurant, you should think twice before every business decision. With the result of this analysis, the runner of a restaurant can also take the grade into consideration. For example, if the owner is running a restaurant in Harlem, the grade would not trouble him or her, due to the average poor sanitation condition.   The restaurant owner could save the money rather than trying to improve his grade.

  • For Us

Want to have a healthy dinner? Look at the map before looking at the menu.

About Author

Shuheng Li

With the intention of becoming a great Data Scientist, Shuheng is an out-box thinker and self-motivator who focuses on Machine Learning and Statistics, and seeks for challenging projects and competitions that push his skills to an advanced level....
View all posts by Shuheng Li >

Leave a Comment

No comments found.

View Posts by Categories

Our Recent Popular Posts

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 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 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 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