Skip to main page content
U.S. flag

An official website of the United States government

Dot gov

The .gov means it’s official.
Federal government websites often end in .gov or .mil. Before sharing sensitive information, make sure you’re on a federal government site.

Https

The site is secure.
The https:// ensures that you are connecting to the official website and that any information you provide is encrypted and transmitted securely.

Access keys NCBI Homepage MyNCBI Homepage Main Content Main Navigation
. 2025 Jul 9;25(14):4264.
doi: 10.3390/s25144264.

Toward a User-Accessible Spectroscopic Sensing Platform for Beverage Recognition Through K-Nearest Neighbors Algorithm

Affiliations

Toward a User-Accessible Spectroscopic Sensing Platform for Beverage Recognition Through K-Nearest Neighbors Algorithm

Luca Montaina et al. Sensors (Basel). .

Abstract

Proper nutrition is a fundamental aspect to maintaining overall health and well-being, influencing both physical and social aspects of human life; an unbalanced or inadequate diet can lead to various nutritional deficiencies and chronic health conditions. In today's fast-paced world, monitoring nutritional intake has become increasingly important, particularly for those with specific dietary needs. While smartphone-based applications using image recognition have simplified food tracking, they still rely heavily on user interaction and raise concerns about practicality and privacy. To address these limitations, this paper proposes a novel, compact spectroscopic sensing platform for automatic beverage recognition. The system utilizes the AS7265x commercial sensor to capture the spectral signature of beverages, combined with a K-Nearest Neighbors (KNN) machine learning algorithm for classification. The approach is designed for integration into everyday objects, such as smart glasses or cups, offering a noninvasive and user-friendly alternative to manual tracking. Through optimization of both the sensor configuration and KNN parameters, we identified a reduced set of four wavelengths that achieves over 96% classification accuracy across a diverse range of common beverages. This demonstrates the potential for embedding accurate, low-power, and cost-efficient sensors into Internet of Things (IoT) devices for real-time nutritional monitoring, reducing the need for user input while enhancing accessibility and usability.

Keywords: IoT devices; KNN; beverage recognition; diet monitoring; machine learning; public health; sensing platform; smart cutlery.

PubMed Disclaimer

Conflict of interest statement

The authors declare no conflicts of interest.

Figures

Figure 1
Figure 1
(a) Distribution of peak absorption for the AS7265x kit sensor [26] and (b) normalized emission spectra of the LED as measured with Photonic Multi-channel Analyzer PMA-12.
Figure 2
Figure 2
(a) 3D renders and (b) photo of the system setup.
Figure 3
Figure 3
Two-dimensional example of KNN (K = 3) classification algorithm: (a) training dataset with two classes (labeled green and orange dots). (b) A new unclassified data is added to the graph (white dot) and compared with the 3 nearest neighbors. (c) The new data is then assigned to the category whose number of first neighbors is highest (green).
Figure 4
Figure 4
Normalized beverage light absorption as a function of the wavelength.
Figure 5
Figure 5
Accuracy of the KNN model as a function of the K nearest neighbors as average (red dots) respect to the several K-fold tests performed.
Figure 6
Figure 6
Confusion matrix of the KNN model (K = 1), showing the classification performance across the different beverages.
Figure 7
Figure 7
Accuracy of the KNN model as a function of the wavelengths combination.
Figure 8
Figure 8
Confusion matrix of the KNN model (K = 1), illustrating beverage classification performance using the optimized wavelengths (460, 535, 610, and 810 nm).

Similar articles

References

    1. Khot R.A., Mueller F. Human-Food Interaction. Found. Trends® Hum.–Comput. Interact. 2019;12:238–415. doi: 10.1561/1100000074. - DOI
    1. Peuhkuri K., Sihvola N., Korpela R. Diet Promotes Sleep Duration and Quality. Nutr. Res. 2012;32:309–319. doi: 10.1016/j.nutres.2012.03.009. - DOI - PubMed
    1. St-Onge M.P., Mikic A., Pietrolungo C.E. Effects of Diet on Sleep Quality. Adv. Nutr. 2016;7:938–949. doi: 10.3945/AN.116.012336. - DOI - PMC - PubMed
    1. Bellisle F. Effects of Diet on Behaviour and Cognition in Children. Br. J. Nutr. 2004;92((Suppl. S2)):S227–S232. doi: 10.1079/BJN20041171. - DOI - PubMed
    1. Block G., Azar K.M.J., Romanelli R.J., Block T.J., Palaniappan L.P., Dolginsky M., Block C.H. Improving Diet, Activity and Wellness in Adults at Risk of Diabetes: Randomized Controlled Trial. Nutr. Diabetes. 2016;6:e231. doi: 10.1038/nutd.2016.42. - DOI - PMC - PubMed

LinkOut - more resources