| ---
|
| language:
|
| - en
|
| - fr
|
| - es
|
| - de
|
| - it
|
| - pt
|
| - nl
|
| license: apache-2.0
|
| tags:
|
| - tabular
|
| - multi-modal
|
| - nutriscore
|
| - nutrition
|
| pipeline_tag: tabular-classification
|
| datasets:
|
| - hsilvosa/open-food-facts
|
| metrics:
|
| - accuracy
|
| - mae
|
| - r2
|
| ---
|
|
|
| # Nutri-Score Multi-Modal Tabular Predictor
|
|
|
| This model estimates Nutri-Score grades (A, B, C, D, E) and continuous numerical scores when nutritional values are partially or fully missing.
|
|
|
| ## Dataset
|
|
|
| Trained on [hsilvosa/open-food-facts](https://huggingface.co/datasets/hsilvosa/open-food-facts).
|
|
|
| ## Model Description
|
|
|
| Nutri-Score is a front-of-pack nutritional rating system ranging from A (highest nutritional quality) to E (lowest). When product labels have missing macronutrient values (e.g., missing fiber or sodium content), standard rule-based calculators fail.
|
|
|
| This multi-modal ensemble combines:
|
| 1. Available continuous macronutrients (energy, fat, saturated fat, sugars, proteins, fiber, sodium, salt).
|
| 2. Explicit missingness indicator masks for each nutrient.
|
| 3. Derived nutrient ratios (sugars-to-carbs, sat-to-total-fat, energy density).
|
| 4. Embedded product name, category, and ingredient list text representations.
|
|
|
| ## Performance Metrics
|
|
|
| | Metric | Score |
|
| |---|---|
|
| | **Grade Top-1 Accuracy** | **83.33%** |
|
| | **Grade Top-2 Accuracy** | **93.40%** |
|
| | **Numeric Score R²** | **0.9051** (90.5% Variance Explained) |
|
| | **Mean Absolute Error (MAE)** | **1.95 points** |
|
| | **Median Absolute Error** | **0.95 points** |
|
| | **Weighted F1-Score** | **0.8353** |
|
|
|
| ## Python Usage Example
|
|
|
| ```python
|
| from src.models.nutriscore_predictor import NutriScorePredictor
|
| import pandas as pd
|
|
|
| predictor = NutriScorePredictor.from_pretrained("your-username/nutriscore-predictor")
|
|
|
| sample_product = pd.DataFrame([{
|
| "product_name": "Organic Oat Drink",
|
| "categories": "Plant-based beverages",
|
| "ingredients_text": "Water, oats (12%), sunflower oil, sea salt.",
|
| "energy-kcal_100g": 45.0,
|
| "fat_100g": 1.5,
|
| "sugars_100g": 4.0,
|
| "proteins_100g": 0.8,
|
| }])
|
|
|
| prediction = predictor.predict(sample_product)[0]
|
| print(f"Predicted Grade: {prediction['predicted_grade']}")
|
| print(f"Predicted Score: {prediction['predicted_score']:.2f}")
|
| ``` |