Using R to prevent food poisoning in Chicago

December 29, 2016

(This article was first published on Revolutions, and kindly contributed to R-bloggers)

There are more than 15,000 restaurants in Chicago, but fewer than 40 inspectors tasked with making sure they comply with food-safety standards. To help prioritize the facilities targeted for inspection, the City of Chicago used R to create a model that predicts which restaurants are most likely to fail an inspection. Using this model to deploy inspectors, the City is able to detect unsafe restaurants more than a week sooner than by using traditional selection methods, and cite 37 additional restaurants per month.

Chicago's Department of Public Health used the R language to build and deploy the model, and made the code available as an open source project on GitHub. The reasons given are twofold:

An open source approach helps build a foundation for other models attempting to forecast violations at food establishments. The analytic code is written in R, an open source, widely-known programming language for statisticians. There is no need for expensive software licenses to view and run this code.

Releasing the model as open source has had benefits for beyond Chicago as well: Montogomery County, MD adopted the process and also saw improvements in its food safety inpection process.

You can see how the model is used in practice in the video below from PBS NewsHour. Fast forward to the 3:00 mark to see the Tom Schenk, Chief Data Officer for the City of Chicago, describe how the data science team there used R to develop the model. (There's also a close-up of R code using the data.table package around the 6:45 mark.)

The video also describes the Foodborne Chicago Twitter detection system for flagging tweets describing food poisoning in Chicago (also implemented with R).

PBS NewsHour: Up to code? An algorithm is helping Chicago health officials predict restaurant safety violations (via reader MD)

To leave a comment for the author, please follow the link and comment on their blog: Revolutions. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)