Skip to content

Repository files navigation

Prediction of the Nutriscore using the OpenFoodFacts dataset

The objective of this project was to develop a protocol to predict the Nutriscore (numerical values) using the OpenFoodFacts dataset. Our final work consists in two notebooks : OFFF_notebook (containing Outlier detection and the following models : Decison Tree, RF and SVM) and OFFF_notebook_Lasso (containing the Lasso regression model).

Project steps

1. Dataset splitting

  • The first 10,000 rows of the dataset were used as the training set.
  • Rows 10,001 to 20,000 were used as the test set. This separation ensures that model performance is evaluated on unseen data.

2. Outlier detection

Applied Isolation Forest to detect outliers. After analysis and visualization, we decided not to remove any outliers since they were logical (e.g. salt appearing as a strong outlier for salt content).

3. Data filtering

Only rows containing a valid Nutriscore were kept. The dataset was also restricted to specific product categories in order to focus on a coherent subset.

4. Categorical encoding

Applied OneHotEncoder to transform categorical variables (e.g. pnns_groups1), grouping foods from similar categories such as drinks or snacks.

5. Missing value imputation

Used a KNNImputer to fill in missing values consistently based on nearest neighbors containing similar values in other categories.

6. Feature scaling

Applied RobustScaler to normalize numerical variables while reducing the influence of extreme values.

6. Feature selection

Used a Sequential Feature Selector (KNN-based) to reduce the number of features. The Sequential Feature Selector method was performed for each one of the tested models. Models were tested both with and without feature selection for comparison.

7. Modeling and optimization

Four regression models were tested:

  • Decision Tree
  • Lasso Regression
  • Support Vector Machine (SVM)
  • Random Forest

For each model, hyperparameters were tuned using Halving Grid Search and evaluation was performed using 5-fold cross-validation

Learning curves and loss functions were plotted to analyze performance.

Final evaluation

The complete protocol was applied to the test dataset to evaluate generalization performance.

Results were compared across models and between approaches (with vs. without feature selection).

About

ML project on Open Food Facts Database

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages