/ Smart DataPart IInutritionData Analysis


In my previous post (Small data - Big opportunities) I discussed how valuable small data-sets can be. Now I would like to show it based on the example of a highly personalised food tracking application to control weight, in order to stay healthy and get better results from exercising.

Similar to other data-driven applications the following common aspects need to be regarded:

  • data-tracking ability including knowledge about data to be tracked and the ability to track the data
  • short feedback loops for incremental improvements
  • deep understanding of the main application subject
  • audience that provides data and feedback

Let us have a more detailed look on these aspects.

What and how to track

The point of tracking food is to know how much energy is consumed. This means that the amount of every meal and drink has to be tracked, which can be done within ten minutes every week plus some minutes for additional snacks or changes.
If more energy is consumed, than used by the body, you gain weight. If less energy is consumed, you lose weight. Depending on the goals (gain, lose or maintenance weight) the body weight and body fat percentage has to be tracked regularly for faster feedback.

Feedback loops

There are multiple feedback loops:

  • The daily feedback loop
    • consume the targeted amount of calories and
    • consume enough protein,
  • The weekly feedback loop
    • update body weight and body fat percentage and
    • adjust the targeted amount of calories based on goal and weight changes over the previous two weeks.

Deep understanding of the subject


Food and drink are an energy source for the body. The parts which contribute energy are called macro nutrients or macros. The other parts are mainly vitamins and minerals, called micro nutrients. The unit of energy is colloquially the calorie: cal,[1] used in 1000s as kilocalorie (kcal) and \(\frac{kcal}{gr}\). The four different macro nutrients are protein, carbohydrates, fat and alcohol. Each provide a specific amount of energy: protein and carbohydrates have 4 \(\frac{kcal}{gr}\), fat 9 \(\frac{kcal}{gr}\), and alcohol 7 \(\frac{kcal}{gr}\).

The effects of alcohol are generally considered negative and consumption should be limited[2]. Because of that alcohol will be not considered further; if you drink regularly, keep also track of those calories.

Every food piece can have a different number of macros per gram. These values can be found on food labels[3].

Calculating the amounts of macros and calories are standard matrix multiplications, for example to just get the calories:

\begin{pmatrix} f_{gr}^{kcals} & p_{gr}^{kcals} & k_{gr}^{kcals}\end{pmatrix}
food1_f^{gr} & food2_f^{gr}\\
food1_p^{gr} & food2_p^{gr}\\
food1_k^{gr} & food2_k^{gr}
\begin{pmatrix}food1_{kcals} \\ food2_{kcals}\end{pmatrix}

$$\text{(}\frac{kcal}{gr} * gr = kcal\text{ for fat, protein and carbs; for every food item)}$$

The human body burns energy to keep you alive. As previously mentioned if you provide more energy through food and drink than you burn, you gain weight; if you provide less, you lose weight.
Every macro has different functions beside providing energy — if you want to know more, there are numerous sites that provide overviews[4] and in-depth articles about specifics. Tracking each macro by itself, and not only calories, is recommended. The energy provided is just the sum of all calories of every meal, snack, beverage, … consumed.

Daily energy expenditure

The energy needed by the human body per day is called total daily energy expenditure (TDEE), which consists of a) the activities done, and b) the energy needed just to stay alive, generally referred to as basal metabolic rate (BMR). TDEE is calculated based off the BMR with an activity level multiplier — the more active, the higher the multiplier.

$$\text{TDEE} = \text{BMR} * activity level$$

Table of \(activity level\)

  • sedentary: 1.1
  • 1 to 3 hours exercise: 1.2
  • 4 to 6: 1.35
  • 6+: 1.5

One way to calculate the MBR (stay-alive energy) is the Katch-McArdle Formula,[5] where LBM is the lean body mass. LBM is the body weight without fat; only bones, muscles, organs, etc:

$$\text{BMR} = 370 + (21.6 * \text{LBM})\\
\text{LBM} = \text{bodyweight} * (1 - \text{body fat percentage})$$

