{"id":42503742,"url":"https://github.com/dataforgoodfr/batch5_phenix_happymeal","last_synced_at":"2026-01-28T13:37:21.335Z","repository":{"id":79836544,"uuid":"155621170","full_name":"dataforgoodfr/batch5_phenix_happymeal","owner":"dataforgoodfr","description":"Meal balancing algorithm for unsold food redistribution","archived":false,"fork":false,"pushed_at":"2020-02-28T16:23:37.000Z","size":9016,"stargazers_count":5,"open_issues_count":5,"forks_count":5,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-05-02T02:55:14.243Z","etag":null,"topics":["food-products","optimization","optimization-algorithms","python"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dataforgoodfr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-10-31T20:45:48.000Z","updated_at":"2020-02-28T16:23:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"b4839f76-9dfe-463e-9bff-5569d9adb4f0","html_url":"https://github.com/dataforgoodfr/batch5_phenix_happymeal","commit_stats":{"total_commits":94,"total_committers":9,"mean_commits":"10.444444444444445","dds":0.6382978723404256,"last_synced_commit":"952e14d117ef57b06606b6ab6f6fb7d0c947f220"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dataforgoodfr/batch5_phenix_happymeal","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataforgoodfr%2Fbatch5_phenix_happymeal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataforgoodfr%2Fbatch5_phenix_happymeal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataforgoodfr%2Fbatch5_phenix_happymeal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataforgoodfr%2Fbatch5_phenix_happymeal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dataforgoodfr","download_url":"https://codeload.github.com/dataforgoodfr/batch5_phenix_happymeal/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataforgoodfr%2Fbatch5_phenix_happymeal/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28846053,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T13:02:32.985Z","status":"ssl_error","status_checked_at":"2026-01-28T13:02:04.945Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["food-products","optimization","optimization-algorithms","python"],"created_at":"2026-01-28T13:37:18.394Z","updated_at":"2026-01-28T13:37:21.329Z","avatar_url":"https://github.com/dataforgoodfr.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Phenix project - Happy meal algorithm\n\nThe main goal of this repository is to create balanced meals from a list of products\n\n## Understanding our algorithm\n### Overview of the balanced meal generation process\n\nIn the following workflow, EAN means European Article Number and OFF Open Food Facts.\n\n![Image](static/Input2BalancedMeals.jpg \"icon\")\n\n(The source code of this workflow can be found [here](static/Input2BalancedMeals.xml))\n\n### Matching\nWe used the Naive Bayes method in order to automatically assign categories to articles according to their names.\n### Classifier\nWe used the Random Forest method (40 trees) to automatically assign categories to articles according to their nutrients (6 features).\n### Defining weights in grams\nThis algorithm works as follow: \n\n- If the quantity is mentioned in OFF, then converts the quantity in grams\n    - if not, then compute the average of article's category quantities\n- If the article is rice, semolina, pasta or instant mashed potatoes, then multiply by a specific coefficient\n### Optimizer\nDescription can be found [here](https://github.com/dataforgoodfr/batch5_phenix_happymeal/tree/master/meal_balancer/algos_optimisation).\n### Reallocating remaining articles\n_add a description here_\n\n## Requirements\nThe numpy and [openfoodfacts](https://github.com/openfoodfacts/openfoodfacts-python) packages are required to properly use the repo.\nTested on the following version:\n```python\nimport sys\nimport numpy, openfoodfacts\nprint('Python %s' % '.'.join(map(str, sys.version_info[:3])))\nprint('Numpy %s, Openfoodfacts %s' % (numpy.__version__, openfoodfacts.__version__))\n```\n```console\nPython 3.6.5\nNumpy 1.15.0, Openfoodfacts 0.1.0\n```\n\n## How to use it\nDepending on the feature you wish to test, you may need an Internet connection (product information)\n\n### Product information\n\nPass a barcode (EAN) as argument of the demo script:\n```bash\npython product_info_demo.py 3392460480827\n```\n\n### Meal balancing\n\nRun a simulation with the demo script similarly as below:\n```bash\npython tetris_demo.py 1000 --item_max_qty 100. --portion_size 500. --overflow_thresh 0.2 --underflow_thresh 0.1\n```\n\nwhich should return the result of the algorithm:\n```bash\n------------\nRESULT\n------------\n40 batches for 1 persons (portion of 500.0): 502 items\n1 batches for 3 persons (portion of 500.0): 27 items\n3 batches for 2 persons (portion of 500.0): 65 items\nAverage batch loss: 41.91587070338677\nNumber of remaining items: 201 portioned, 4 unportioned\nNumber of large items: 201\nNumber of unindentified items: 0\n```\n\nMany parameters can be adjusted with the previous arguments.\nTo check the full list of arguments and their meaning, use the help of the parser:\n```bash\npython tetris_demo.py -h\n```\n\n## Useful links\n\n- Understanding Git\n    - [Git Data Transport commands](https://appendtonew.wpengine.com/wp-content/uploads/2015/06/Screen-Shot-2015-06-24-at-8.37.13-PM-1024x663.png)\n    - [Git Cheat Sheet](https://www.dropbox.com/s/jsivybz7qmj4od4/git-cheat-sheet-v2.pdf?dl=0)\n- [Project Slack](https://data-for-good.slack.com)\n- [Project Trello](https://trello.com/b/X9SX81OU/algo-matching-db-open-food-fact)\n\n\n## TODO\n- [x] Implement an EAN - product information function\n- [x] Implement a naive meal balancing algorithm\n- [ ] Explore brute force and smart optimisation techniques\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdataforgoodfr%2Fbatch5_phenix_happymeal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdataforgoodfr%2Fbatch5_phenix_happymeal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdataforgoodfr%2Fbatch5_phenix_happymeal/lists"}