## 3 Results and Discussion  
By using data generated from the UVA/Padova simulator, the outcome and risk prediction models were built based on gradient descend and the stochastic variational inference. Figure 3 shows the MSE of the training and testing data during the training process of the feedforward neural networks. Table 3 shows the final ELBO (defined by Equation (14)) of the Bayesian neural networks under without and with noise in the CGM measurements. Figure 4 shows the training data and predictions made by the models for different carbohydrate values without and with CGM noise, respectively. The deterministic reward prediction is represented by the solid red line. The predicted risks with 90%-confidence intervals are represented by a green and a blue-shaded uncertainty bands in the figure, correspondingly to the hypoglycemia and hyperglycemia risks, respectively.  
It can be seen from Figure 3 and Table 3 that the prediction errors are higher when measurement noise is introduced. Consequently, Figure 4 shows that the predicted risk uncertainty bands are wider when there is measurement noise, indicating that the predicted risk cannot be accurately predicted compared to nominal condition.  
Based on the prediction models of the reward and risks, safe and optimal actions are derived as shown in Table 4. Safe actions are defined as actions that have a 90% probability of the hypoglycemia risk under 5 and the hyperglycemia risk under 7. The risk thresholds reflect that higher emphasis was put on hypoglycemia due to the higher adverse effects of getting hypoglycemia. It can be seen that the lower and upper bound for safe actions are tighter under noise conditions, since the risk models capture the uncertainties and provide more conservative recommendations under more uncertain condition. The optimal recommendation is chosen among the safe actions that maximize the blood glucose outcome predicted by the deterministic feedforward neural network. Hence the value is the same for both conditions when there is CGM noise and when there is no CGM noise.  
\begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Risk** & \multicolumn{2}{c}{**Training**} & \multicolumn{2}{c}{**Validation**} \\ \hline  & **without Noise** & **with Noise** & **without Noise** & **with Noise** \\ \hline Hyperglycemia & 0.4198 & 0.0632 & 0.5340 & 0.0307 \\ Hypoglycemia & \(-\)0.4650 & \(-\)0.7172 & \(-\)0.3112 & \(-\)1.0458 \\ \hline \hline \end{tabular}
\end{table}
Table 3: Evidence lower bound (ELBO) of the risk models for training and validation data.  
Figures 5 and 6 show different ranges of blood glucose when the patient follows the optimal recommendation, consumes food within the safe recommendation actions, or takes food with carbohydrate amounts between 0 and 200 g. The distribution of blood glucose measurement according to food intakes at certain time points can also be seen in the figures. The results show that the range of blood glucose responses to the optimal and safe actions are significantly better than the range of blood glucose when any action can be selected. The blood glucose range is slightly narrower in the case with CGM noise since the recommendation is more conservative in order to compensate for uncertainties in the responses.  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Action Type** & **No Noise** & **with Noise** \\ \hline Safe lower & 26.3 & 34.3 \\ Safe upper & 74.7 & 60.6 \\ Optimal & 50.2 & 50.2 \\ \hline \hline \end{tabular}
\end{table}
Table 4: Recommended actions (grams of carbohydrates).  
Figure 4: Training data (dots and cross), predicted outcome and risks under no CGM noise (**a**), and CGM noise (**b**). Green and blue shaded uncertainty bands represent the 90% confident intervals for hypoglycemia and hyperglycemia risks respectively.  
Figure 3: Training (solid blue line) and testing (orange dashed line) error without CGM measurement noise (**a**) and with CGM measurement noise (**b**).