Low-Cost Sensor Fusion Framework for Organic Substance Classification and Quality Control Using Classification Methods
Low-Cost Sensor Fusion Framework for Organic Substance Classification and Quality Control Using Classification Methods
Chowdhury, B. U., Molina, D. V., & Shougat, M. R. E. U., "Low-Cost Sensor Fusion Framework for Organic Substance Classification and Quality Control Using Classification Methods," 2025 IEEE International Conference on Future Machine Learning and Data Science (FMLDS)
Abstract— We present a sensor-fusion framework for rapid, non-destructive classification and quality control of organic substances, built on a standard Arduino Mega 2560 microcontroller platform equipped with three commercial environmental and gas sensors. All data used in this study were generated in-house: sensor outputs for ten distinct classes—including fresh and expired samples of apple juice, onion, garlic, and ginger, as well as cinnamon and cardamom—were systematically collected and labeled using this hardware setup, resulting in a unique, application-specific dataset. Correlation analysis was employed as part of the preprocessing pipeline for feature selection. After preprocessing and dimensionality reduction (PCA/LDA), multiple supervised learning models—including Support Vector Machine (SVM), Decision Tree (DT), and Random Forest (RF), each with hyperparameter tuning, as well as an Artificial Neural Network (ANN) and an ensemble voting classifier—were trained and cross-validated on the collected dataset. The best-performing models, including tuned Random Forest, ensemble, and ANN, achieved test accuracies in the 93–94% range. These results demonstrate that low-cost, multisensory platforms based on the Arduino Mega 2560, combined with advanced machine learning and correlation-driven feature engineering, enable reliable identification and quality control of organic compounds.
Data was collected using an Arduino Mega 2560 equipped with three sensors: the Grove Multichannel Gas Sensor V2, Grove SGP30, and Grove BME680. These sensors measured various environmental and chemical parameters, including CO, NO₂, VOCs, ethanol, CO₂, TVOC, temperature, humidity, and pressure. The dataset comprised ten classes—fresh and expired variants of apple juice, onion, garlic, and ginger, along with cinnamon and cardamom. For each class, 10,000 samples were recorded. Sensor readings were collected over multiple runs and stored in individual CSV files, each containing all feature columns and a class label. These files were subsequently merged into a single master dataset, resulting in 100,000 samples. The dataset was balanced and underwent quality assurance through sensor calibration, stabilization before logging, and preprocessing techniques to address noise and potential anomalies. Fig. 2 shows the overall sensor integration and data acquisition workflow used to generate the dataset.
Fig. 3. Flowchart of Model Development and ANN Architecture Exploration.
In total, 26 distinct models were developed and evaluated, comprising twelve baseline traditional models across four dataset versions, three tuned classifiers on the selected V2 feature set, one ensemble model, and ten ANN variants (spanning five architectural configurations on both original and reduced feature sets).
Fig. 4. Correlation of individual sensor features with the target class label.
Feature Correlation Analysis before applying dimensionality reduction and modeling, correlation analysis was performed to evaluate the relationship between each feature and the target variable. As shown in Fig. 4, pressure exhibited the highest positive correlation with the target, followed by CO and VOC1. Conversely, temperature showed a strong negative correlation.
While this may suggest that pressure and temperature are essential predictors, their correlation is likely due to uncontrolled environmental conditions during data collection. Since pressure and temperature were not consistently maintained across samples, their inclusion could lead to an inflated model performance by capturing ambient drift rather than substance-specific characteristics.
These two features were excluded in version V2 and beyond to avoid overfitting and ensure that classification is based on meaningful chemical signals rather than external environmental factors.
Fig. 5. LDA and PCA projection on the complete and reduced feature sets.
Fig. 6. t-SNE and UMAP projection on the complete and reduced feature sets.
Fig. 7. Cross-validation accuracy comparison of SVM, Random Forest (RF), and Decision Tree (DT) across four dataset versions (V1–V4).
Cross-validation accuracies were compared across four dataset versions (V1–V4) for each classifier (SVM, RF, DT) to evaluate the impact of feature engineering and dimensionality reduction. The results are presented in Fig. 7.
V1 and V2 outperformed the other versions, achieving the highest accuracy across all three models. While V1, which includes all features, consistently yielded slightly higher accuracy than V2, the difference was marginal, typically around 0.1%, and likely influenced by uncontrolled environmental variations. Since V2 excludes temperature and pressure, it avoids learning from potentially spurious patterns
caused by ambient drift. Given the minimal performance trade-off, reduced complexity, and improved generalizability, V2 was selected as the final version for model tuning and further evaluation.
Fig. 8. CV accuracy before and after hyperparameter tuning for SVM, RF, and DT models.
To improve the baseline model’s performance on the selected V2 feature set, hyperparameter tuning was performed using GridSearchCV with stratified 5-fold cross-validation. Parameter grids were defined separately for each classifier—SVM, Random Forest (RF), and Decision Tree (DT)—exploring different kernel types and regularization strengths for SVM, maximum depth and minimum leaf sizes for DT, and tree count and feature subset sizes for RF.
The best cross-validation and evaluation scores obtained after tuning were:
· SVM (CV): 0.9272, Train: 0.9304, Test: 0.9301
· RF (CV): 0.9425, Train: 0.9438, Test: 0.9427
· DT (CV): 0.9385, Train: 0.9397, Test: 0.9396
These improvements were particularly notable for RF and DT compared to their untuned counterparts. Fig. 8 compares cross-validation accuracies before and after tuning for all three classifiers to visualize the effectiveness of hyperparameter tuning. The improvement across models confirms the benefits of targeted tuning.
Fig. 9. Tuned learning curves for SVM, Random Forest (RF), and Decision Tree (DT) models on the V2 feature set.
Additionally, learning curves for the tuned models were plotted to assess generalization performance. As shown in Fig. 9, training and validation curves converged steadily as the sample size increased, indicating low variance and minimal overfitting. All three models continued to improve with additional training data, suggesting capacity for further enhancement.
These results validate both the effectiveness and stability of the optimized models.
Fig. 10. Learning curve for the Ensemble model.
Fig. 11. Confusion matrix of the ensemble model on the test set.
A soft-voting ensemble was constructed using the tuned SVM, RF, and DT models to improve classification robustness. Each model contributed probabilistic predictions, and the final class label was determined by averaging the predicted probabilities and selecting the class with the highest consensus. Fig. 10 shows the learning curve of the ensemble model. The ensemble demonstrates stable convergence, with validation accuracy closely tracking training performance as the dataset size increases.
Fig. 12. Confusion matrix of the tuned Random Forest on the test set.
Fig. 13. ROC curve for the Random Forest model on the test set.
TABLE I. Classification Report of the Tuned Random Forest Model on the Test Set
After hyperparameter tuning, the Random Forest (RF) model emerged as the top-performing individual classifier. It consistently achieved the highest scores across all evaluation metrics:
· Cross-Validation Accuracy: 94.25%
· Train Accuracy: 94.38%
· Test Accuracy: 94.27%
These results underscore RF's ability to generalize well while maintaining a low variance between training and test performance. Fig. 12 presents the confusion matrix for the test set. The model demonstrates excellent discrimination, correctly classifying most instances with minimal class confusion.
Table I displays the classification report test set, confirming high macro-averaged precision, recall, and F1-scores above 0.94.
Fig. 13 shows the ROC curve for the tuned RF model, which exhibits near-perfect separation with micro- and macro-average AUC values approaching 1.00. The tuned Random Forest is the strongest candidate based on accuracy, generalization, and class-wise performance. While it outperformed the ensemble model across key metrics, further evaluation is required before final model selection. The following section will explore and compare the performance of various ANN architectures to tuned Random Forest and ensemble benchmarks.
Fig. 14. Train, validation, and test accuracies of five ANN variants using all features.
Fig. 15. Train, validation, and test accuracy of five ANN variants with temperature and pressure dropped.
To identify the most effective ANN design, five variants were evaluated on all features, including the dropped feature set (excluding temperature and pressure)
· Baseline: Standard sequential model with three dense layers
· Deeper: Increased number of hidden layers
· Wider: Increased neurons per layer
· L2 Regularization: Added weight penalties to reduce overfitting
· RMSprop Optimizer: Switched from Adam to RMSprop
Fig. 14 and Fig. 15 present train, validation, and test accuracies for all five ANN architectures on the complete and reduced feature sets, respectively.
Fig. 16. Loss and accuracy curves of the wider ANN model with dropped features.
Fig. 17. Confusion matrix of the wider ANN model with dropped features on the test set.
TABLE II. Classification Report of the Wider ANN Model with Dropped Features on Test Set
Despite this strong performance, the ANN model slightly underperformed the tuned Random Forest, which achieved a test accuracy of 94.27%. However, the ANN's performance was comparable, and generalization was robust, reinforcing that the ANN is a viable alternative classification method in sensor fusion.
This project demonstrates that a low-cost sensor fusion system, built around Arduino Mega 2560 and commercial gas sensors, provides a highly effective and affordable solution for rapid, non-destructive quality control of organic substances. The tuned Random Forest (RF) classifier was selected as the best-performing approach through rigorous model development and evaluation. It achieved a test accuracy of 94.27%, outperforming other models such as SVM, Decision Tree, ANN, and even the ensemble method. The tuned RF model delivered the highest accuracy and showed excellent generalization and balanced class-wise performance, reliably distinguishing between fresh and expired substances across multiple organic classes.
This approach is very cheap compared to traditional laboratory methods, leveraging affordable hardware and open-source tools. The system enables reliable, on-site identification of organic substance quality, including spoilage detection, making advanced quality control accessible even for small producers or resource-limited settings.
Collecting more data and performing deeper hyperparameter tuning for future work can further improve results. Additionally, maintaining consistent temperature and pressure conditions during data collection will allow these features to be reliably integrated into the model, further enhancing classification performance.