Abstract
Milk adulteration remains a significant global food safety concern, given the widespread consumption of milk by billions worldwide. This study presents a soft sensor for quantifying concentrations of common milk adulterants, including ammonia, urea, sugar, and hydrogen peroxide. The approach integrates near-infrared (NIR) spectroscopy with a chemometric framework for real-time measurement. Orthogonal partial least squares (OPLS) was coupled with the XGBoost algorithm, leveraging its ensemble boosting mechanism and resistance to overfitting. K-means random clustering was used to organize experimental trials during model development. The soft sensor demonstrated high predictive performance, with root mean squared error (RMSE), normalized root mean squared error (NRMSE), and cross validation –coefficient of correlation (CV-R~2 ) values of 0.01, 0.02, and 0.97 for urea; 0.01, 0.02, and 0.96 for ammonium sulfate; 0.07, 0.13, and 0.95 for sugar; and 0.01, 0.03, and 0.94 for H_2 O2 . For all the adulterants, R~2 and the other variants of R2 (adjusted and multiple) values were higher than 0.95, thereby demonstrating the exceptional performance of the developed soft sensor. The soft sensor provided accurate real-time values with an average error rate of less than 10%. Overall, the results demonstrate that the developed NIR-chemometric soft sensor provides a rapid, non-destructive, and reliable method for detecting and quantifying multiple milk adulterants in real time, offering significant potential for food safety monitoring.