There are formulas without knowledge about body fat, but fat free mass is the main factor that drives BMR.[6]

Body fat

There are various ways to guesstimate your body fat percentage, but only two of them are considered accurate:

  • DEXA scans,[7] where an X-ray measures bone density and soft tissue, or
  • Hydrostatic weighting,[8] where body density is measured in a water tank.

Since these two approaches are time consuming and often not applicable for every day life, other satisfactory approaches are:

  • take pictures of yourself, and compare with online pictures of people with known body fat percentages
  • measure the skin thickness on different points on your body with a caliper
  • Navy method, where the waist and neck measurements are taken[9]
  • Scale with body fat functionality uses electric impedance

All of these produce results with a rather high error margin. But they are suitable to track progress and get initial guesses to calculate the MBR. Different approaches can be combined in order to reduce error and compensate for individual weaknesses. I use the navy method, caliper and a scale, then take the mean as body fat percentage for the week. If these three combined go up (or down), I can be pretty sure that the percentage overall went also up (or down).

Example: a person weighting 80kg with 25% body fat and pretty active lifestyle (1-3 hours training) has

\text{LBM} = 80 * (1 - 0.75) = 60 kg,\text{ and therefore}\\
\text{BMR} = 370 + (21.6 * 60) = 1666 kcal\\
\text{TDEE} = 1666 * 1.375 = 1999 kcal

What does this now tell us? If this person eats around 2000 kcal per day, he will maintain his weight. If he eats significant more or less, he will gain or lose weight.
Based on the feedback loops and goals, this person can then adjust his calories needed.

Now everything is given to design and implement a food / weight control monitoring application — in my next post. Additionally we’ll explore the last aspect: the audience of the data-driven application. Since the target audience is myself, you will also see my motivation, reasoning and incentives to dig into this topic.

Stay tuned!

  1. Calorie. Link: https://en.wikipedia.org/wiki/Calorie. Last check on 23.07.18 ↩︎

  2. Does Alcohol Consumption Affect Weight Loss and Muscle Growth? Matthews M. Link: https://www.muscleforlife.com/does-alcohol-consumption-affect-weight-loss-and-muscle-growth/. Last Check: 23.07.18 ↩︎

  3. United States Nutrition Facts Label Module Formats. Link: https://www.esha.com/us-nutrition-facts-labels/. Last Check: 23.07.18 ↩︎

  4. What are macronutrients? Everything you need to know. Runtastic Team. Link: https://runtastic.com/blog/en/what-are-macronutrients/. Last check 23.07.18 ↩︎

  5. Basal metabolic rate. Link: https://en.wikipedia.org/wiki/Basal_metabolic_rate. Last check on 23.07.18 ↩︎

  6. Factors influencing variation in basal metabolic rate include fat-free mass, fat mass, age, and circulating thyroxine but not sex, circulating leptin, or triiodothyronine. Johnstone AM, Murison SD, Duncan JS, Rance KA, Speakman JR, Koh YO. American Journal of Clinical Nutrition. 82 (5): 941–948. doi:10.1093/ajcn/82.5.941. Link: https://www.ncbi.nlm.nih.gov/pubmed/16280423. Last Check: 23.07.18 ↩︎

  7. Dual-energy X-ray absorptiometry. Link: https://en.wikipedia.org/wiki/Dual-energy_X-ray_absorptiometry. Last Check: 23.07.18 ↩︎

  8. Hydrostatic weighting. Link: https://en.wikipedia.org/wiki/Hydrostatic_weighing. Last Check: 23.07.18 ↩︎

  9. Development of the DoD body composition estimation equations. Hodgdon JA, Friedl K. Link: http://www.dtic.mil/get-tr-doc/pdf?AD=ADA370158. Last Check: 23.07.18 ↩︎

    Christian Seyda

    Christian Seyda

    Software engineer at incontext.technology working on backend for mass data. He studied computer sciences with focus on data mining and care to implement applications to support healthy living.

    Read More