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).
- 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.
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).
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.
Applied OneHotEncoder to transform categorical variables (e.g. pnns_groups1), grouping foods from similar categories such as drinks or snacks.
Used a KNNImputer to fill in missing values consistently based on nearest neighbors containing similar values in other categories.
Applied RobustScaler to normalize numerical variables while reducing the influence of extreme values.
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.
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.
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).