## 2 Materials and Methods
### Confirmation of Predictive Contributors Using the Mchine Learning Interpretation Method  
We used Shapley additive explanations (SHAP), a model-agnostic method of machine learning, to visualize the relationship between predictors and delirium. SHAP is an excellent method for visualizing the contribution of predictors. Shapley values are guaranteed to be fairly distributed in cooperative game theory [38]. The SHAP algorithm is an additive feature attribution method that approximates each prediction \(f(x)\) with \(g(z^{\prime})\), a linear function of the binary variables \(z^{\prime}\in\left\{0,1\right\}^{M}\) and the feature attribution values \(\phi_{i}\in\mathbb{R}\), which are defined as follows:  
\[g(z^{\prime})=\phi_{0}+\sum_{i=1}^{M}\phi_{i}z^{\prime}_{i}, \tag{1}\]  
where \(M\) is the number of predictors.  
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Predictors** & **Overall** & **No Delirium** & **Delirium** & **\(p\) Value** & **\% Missing** \\  & **n = 55,389** & **n = 50,928** & **n = 4461** & \(p\) Value** & **\% Missing** \\ \hline Predisposing risk factors & & & & & \\ Age, year & 73.0 (64.0–82.0) & 72.0 (64.0–81.0) & 83.0 (74.0–89.0) & \textless{}0.001 & 0.0 \\ Body mass index, kg/m\({}^{2}\) & 22.5 (20.0–25.1) & 22.7 (20.2–25.3) & 20.6 (18.2–23.2) & \textless{}0.001 & 1.1 \\ Men & 33,829 (61.1) & 31,474 (61.8) & 2355 (52.8) & \textless{}0.001 & 0.0 \\ Intake of benzodiazep medications & 977 (1.8) & 812 (1.7) & 165 (3.8) & \textless{}0.001 & 4.4 \\ Intake of opioid medications & 896 (1.7) & 690 (1.4) & 206 (4.7) & \textless{}0.001 & 4.4 \\ Intake of steroid medications & 1829 (3.5) & 1573 (3.2) & 256 (5.9) & \textless{}0.001 & 4.4 \\ Dementia & 4907 (9.3) & 3450 (7.1) & 1457 (33.3) & \textless{}0.001 & 4.4 \\ Brain tissue disorder & 7028 (13.3) & 5950 (12.3) & 1078 (24.7) & \textless{}0.001 & 4.4 \\ Heavy drinker & 878 (1.7) & 701 (1.4) & 177 (4.0) & \textless{}0.001 & 4.4 \\ History of delirium & 1307 (2.5) & 802 (1.7) & 505 (11.5) & \textless{}0.001 & 4.4 \\ Emergency hospitalization & 30,043 (54.2) & 26,075 (51.2) & 3968 (88.9) & \textless{}0.001 & 0.0 \\ Use of ambulance & 19,189 (34.6) & 15,948 (31.3) & 3241 (72.7) & \textless{}0.001 & 0.0 \\ Room at hospitalization & & & & \textless{}0.001 & 0.0 \\ Bay of general ward & 16,139 (29.1) & 15,570 (30.6) & 569 (12.8) & & \\ Intensive care unit & 12,216 (22.1) & 9661 (19.0) & 2555 (57.3) & & \\ Private room of general ward & 27,034 (48.8) & 25,697 (50.5) & 1337 (30.0) & & \\ Schedule of treatment & & & & \textless{}0.001 & 0.0 \\ Catheterization & 7249 (13.1) & 6950 (13.6) & 299 (6.7) & & \\ Endoscopic treatment & 5032 (9.1) & 4792 (9.4) & 240 (5.4) & & \\ Preserved treatment & 23,554 (42.5) & 21,421 (42.1) & 2133 (47.8) & & \\ Surgery & 19,554 (35.3) & 17,765 (34.9) & 1789 (40.1) & & \\ \hline \hline \end{tabular} Data are expressed as median (interquartile range), number (%).  
\end{table}
Table 1: Predictor characteristics in analysis population A.  
The SHAP value \(\phi_{i}\) is defined as follows:  
\[\phi_{i}=\sum_{S\subseteq N\setminus\{i\}}\frac{|S|!(M-|S|-1)!}{M\,!}[f_{x}(S \cup\{i\})-f_{x}(S)], \tag{2}\]  
where \(f\) is the model, \(N\) is the set of all input variables, and \(S\) is a subset of set \(N\) excluding variable \(i\). The importance of each variable visualized in the SHAP summary plots is defined as follows:  
\[FeatureImportance_{i}=\frac{1}{N}\sum_{j=1}^{N}\left|\phi_{i}^{(j)}\right|, \tag{3}\]  
where \(j\) is the subscript of the case number. The XGBoost algorithm was used to visualize Shapley values because of its high affinity to the SHAP method.