RShiny App to Visualize Hygiene Conditions

Karthik Uppulury
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 airbnb Alex Baransky alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus API Application artist aws 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 Bundles California Cancer Research capstone Career Career Day citibike clustering Coding Course Demo Course Report D3.js data Data Analyst data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization Deep Learning Demo Day Discount dplyr employer networking feature engineering Finance Financial Data Science Flask gbm Get Hired ggplot2 googleVis Hadoop higgs boson Hiring hiring partner events Hiring Partners Industry Experts Instructor Blog Instructor Interview Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter lasso regression Lead Data Scienctist Lead Data Scientist leaflet linear regression Logistic Regression machine learning Maps matplotlib Medical Research Meet the team meetup Networking neural network Neural networks New Courses nlp NYC NYC Data Science nyc data science academy NYC Open Data NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time Portfolio Development prediction Prework Programming PwC python python machine learning python scrapy python web scraping python webscraping Python Workshop R 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 Selenium sentiment analysis Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau team TensorFlow Testimonial tf-idf Top Data Science Bootcamp twitter visualization web scraping Weekend Course What to expect word cloud word2vec XGBoost yelp