## 2 Methods
### Assessment of Uncertainty  
The proposed model is designed to estimate both \(\mathit{Cal}\) and \(\mathit{CPF}\) values. Under ideal conditions, the optimal values estimated by a model, denoted as \(\mathit{Cal}^{*}\) and \(\mathit{CPF}^{*}\), are characterized by the following relationship:  
\[\mathit{Cal}^{*}=\mathit{CPF}^{*}, \tag{1}\]  
\[\mathit{CPF}^{*}=(4\times\mathit{Carbohydrate}^{*})+(4\times\mathit{Protein}^{*})+(9 \times\mathit{Fat}^{*}) \tag{2}\]  
The equations indicate that the difference between \(\mathit{Cal}^{*}\) and \(\mathit{CPF}^{*}\) should be zero. However, in the real case, prediction errors are unavoidable. Moreover, due to the independent prediction paths for Cal and CPF, discrepancies can arise between these two values, despite their theoretical equivalence. Based on this motivation, we observed how the difference between the relationships varies according to the prediction performance based on the deep neural network model illustrated in Figure 1. Figure 2 displays the boxplot of errors, measured using the Symmetric Mean Absolute Percentage Error (SMAPE), between the predicted calorie values (\(\mathit{Cal}\)) and the calorie values (\(\mathit{Cal}^{\prime}\)) estimated from the predicted CPF values for the model trained to predict food components. The figure highlights both the best 30% of cases, where the model achieved the highest accuracy, and the worst 30% of cases, where the largest prediction errors occurred. The results reveal that the best and worst cases have median SMAPE values of 0.07 and 0.15, respectively. Furthermore, the upper whiskers, representing the 95 th percentile, are 0.19 and 0.55, respectively. The outliers beyond the upper whisker are plotted using the '+' symbol. These findings indicate a correlation where the SMAPE between \(\mathit{Cal}\) and \(\mathit{Cal}^{\prime}\) increases proportionally with the augmentation of estimation error, highlighting the direct impact of the error magnitudes on the model's performance metrics. In other words, this experiment demonstrates that the difference between the \(\mathit{Cal}\) and \(\mathit{Cal}^{\prime}\) values can be used to measure the model's uncertainty. Analyzing these discrepancies provides insights into the reliability of the model's predictions, thereby offering a metric for assessing its performance and robustness in practical applications.  
Motivated by these findings, we propose a metric to estimate the uncertainty, denoted as \(U_{i}\), as follows:  
\[U_{i}=\frac{\mid\mathit{Cal}_{i}-\mathit{Cal}^{\prime}_{i}\mid}{(\mid\mathit{ Cal}_{i}\mid+\mid\mathit{Cal}^{\prime}_{i}\mid)/2} \tag{3}\]  
Figure 1: Overview of the proposed system. The system combines NIR spectroscopy with an uncertainty-aware deep learning model to estimate calories and macronutrient contents (carbohydrates, proteins, and fats) in food. It analyzes NIR absorption patterns for accurate nutrient prediction and flags uncertain results to improve reliability.  
where \(i\) denotes the index of each sample. \(Cal\) is the calorie value estimated by a model, and \(Cal^{\prime}\) is the calorie value estimated from the predicted \(CPF\) values. The uncertainty values \(U_{i}\), ranging from 0.0 to 1.0, represent the global lower and upper bounds of the uncertainty function. A value of 0.0 indicates perfect prediction, while 1.0 denotes maximum uncertainty. These bounds are inherent to the metric and remain independent of the dataset, though the observed distribution of values may vary based on the specific data. Consequently, this uncertainty metric enables the model to autonomously estimate its own error. This self-assessment capability enhances the model's reliability and robustness in practical applications by providing a quantifiable measure of prediction confidence.