## 2 Material and Methods
### Data Overview  
CGM usage has experienced an extraordinary growth in recent years and its data is easier to access by researchers than before. Indeed, diabetes management software such as Tidepool or SocialDiabetes gather and store this data, facilitating data curation and access by researchers [20; 21]. Furthermore, full repositories of experimental CGM data are freely available to download e.g., the rePLACE-BG diabetes dataset [22]. In this work, we opted to use in silico data consisting of two datasets (one for training, one for validation) of ten virtual adults from the educational version of the UVA/Padova simulator [23], with an exercise model add-on [24], and additional sources of intra-patient variability. Both sets of data were generated following open loop therapy (basal insulin and ratios provided by the simulator were used). The main characteristics (events and variability) of the simulated scenario were chosen to represent as closely as possible the real life of people with T1D, and are summarized next:  
* A nominal day with three meals of 40, 90 and 60 g of carbohydrates at 7:00, 14:00 and 21:00 h were simulated.
* Actual mealtime and carbohydrate intake varied around nominal values following a normal distribution with a standard deviation of 20 min for mealtime, and a 10% coefficient of variance for meal size.
* Meal absorption dynamics were changed at each meal by randomly selecting one of the meal model parameter sets available from the simulator [23].
* Meal absorption rate at each meal changed within a uniform distribution in \(\pm\)30%, and carbohydrate bioavailability in \(\pm\)10% around selected nominal values.
* Carbohydrate counting errors by the patient were considered to follow a uniform distribution between \(-\)30% and +10%, following results in [25] where a trend to meal underestimation is reported.
* Insulin absorption pharmacokinetics varied in \(\pm\)30%, according to the intra-patient variability reported in [26].
* Circadian variability of insulin sensitivity was considered with variations in \(\pm\)30% around nominal sensitivity, reproducing changes in basal insulin requirements in the adult population reported in [27].
* The 15-15 rule [28] was used to treat hypoglycemia (15 g of carbohydrates were administered when glucose went below 70 mg/dL, and repeated if after 15 min hypoglycemia was still present).  
Training and validation datasets were generated using the same scenario. Four months of data were generated for the training dataset, representing the maximum data per patient available. The actual length of training data used was varied in the study performed according to the scenarios described in Section 2.8. A fixed length of two months was considered for the validation dataset.  
In both datasets, besides CGM data, time stamps and labels for the following events were generated: _Breakfast, Lunch, Dinner, Night_ and _Hypoglycemia treatment_. The _Night_ event was considered to start 6 h after dinner. All rescue carbs administered in a hypoglycemia treatment were gathered in a single _Hypoglycemia treatment_ event, starting at the time of the first rescue carb intake. This will be represented, for each patient \(p=1,\ldots,10\), by the set of time-ordered pairs  
\[\mathcal{E}^{p}:=\{(t_{c_{i}},\mathcal{L}_{e_{i}})\ \mid\ i=1,\ldots,n_{e}\}, \tag{1}\]  
where \(t_{c_{i}}\) is the timestamp for the \(i\)-th event, \(t_{c_{i}}<t_{c_{i+1}}\), \(\mathcal{L}_{e_{i}}\) is the label of the \(i\)-th event, \(\mathcal{L}_{e_{i}}\in\{\)_Breakfast, Lunch, Dinner, Night, Hypoglycemia treatment_\(\}\), and \(n_{e}\) is the number of events.