GithubHelp home page GithubHelp logo

pynutriscore's Introduction

pyNutriScore

Nutri Score logo

The goal of the project is to provide simple package that can calculate the Nutri-Score.

What is the Nutri-Score ?

The Nutri-Score is a nutrition label that converts the nutritional value of products into a simple code consisting of 5 letters, each with its own colour.

Each product is awarded a score based on a scientific algorithm.

This formula takes into account the nutrients to avoid (energy value and the amount of sugars, saturated fats and salt) and the positive ones (the amount of fibre, protein, fruit, vegetables and nuts).

You can therefore see at a glance which products are recommended and which should be avoided.

Source: https://nutriscore.colruytgroup.com/colruytgroup/en/about-nutri-score/

Paper: https://pdfs.semanticscholar.org/3d1c/c206bc286bb5f80452821a0d26ff9e55b387.pdf

Where to get it

The source code is currently hosted on GitHub at: https://github.com/lemonhead94/pyNutriScore

Usage

Install

pip install pyNutriScore

Calculate the nutri-score:

from pyNutriScore import NutriScore

result = NutriScore().calculate(
    {
        'energy': 0,
        'fibers': 4,
        'fruit_percentage': 60,
        'proteins': 2,
        'saturated_fats': 2,
        'sodium': 500,
        'sugar': 10,
    },
    'solid'  # either 'solid' or 'beverage'
)

print(result)  # Output: 2

Calculate the nutri-score class:

from pyNutriScore import NutriScore

result = NutriScore().calculate_class(
    {
        'energy': 0,
        'fibers': 4,
        'fruit_percentage': 60,
        'proteins': 2,
        'saturated_fats': 2,
        'sodium': 500,
        'sugar': 10,
    },
    'solid'  # either 'solid' or 'beverage'
)

print(result)  # Output: "B"

License

MIT

Contribution

Feel free to add suggestions, PRs, comments and bug reports.

Credits

This is a re-implementation of the TypeScript package nutri-score by Alex Kolarski in Python.

Authors

Jorit Studer ([email protected])

pynutriscore's People

Contributors

lemonhead94 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.