GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - senturkilayda/food-nutrition-segmentation: Food engineering data science project using Open Food Facts API, feature engineering, and nutrition risk segmentation.

BranchesTags
Open more actions menu

Latest commit

 

History

1 Commit
1 Commit

Folders and files

NameName
Last commit message
Last commit date
outputs
outputs
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
open_food_facts_segmentation.py
open_food_facts_segmentation.py
 
 
requirements.txt
requirements.txt
 
 

Repository files navigation

Food Nutrition Segmentation with Open Food Facts

Project Overview

This project applies a data science segmentation approach to food engineering data using Open Food Facts product information.

The main goal of the project is to analyze food products based on nutritional values such as sugar, fat, salt, protein, and additive count. These values are converted into categorical features, then combined into food profiles. Finally, the food profiles are segmented according to a custom nutrition risk score.

Project Logic

This project is inspired by previous segmentation-based data science projects.

Persona Project:

COUNTRY + SOURCE + SEX + AGE_CAT -> PRICE_SEGMENT

Planets Project:

METHOD + YEAR_CAT + NUMBER_CAT -> DISTANCE_SEGMENT

Food Engineering Adaptation:

CATEGORY + SUGAR_CAT + FAT_CAT + SALT_CAT + ADDITIVE_CAT -> NUTRITION_SEGMENT

Dataset

The data is retrieved from the Open Food Facts API.

If the Open Food Facts API is temporarily unavailable, the script uses a small educational fallback dataset to continue the project workflow.

Tools and Libraries

  • Python
  • pandas
  • NumPy
  • requests
  • Open Food Facts API
  • GitHub

Features Used

Feature Description
product_name Name of the food product
categories Product category
sugars_100g Sugar amount per 100g
fat_100g Fat amount per 100g
salt_100g Salt amount per 100g
proteins_100g Protein amount per 100g
additives_n Number of additives
nutrition_grade Nutrition grade if available

Feature Engineering

The numerical nutritional values are converted into categorical variables.

Original Feature Created Category
sugars_100g SUGAR_CAT
fat_100g FAT_CAT
salt_100g SALT_CAT
additives_n ADDITIVE_CAT

Example food profile:

SNACKS_VERY_HIGH_SUGAR_VERY_HIGH_FAT_MEDIUM_SALT_MEDIUM_ADDITIVE

Nutrition Risk Score

A custom nutrition risk score is calculated using sugar, fat, salt, additive count, and protein values.

NUTRITION_RISK_SCORE = (
    sugars_100g * 1.5 +
    fat_100g * 1.2 +
    salt_100g * 10 +
    additives_n * 2 -
    proteins_100g * 0.5
)

This score is created for educational data science practice. It is not an official health score.

Segmentation

Food profiles are grouped and segmented based on their average nutrition risk score.

Segment Meaning
A Highest risk profile
B High risk profile
C Medium risk profile
D Lower risk profile

Output Files

The project creates two CSV files in the outputs folder:

outputs/open_food_facts_dataset.csv
outputs/food_profile_segments.csv

How to Run

Install the required libraries:

pip install -r requirements.txt

Run the Python script:

python open_food_facts_segmentation.py

Project Outcome

This project demonstrates how food engineering data can be analyzed using Python, API usage, feature engineering, custom scoring, and segmentation logic.

Future Improvements

  • Add visualizations for sugar, fat, salt, and additive distributions
  • Add a machine learning model for nutrition grade prediction
  • Add a Streamlit dashboard
  • Analyze specific product categories such as dairy, snacks, beverages, or bakery products
  • Compare products by country or brand

About

Food engineering data science project using Open Food Facts API, feature engineering, and nutrition risk segmentation.

Resources

Readme
Activity

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.