hsilvosa commited on
Commit
1002ccc
·
verified ·
1 Parent(s): d6894c3

Upload Nutri-Score predictor model

Browse files
Files changed (5) hide show
  1. README.md +75 -0
  2. clf_model.joblib +3 -0
  3. config.json +149 -0
  4. pytorch_model.bin +3 -0
  5. reg_model.joblib +3 -0
README.md ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - fr
5
+ - es
6
+ - de
7
+ - it
8
+ - pt
9
+ - nl
10
+ license: apache-2.0
11
+ tags:
12
+ - tabular
13
+ - multi-modal
14
+ - nutriscore
15
+ - nutrition
16
+ pipeline_tag: tabular-classification
17
+ datasets:
18
+ - hsilvosa/open-food-facts
19
+ metrics:
20
+ - accuracy
21
+ - mae
22
+ - r2
23
+ ---
24
+
25
+ # Nutri-Score Multi-Modal Tabular Predictor
26
+
27
+ This model estimates Nutri-Score grades (A, B, C, D, E) and continuous numerical scores when nutritional values are partially or fully missing.
28
+
29
+ ## Dataset
30
+
31
+ Trained on [hsilvosa/open-food-facts](https://huggingface.co/datasets/hsilvosa/open-food-facts).
32
+
33
+ ## Model Description
34
+
35
+ 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.
36
+
37
+ This multi-modal ensemble combines:
38
+ 1. Available continuous macronutrients (energy, fat, saturated fat, sugars, proteins, fiber, sodium, salt).
39
+ 2. Explicit missingness indicator masks for each nutrient.
40
+ 3. Derived nutrient ratios (sugars-to-carbs, sat-to-total-fat, energy density).
41
+ 4. Embedded product name, category, and ingredient list text representations.
42
+
43
+ ## Performance Metrics
44
+
45
+ | Metric | Score |
46
+ |---|---|
47
+ | **Grade Top-1 Accuracy** | **83.33%** |
48
+ | **Grade Top-2 Accuracy** | **93.40%** |
49
+ | **Numeric Score R²** | **0.9051** (90.5% Variance Explained) |
50
+ | **Mean Absolute Error (MAE)** | **1.95 points** |
51
+ | **Median Absolute Error** | **0.95 points** |
52
+ | **Weighted F1-Score** | **0.8353** |
53
+
54
+ ## Python Usage Example
55
+
56
+ ```python
57
+ from src.models.nutriscore_predictor import NutriScorePredictor
58
+ import pandas as pd
59
+
60
+ predictor = NutriScorePredictor.from_pretrained("your-username/nutriscore-predictor")
61
+
62
+ sample_product = pd.DataFrame([{
63
+ "product_name": "Organic Oat Drink",
64
+ "categories": "Plant-based beverages",
65
+ "ingredients_text": "Water, oats (12%), sunflower oil, sea salt.",
66
+ "energy-kcal_100g": 45.0,
67
+ "fat_100g": 1.5,
68
+ "sugars_100g": 4.0,
69
+ "proteins_100g": 0.8,
70
+ }])
71
+
72
+ prediction = predictor.predict(sample_product)[0]
73
+ print(f"Predicted Grade: {prediction['predicted_grade']}")
74
+ print(f"Predicted Score: {prediction['predicted_score']:.2f}")
75
+ ```
clf_model.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:93270fa66e10dcc6ab29d96333ee643e4a8bbb770eabad237a17d47715d2c7c0
3
+ size 2761160
config.json ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "text_features": 64,
3
+ "nutrient_means": {
4
+ "energy-kcal_100g": 593.3308824394151,
5
+ "fat_100g": 30.74013926932252,
6
+ "saturated-fat_100g": 10.32354276398921,
7
+ "sugars_100g": 34.56173870053036,
8
+ "carbohydrates_100g": 68.65251908164707,
9
+ "proteins_100g": 13.128354332154984,
10
+ "fiber_100g": 5.057634242792158,
11
+ "salt_100g": 1.2142082413442563,
12
+ "sodium_100g": 0.48557621082556474,
13
+ "sugars_carbs_ratio": 0.5028519837786664,
14
+ "sat_total_fat_ratio": 0.3146704924893529,
15
+ "additive_count": 1.7563809523809524
16
+ },
17
+ "vocab": {
18
+ "enriched": 18,
19
+ "iron": 27,
20
+ "niacin": 35,
21
+ "mononitrate": 32,
22
+ "folic": 22,
23
+ "acid": 0,
24
+ "wheat": 61,
25
+ "flour": 21,
26
+ "riboflavin": 45,
27
+ "salt": 46,
28
+ "sugar": 54,
29
+ "soy": 49,
30
+ "natural": 33,
31
+ "flavors": 20,
32
+ "onion": 37,
33
+ "powder": 43,
34
+ "garlic": 25,
35
+ "folic acid": 23,
36
+ "wheat flour": 62,
37
+ "cream": 17,
38
+ "foods": 24,
39
+ "milk": 30,
40
+ "chocolate": 8,
41
+ "oil": 36,
42
+ "cocoa": 11,
43
+ "lecithin": 29,
44
+ "corn": 15,
45
+ "syrup": 55,
46
+ "contains": 14,
47
+ "artificial": 1,
48
+ "gum": 26,
49
+ "color": 12,
50
+ "soy lecithin": 50,
51
+ "corn syrup": 16,
52
+ "water": 60,
53
+ "vegetable": 57,
54
+ "soybean": 51,
55
+ "yellow": 63,
56
+ "sodium": 48,
57
+ "cheese": 7,
58
+ "palm": 39,
59
+ "modified": 31,
60
+ "starch": 53,
61
+ "red": 44,
62
+ "calcium": 6,
63
+ "citric": 9,
64
+ "flavor": 19,
65
+ "citric acid": 10,
66
+ "undefined": 56,
67
+ "organic": 38,
68
+ "vinegar": 58,
69
+ "concentrate": 13,
70
+ "soybean oil": 52,
71
+ "plant": 40,
72
+ "based": 2,
73
+ "beverages": 4,
74
+ "plant based": 41,
75
+ "based foods": 3,
76
+ "juice": 28,
77
+ "snacks": 47,
78
+ "butter": 5,
79
+ "potassium": 42,
80
+ "vitamin": 59,
81
+ "natural flavor": 34
82
+ },
83
+ "idf": [
84
+ 1.8519114420218497,
85
+ 2.7501168981829807,
86
+ 3.098720521521592,
87
+ 3.1238889754618433,
88
+ 2.910912425226381,
89
+ 3.267541391096644,
90
+ 2.9603948147669508,
91
+ 3.251125153761982,
92
+ 3.616691352692227,
93
+ 2.4549267705313707,
94
+ 2.4614761185427927,
95
+ 3.3912037450891903,
96
+ 2.5969454393657947,
97
+ 3.1987017880596817,
98
+ 2.607582580201883,
99
+ 2.0094723278095072,
100
+ 2.485794058005419,
101
+ 3.2652451788362935,
102
+ 3.0465150219604964,
103
+ 2.323233050705782,
104
+ 2.826102805160903,
105
+ 2.46972358797281,
106
+ 2.879234134926273,
107
+ 2.88173179466991,
108
+ 2.6575259756268546,
109
+ 2.945291322426021,
110
+ 2.820206561663621,
111
+ 2.954662207599328,
112
+ 3.0513182826270078,
113
+ 3.017811870737165,
114
+ 2.287229513279695,
115
+ 2.858557576688348,
116
+ 2.909304449321146,
117
+ 1.9606386086846033,
118
+ 3.0153078451039748,
119
+ 2.9287729422150806,
120
+ 1.9507326336737227,
121
+ 3.138733781666995,
122
+ 3.7363503319679623,
123
+ 3.177469567953908,
124
+ 3.117537227231234,
125
+ 3.1215023394841124,
126
+ 3.1215023394841124,
127
+ 2.9719595695081824,
128
+ 2.924196275187669,
129
+ 2.8898925430362326,
130
+ 1.5203625677009747,
131
+ 2.9654804334580454,
132
+ 2.4123926562337012,
133
+ 2.7435612887997607,
134
+ 3.171186824774413,
135
+ 2.742200929455162,
136
+ 3.058380196383469,
137
+ 2.566608505991577,
138
+ 1.7561853120443869,
139
+ 2.324306588114306,
140
+ 1.7565911150326077,
141
+ 2.8880033737086253,
142
+ 3.1346998915660587,
143
+ 3.076446175123119,
144
+ 1.8058836884934775,
145
+ 2.4961568450409652,
146
+ 2.737860173860243,
147
+ 3.208188706991438
148
+ ]
149
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e897aee736df6acd7096c0be40d89b12d8b298a88d2802c6b50657f46fb2b63f
3
+ size 85885
reg_model.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b6672434b05ff626fc6e5c613c0d2ad1e41e5f3c49b65bf10656eec7e40e6c7c
3
+ size 591150