Know What You Eat, Wherever You Are

Jonathan Liu
Posted on Aug 7, 2016

My Shiny App can be accessed at https://jonathanliu.shinyapps.io/FoodExplorerV2/

EDIT: Several updates and changes have been made after this blog post has been posted.

Please visit https://jonathanliu.shinyapps.io/FoodExplorerV5/ for the latest version of my App.

Source Codes at my Github has also been updated.

Dataset used in this App can be found HERE on Open Food Facts website

Introduction

Traveling abroad sometimes can be painful, especially when you are trying to keep your regular diet. Imagine you have to spend a few days in Russia, and you do not speak Russian, what should you eat? Well, McDonalds can be a safe choice, but what if you cannot find a familiar restaurant or you want to keep your healthy diet?

openfoodfacts-logo

[Figure 1. Open Food Facts]

Open Food Facts might be useful in helping you find out what to eat. It is an open source database that started in France, which provides nutrition facts for food products sold in each country, and all nutrition information was available in English. This can be very helpful to foreigners to understand food in this country. Currently, this database contains more than 90,000 records, all of the contents are contributed by volunteers, and its entire database can be downloaded for free.

With that being said, however, there a few issues that causing this great website to be less accessible. For example, although the search engine provided by Open Food Facts website gives many options to dig into the dataset, its user interface is not very user-friendly. Users have to switch back and forth between different result pages to check details of products, which makes the searching quite inefficient. Therefore, in an attempt to build a more efficient explorer for the Open Food Fact database, I have made a World Food Explorer with RStudio’s Shiny web application framework.

Overview

Overview

[Figure 2. Overview]

As shown in Figure 2, the first page of this web app shows a brief overview of all food records within the database. As this summary demonstrates, although there are more than 14 countries included in this database, the majority of product records in the database come from France and other European countries; while users from United States, Canada, Brazil, and Australia also contributed thousands of records. This is understandable since this project was originally founded in France.

Explorer

Filters

[Figure 3. Country Selector and Nutrition Filters]

The explorer page provides an interface to dig into the dataset. The Nutrition Filters box on top of the page (collapsed by default) provides slider-form filters for 10 major nutritional elements that exist in food products, including total calories, Carbohydrates, Sugar, etc. After selecting a target country on the top of the page, then check interested nutrition and change the range of filtering, this app will filter all the products based on users’ choices.

DataTable

[Figure 4. DataTable]

Meanwhile, the Matching Items box lists all the products that match the filtering criteria and display corresponding nutritional facts along with the product names and their packaging barcodes. Users can also click the “Info” button on the right side of each record to browse the detail page on the Open Food Facts website.

Scatter Plot

[Figure 5. Scatter Plot]

At the bottom of Explorer page users can find another box called Correlation Between Nutrition. This box projects all the food records in the Matching Items box into a scatterplot, showing the relationship between two selected nutrition items. This chart reveals some very interesting relationships. For example, Figure 5 shows a scatterplot between sugar and Carbohydrate per 100 gram of product, and immediately you can identify the clear correlation on x = y boundary. What does this line tell us? It means within many food products, sugar is the only carbohydrate that is included! That sounds scary, but what on earth are those items? By narrowing down nutrition filters, the app allows users to further investigate this sweet list.

High Sugar items

[Figure 6. High Sugar Items]

Ha! As shown in Figure 6, it turns out that products with the extremely high volume of sugar are really just pure sugar or syrup. Feel relieved now? Well, let’s look further.

Real High Sugar Food

[Figure 7. High Sugar Items - Below 50g]

When we lower the sugar limit further to below 50 grams per 100 grams of product, we finally find dentists’ top enemies – chocolate, sugary drinks. All those sweet devils are hiding in this range!

Summary

Summary - Warning

[Figure 8. Summary Tab]

Now, after exploring different types of food and nutrition items, users might want to save a list of items for further consideration. This is what Summary tab is for. When users want to save an item in the food in Explorer tab, they can select items in the data table, and then click “Add Selections to Summary” button on the top right of the data table. The number of saved items are shown in both the sidebar and the Explorer tab, and users can reset this list anytime by clicking the “Reset Selections” button in the sidebar. Saved items can be reviewed in Summary tab; in addition, this tab also calculates the average nutrition level of all selected items, compares it with the FDA’s suggested Daily Value (DV) of each nutritional element, and shows the average DV% that each item in the list contains. If the average DV% exceeds 50%, the corresponding info boxes will turn into yellow as warnings.

End Note

This Shiny App is designed as a replacement for the "unfriendly" user interface on the Open Food Facts website. While it improves users' experience, there is still more that can be done. for example, a download button might be useful for users to download their selected items. If you are interested, please feel free to fork my source code at my Github.

 

About Author

Jonathan Liu

Jonathan Liu

Through years of self-learning on programming and machine learning, Jonathan has discovered his interests and passion in Data Science. With his B.B.A. in accounting, M.S. in Business Analytics, and two years of experience as operation analyst, he is...
View all posts by Jonathan Liu >

Leave a Comment

No comments found.

View Posts by Categories


Our Recent Popular Posts


View Posts by Tags

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 Classes Demo Day Demo Lesson 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 Lectures linear regression Live Chat Live Online Bootcamp 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 Lectures 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 Realtime Interaction 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