Cucumber time, food on a 2D plate / plane
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Introduction
It is 35 degree Celsius out side, we are in the middle of the ‘slow news season’, in many countries also called cucumber time. A period typified by the appearance of less informative and frivolous news in the media.
Did you know that 100 g of cucumber contain 0.28 mg of iron and 1.67 g of sugar? You can find all the nutrient values of a cucumber on the USDA food databases.
Food Data
There is more data, for many thousands of products you can retrieve nutrient values through an API (need to register for a free KEY). So besides the cucumber I extracted data for different type of food for example
- Beef products
- Dairy & Egg products
- Vegetables
- Fruits
- etc.
And as a comparison, I retrieved the nutrient values for some fast food products from McDonald’s and Pizza Hut. Just to see if pizza can be classified as vegetable from a data point of view So the data looks like:
I have sampled 1500 products and per product we have 34 nutrient values.
Results
The 34 dimensional data is now compressed / projected onto a two dimensional plane using UMAP (Uniform Manifold Approximation and Projection). There is a Python and R package to this.
An interactive map can be found here, and the R code to retrieve and plot the data here. Cheers, Longhow.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.