## 4 Hyperparameter Tuning  
The basic setup of our hyperparameter tuning experiments is to consider a group of target patients. For each target patient \(p\) at a given time \(t\) early in \(p\)'s stay in the MICU, we will find a set of patients that have a similar abnormality profile to \(p\) and use those patients to predict what to do with \(p\) in the next \(h=2\) h. Hyperparamter tuning aims to answer the following questions:  
1. Which encoding strategy for patient state leads to the best overall recommendation performance? 2. Based on the abnormalities of each target patient, which other patients should be considered \"relevant\"? Separating the Testing from the Training data set  
Out of a total of 8060 admissions to MICU patients, we sequestered a hold-out set of 800 patient admissions for our testing experiments in Section 5. The data for these patients were not used in the hyperparameter tuning experiments in this section but form the basis of the results in the next section. We have removed the 155 patients from the non-sequestered data set whose hospital stay was longer than three months. We have carried this out because such patients have little relevance to most emergency room patients. For hyperparameter tuning, we use 300 patients randomly and uniformly as targets from the non-sequestered data set of 7105 patients. For each such target patient, we selected a medical state randomly and uniformly that arose 12 to 24 h from the target patient's admission into the MICU. **Note:** Empirically, 12 h from admission is a sufficient time for the MIMIC-III database to capture a patient's state: certain lab tests such as blood cultures can take a few hours. Conversely, because patients in the early hours after admission to the ICU tend to be less stable than later on, suggesting treatments in those early hours can greatly contribute to patient well-being. As electronic records become more real-time and available, our techniques could work even earlier. Experimental Setup  
We implemented the DataToCare pipeline in Python 3.8 using the standard libraries of sklearn, multiprocessing, and UMAP. The experiments ran on Ubuntu 20.04 with 32 GB memory, 12-Core CPU, and no GPU. The random forest was built from 100 tree classifiers for each treatment. UMAP used 15 neighbors with a minimum distance of 0.2 and 200 epochs, with the result that the number of dimensions decreased by roughly a factor of 10. Metrics  
We measured prediction accuracy separately with respect to patients and with respect to treatments. In both cases, we used Precision, Recall, and F1-score. * **Accuracy with respect to patients:** We reported the average of these measures calculated on the number of patients in each experiment. Precision is defined as the number of treatments we correctly identified divided by all treatments predicted for a patient over the prediction time horizon. Recall is the number of treatments we accurately identified divided by the treatments actually given within the time horizon (regardless of whether they are in the universe of treatments given to similar patients). The F1-score is the harmonic mean of precision and recall. The F1-score is a good measure because of the highly imbalanced data: on average, there are only 2.48 treatments per patient within the time horizon (2 h), but there are 203 available treatments. The following example involving three patients illustrates how the average precision, recall, and F1-score will be calculated: 1. Patient P1: actual given treatments, 5; correctly predicted, 4; not predicted, 1; and wrongly predicted, 1. 2. Patient P2: actual given treatments, 7; correctly predicted, 5; not predicted, 2; and wrongly predicted, 4. 3. Patient P3: actual given treatments 3; correctly predicted, 1; not predicted, 2; and wrongly predicted, 2.