• Personal Blog

    Posted on September 29th, 2014

    Written by Denis Finnegan

    Tags

    Creating a Healthier Alternative Prototype

    A little while ago, my Data & Nutrition Manager (Dr. Claire Kehoe) came to me with an idea she had fro our upcoming Innovation Day on the 26th of September.

    The idea was to see if we could create an app to use a government backed health food scoring system; which rates the healthiness of food per 100g and returns a simplified score to customers. It would be based on the UK Food Standards Agency’s Nutrient Profiling Model released in 2009 but as yet not heavily though we have seen clever services like FoodSwitch utilising it to great effect and we thought that this would be a super development to bring to the Tesco Health and Wellbeing Platform.

    Because I was going to be running the innovation day myself however, I know it meant I wouldn’t be able to participate with this project but I really wanted to see it go forward.

    Health Score Prototype

    Health Score Prototype

    So I started coding the basic rules of the Health Food Score in my spare time. There were quite a few challenges like the fact that ingredients are sometimes nested and don’t always give you their percentage. Thankfully Claire had some very clever ideas as to how to get around this and even though the Fruit, Veg and Nut calculations need to be a bit more intelligent and better automated, it seemed that for the sake of prototyping, the static list of FV&N terms was working well.

    I eventually got the code to the point where you could input a productid which is a Tesco.com product reference and get the Food Health Score returned. Rather than doing this on the fly, using the previous scrape system I previously created, I just used our database as most of the products are already loaded there.

    As a quick example, take say the product “Kelloggs Special K 550G” 273299654, feed this into the system and and it would spit back a final food health score to you, in this case, the Special K scored a 6, which is not bad at all  given that:

    • A food is classified as ‘less healthy’ where it scores 4 points or more.
    • A drink is classified as ‘less healthy’ where it scores 1 point or more.

    Food Health Score for Kelloggs Special K 550G

    • Fruit Veg & Nut Score
    • weightofFVN: 0
    • weightofDriedFNV: 0
    • weightofOtherIngredients: 100
    • finalFVN: 0
    • FNV Score: 0
    • A Score

      Food Health Score Prototype Running

      Food Health Score Prototype Running

    • starting Sugar Score: 0
    • energyScore: 4
    • satFatScore: 0
    • sugarScore: 3
    • sodiumScore: 4
    • scoreAPoints: 11
    • C Score
    • fibreScore: 5
    • proteinScore: 5
    • scoreFNV: 0
    • scoreCPoints: 10
    • Overall Health Score
    • healthScore: 6

    So I had it working which was all well and good but in order for Claire and now Eric Valverde (our Graphic & Web Design Manager) who had joined forces for the innovation day to build something from this, I needed to give them something they could access rather than a dump of Python Code.

    So firstly, I modified the script to run through every product in the database and assign a Food Score to it and then went searching for a lightweight web server to create an API for Eric to call with through the Titanium App he was going to create for iOS on the day. Hence, after a quick bit of digging around I found a lightweight Restful Python API called Bottle which I quickly set about using to make my Food Score Service available through.

    Kp Mini Cheddars 12 Pack Snacks

    As part of the teams project, they wanted for you to be able to barcode scan an item, and then see say 5 healthier alternatives to this product. For the purposes of example, lets use Kp Mini Cheddars 12 Pack Snacks. Using the Sub Shelf this product is located on, I quickly grabed the top 5 healthiest products on that shelf.

    The API had two simple calls, one to check the health score for a product which accepted a barcode and then returned the Health Score to the customer in JSON and the second which lists out the 5 healthiest alternatives:

    1) CHECK FOOD HEALTH SCORE

    http://192.168.133.89:8080/check/5000168131092

    [
    {
    “productId”: 251228859,
    “strippedProductName”: “Mcvities Mini Cheddars Snacks”,
    “tescoShelfName”: “Crisps & Snacks”,
    “calories”: 517.0,
    “EANBarcode”: “5000168131092”,
    “imagePath”: “http://img.tesco.com/Groceries/pi/092/5000168131092/IDShot_90x90.jpg”,
    “foodHealt

    hScore”: 24
    }
    ]

    2) RETURN HEALTHIER ALTERNATIVES

    http://192.168.133.89:8080/list/5000168131092

    Walkers Baked Stars Mild Sweet Chilli Crisps6pk

    Walkers Baked Stars Mild Sweet Chilli Crisps6pk

    [
    {

    “productId”: 272898494,
    “strippedProductName”: “Walkers Baked Stars Mild Sweet Chilli Crisps”,
    “tescoShelfName”: “Crisps & Snacks”,
    “calories”: 410,

    “EANBarcode”: “5000328330655”,
    “imagePath”: “http://img.tesco.com/Groceries/pi/655/5000328330655/IDShot_90x90.jpg”,
    “foodHealthScore”: -3
    },

    {
    “productId”: 272898690,
    “strippedProductName”: “Walkers Baked Stars Salt & Vinegar Crisps “,
    “tescoShelfName”: “Crisps & Snacks”,
    “calories”: 409,
    “EANBarcode”: “5000328453361”,
    “imagePath”: “http://img.tesco.com/Groceries/pi/361/5000328453361/IDShot_90x90.jpg”,
    “foodHealthScore”: -3

    },
    {
    “productId”: 272898874,
    “strippedProductName”: “Walkers Baked Stars Cheese & Onion Crisps “,
    “tescoShelfName”: “Crisps & Snacks”,
    “calories”: 410,
    “EANBarcode”: “5000328484501”,
    “imagePath”: “http://img.tesco.com/Groceries/pi/501/5000328484501/IDShot_90x90.jpg”,
    “foodHealthScore”: -3
    },
    {
    “productId”: 280541639,
    “strippedProductName”: “Tesco Chicken & Lemgrass Lentil Chips “,
    “tescoShelfName”: “Crisps & Snacks”,
    “calories”: 461,
    “EANBarcode”: “5053526205805”,
    “imagePath”: “http://img.tesco.com/Groceries/pi/805/5053526205805/IDShot_90x90.jpg”,
    “foodHealthScore”: -3
    },
    {
    “productId”: 274110329,
    “strippedProductName”: “Propercorn Lightly Sea Salted “,
    “tescoShelfName”: “Crisps & Snacks”,
    “calories”: 440,
    “EANBarcode”: “5060283760003”,
    “imagePath”: “http://img.tesco.com/Groceries/pi/003/5060283760003/IDShot_90x90.jpg”,
    “foodHealthScore”: -2
    }
    ]

    Armed with an API the guys were able to build a fun light weight App on the day that you could scan a food product and get a list of healthier alternatives. Unfortunately, I cannot share the screen shots of this prototype with you due to IP restrictions but perhaps once it is rolled out to customers on Tesco Health and Wellbeing Desktop and App services, you can see for yourself.

    So, even though I didn’t get to participate on the day, I had a lot of fun from the fringes and really enjoyed this little project. I do try and keep a little bit of development exposure ongoing so that I can stay in touch with this area of IT.

     

    This entry is filed under Personal Blog. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.
  • 0 Comments

    Take a look at some of the responses we have had to this article.

  • Leave a Reply

    Let us know what you thought.

  • Name(required):

    Email(required):

    Website:

    Message:

    CAPTCHA Image
    Play CAPTCHA Audio
    Reload Image