RShiny App to Visualize Hygiene Conditions

Posted on Apr 7, 2018

This blog presents an RShiny application to visualize trends from food safety inspections and better understand hygiene factors


In this blog I analyze and present trends from inspections of various facility types in the city of Chicago during the years of 2010-2019 by Chicago Department of Public Health's Food Protection Program. The raw data set can be found here. The data set provides users with information pertinent to the food safety inspections such as the result of the inspection (Pass/Fail etc), name of the facility inspected inter alia.


Herein this article the frequency distribution of various factors and their dependence on other competitive and/or aiding factors is analyzed.


The metadata information of the data set is depicted in the below table. The description for the metadata is interpreted from examining the data set and shown below:

Metadata Description Type
Inspection.ID  A unique number assigned to a specific facility under inspection Number
DBA.Name  Name of the facility String
AKA.Name  Short name of the facility String
Lincense..  A unique number assigned to each faciltity Number
Facility.Type  Denotes the type of the facility String
Risk  Denotes the risk level of a facility String
Address  Denotes the address of the facility String
City  Name of the city the facility is in String
State  Name of the state the facility is in String
Zip  Denotes the zip code of the facility Number
Inspection.Date  The date when the facility was inspected String
Inspection.Type  Denotes if the facility was inspected first time or re-inspected String
Results  Denotes if the inspection resulted in a Pass, Fail, etc String
Violations  Describes the reasons for the results and any violations String
Latitude  Denotes the Latitude of the facility Number
Longitude  Denotes the Longitude of the facility Number
Location  Denotes the latitude and longitude position String
Year  Denotes the year of inspection Number

A variety of facility types have been inspected. A total of 487 facility types were inspected. However, the facility types of 'Restaurant', 'Grocery Store' and 'School' comprise 85% of the sample size.


The frequency distribution of the facility types is studied. The R Shiny app presents the distribution of all facility types and the top 10 facilities per frequency count subject to constraints on the parameter of 'Risk', 'Year' and 'Results'. Such a plot is quite useful to understand how the facility types have evolved in performance each year. The top 10 facility types and their respective counts are shown in Table 1.


Although a high fraction of facility types have a 'Pass' result from the inspection agency, many of them have higher risks associated. Quite surprisingly, a large fraction of each facility type suffer from a 'High Risk' score. This is also represented in Table 2. This underscores the importance and necessity of a 'Hygiene' kind of a score. It is noted that such a score in this scenario would have not been strongly correlated with the 'Results' issued by the agency but is nevertheless very critical for the general public health. 


Finally, the frequency distribution of the facility type is plotted as a function of the latitude and the longitude of the facility type. Such a plot helps one to identify specific locations in the city with the observed 'Results' in general. 

The code for the project is available here.

The RShiny app can be found here.



About Author

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