<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/nyc-restaurants-reviews-and-inspection-scores/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://nycdatascience.com/blog/student-works/nyc-restaurants-reviews-and-inspection-scores/"> R – NYC Data Science Academy Blog</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><img sizes="(max-width: 1024px) 100vw, 1024px" src="https://i1.wp.com/nycdatascience.com/blog/wp-content/uploads/2018/05/nyc_res_img-1-1024x640.jpg?w=450&ssl=1" alt="" class="wp-post-image" data-recalc-dims="1"></p>
<p> </p>
<p><span>If you ever pass outside a restaurant in New York City, you’ll notice a prominently displayed letter grade. Since July 2010, the Health Department has required restaurants to post letter grades showing sanitary inspection results.</span></p>
<p><span> An A grade attests to top marks for health and safety, so you can feel secure about eating there. But you don’t necessarily know that you will enjoy the food and experience courteous service. To find that out, you’d refer to the restaurant reviews. For this project, I looked at a simple data analysis and visualization of the NYC restaurants reviews and inspection scores data to find out if there is any correlation between the two. The data will also show which types of cuisines and which NYC locations tend to attract more ratings.</span></p>
<p><span>Nowadays, business reviews, ratings and grades are the decision making for any business to measure for their quality, popularity and future success. For restaurants business, ratings, hygienic, and cleanliness are essential.</span> A popular site for reviews, Yelp, offers many individual ratings for restaurants. The New York City Department of Health and Mental Hygiene (DOHMH) conducts unannounced restaurant inspections annually. They check if the food handling, food temperature, personal hygiene of workers and vermin control of the restaurants are in  compliance with hygienic standards.. The scoring and grading process can be found<a rel="nofollow" href="http://www1.nyc.gov/assets/doh/downloads/pdf/rii/how-we-score-grade.pdf" target="_blank"> here</a>.</p>
<p><span> The restaurant ratings and location information used in this project come from Yelp’s </span><span>API</span><span>. The inspection data was downloaded from NYC open data </span><a rel="nofollow" href="https://data.cityofnewyork.us/Health/DOHMH-New-York-City-Restaurant-Inspection-Results/43nn-pn8j" target="_blank"><span>website</span></a><span>. I merge yelp restaurants review data and inspection data and remove NA rows which doesn’t have</span>either inspection score or reviews. I also reassigned the inspection score in the grades A, B, and C category as this measure is widely used and label on restaurants. There were other scores, primarily P or Z, or some version of grade pending which we are ignoring in our analysis here. Restaurants with a score between 0 and 13 points earn an A, those with 14 to 27 points receive a B and those with 28 or more a C.</p>
<p><a rel="nofollow" href="http://nycdatascience.com/blog/wp-content/uploads/2018/05/grade_cuisine-1.png" target="_blank"><br>
</a><a rel="nofollow" href="https://i2.wp.com/nycdatascience.com/blog/wp-content/uploads/2018/05/grade_boro-1.png" target="_blank"><img sizes="(max-width: 590px) 100vw, 590px" src="https://i2.wp.com/nycdatascience.com/blog/wp-content/uploads/2018/05/grade_boro-1.png?w=450" alt="" class="wp-image-32649" data-recalc-dims="1"></a><a rel="nofollow" href="https://i1.wp.com/nycdatascience.com/blog/wp-content/uploads/2018/05/grade_cuisine-1.png" target="_blank"><img sizes="(max-width: 577px) 100vw, 577px" src="https://i1.wp.com/nycdatascience.com/blog/wp-content/uploads/2018/05/grade_cuisine-1.png?w=450" alt="" class="wp-image-32648" data-recalc-dims="1"></a></p>
<p> </p>
<p><span>The data shows that an A is the most commonly assigned inspection grade for restaurants of all types in all locations. I plotted various bar plots to visualized the inspection scores and ratings based on borough and cuisine type.</span></p>
<p><span>With respect to location, this borough bar plot shows that Ma</span>nhattan has highest number of restaurants with all grades compared to others. This is obvious as it has highest number of restaurants in general.  Staten Island has lowest number of restaurants with grades A, B and C among all.</p>
<p><span>As for cuisine types, the cuisines plots shows first 15 restaurants with highest number of counts for based on cuisine.  This indicates that the American cuisine has highest number of A grade compared to other. This indicate that american restaurants are focus more on hygienic and cleanliness compare to others type of restaurants. </span></p>
<p><a rel="nofollow" href="https://i0.wp.com/nycdatascience.com/blog/wp-content/uploads/2018/05/rating_cuisine-1.png" target="_blank"><img sizes="(max-width: 635px) 100vw, 635px" src="https://i0.wp.com/nycdatascience.com/blog/wp-content/uploads/2018/05/rating_cuisine-1.png?w=450" alt="" class="wp-image-32650" data-recalc-dims="1"></a></p>
<p><a rel="nofollow" href="https://i0.wp.com/nycdatascience.com/blog/wp-content/uploads/2018/05/ratings_boro-1.png" target="_blank"><img sizes="(max-width: 633px) 100vw, 633px" src="https://i0.wp.com/nycdatascience.com/blog/wp-content/uploads/2018/05/ratings_boro-1.png?w=450" alt="" class="wp-image-32651" data-recalc-dims="1"></a></p>
<p> </p>
<p><span>The review plot indicates that most  restaurants do achieve the top rating of 4 stars. Again, Manhattan has the highest number of restaurants with ratings four stars while Staten Island has lowest numbers of restaurants with high ratings. It also shows that almost all borough have a low number of  2 star restaurants. Moreover, cuisine reviews plot indicates that American cuisine tend to have the highest rating compared to other cuisines. The reasons could be more American restaurants under this category then others. </span></p>
<p> </p>
<p><a rel="nofollow" href="https://i0.wp.com/nycdatascience.com/blog/wp-content/uploads/2018/05/scatter_plot-1.png" target="_blank"><img sizes="(max-width: 682px) 100vw, 682px" src="https://i0.wp.com/nycdatascience.com/blog/wp-content/uploads/2018/05/scatter_plot-1.png?w=450" alt="" class="wp-image-32647" data-recalc-dims="1"></a></p>
<p><span>The scatter plots shows the</span>relationship between inspection score and rating. It indicates that there is no direct clear correlation between two variables. It is fairly common for a  restaurant with a C grade inspection score to achieve a 4-5 star ratings in a review. Also it is possible to find a number of A grade ratings for restaurants that only have 1-2 stars.  This could be because so long as food is tasty, people will rate the restaurant well because they do not pay very much attentions to cleanliness and hygienic issues. The scatter plots also show that though some  restaurants maintain a very high level of cleanliness and hygienic food conditions, they fail to get good ratings, which could be due to bad service or less than tasty food . We can do further analysis on both side of  restaurants by analyzing review comments and try to find why some restaurants have good reviews but low inspection score and vice-versa. This require further data about reviews comments and further analysis using NLP.</p>
<p><a rel="nofollow" href="https://i2.wp.com/nycdatascience.com/blog/wp-content/uploads/2018/05/cluster_map-1.png" target="_blank"><img sizes="(max-width: 638px) 100vw, 638px" src="https://i2.wp.com/nycdatascience.com/blog/wp-content/uploads/2018/05/cluster_map-1.png?w=450" alt="" class="wp-image-32645" data-recalc-dims="1"></a></p>
<p> </p>
<p><a rel="nofollow" href="https://i2.wp.com/nycdatascience.com/blog/wp-content/uploads/2018/05/heat_map-1.png" target="_blank"><img sizes="(max-width: 650px) 100vw, 650px" src="https://i2.wp.com/nycdatascience.com/blog/wp-content/uploads/2018/05/heat_map-1.png?w=450" alt="" class="wp-image-32646" data-recalc-dims="1"></a></p>
<p> </p>
<p><span>The cluster map of NYC restaurants helps visualize locations and  to filter the restaurants based cuisine types. The color mark of the point indicates the ratings and includes  descriptions of the featured restaurants. The heat map show the density of the restaurants based on borough selection or cuisine selection. It indicate which area has a greater number of restaurants. This could be helpful for business people to make informed decisions about where to  open new restaurants based on the types of restaurants already in place.</span></p>
<p><span>Finally, this app can be useful for people to filter the data base on borough, cuisine , ratings , and inspection grade.  The people want to go to eat with specific criteria can filters the restaurants and visit their favorite restaurants based on top marks for both ratings and inspection grades. The shiny app link is </span><a rel="nofollow" href="https://akshayvaghani.shinyapps.io/NYC_Restaurants/" target="_blank"><span>here</span></a><span>. </span></p>
<p> </p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://nycdatascience.com/blog/student-works/nyc-restaurants-reviews-and-inspection-scores/"> R – NYC Data Science Academy Blog</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/B45TPNMYEfo" height="1"></a></div>