{'fraction_non_alphanumeric': 0.028843880526440224, 'fraction_numerical': 0.016865001182126253, 'mean_word_length': 5.295956338377573, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Machine learning algorithms for claims data‐based prediction of in‐hospital mortality in patients with heart failure

Abstract Aims Models predicting mortality in heart failure (HF) patients are often limited with regard to performance and applicability. The aim of this study was to develop a reliable algorithm to compute expected in‐hospital mortality rates in HF cohorts on a population level based on administrative data comparing regression analysis with different machine learning (ML) models. Methods and results Inpatient cases with primary International Statistical Classification of Diseases and Related Health Problems (ICD‐10) encoded discharge diagnosis of HF non‐electively admitted to 86 German Helios hospitals between 1 January 2016 and 31 December 2018 were identified. The dataset was randomly split 75%/25% for model development and testing. Highly unbalanced variables were removed. Four ML algorithms were applied, and all algorithms were tuned using a grid search with multiple repetitions. Model performance was evaluated by computing receiver operating characteristic areas under the curve. In total, 59 125 cases (69.8% aged 75 years or older, 51.9% female) were investigated, and in‐hospital mortality was 6.20%. Areas under the curve of all ML algorithms outperformed regression analysis in the testing dataset with values of 0.829 [95% confidence interval (CI) 0.814–0.843] for logistic regression, 0.875 (95% CI 0.863–0.886) for random forest, 0.882 (95% CI 0.871–0.893) for gradient boosting machine, 0.866 (95% CI 0.854–0.878) for single‐layer neural networks, and 0.882 (95% CI 0.872–0.893) for extreme gradient boosting. Brier scores demonstrated a good calibration especially of the latter three models. Conclusions We introduced reliable models to calculate expected in‐hospital mortality based only on administrative routine data using ML algorithms. A broad application could supplement quality measurement programs and therefore improve future HF patient care.


Introduction
Heart failure (HF) is still of highest socio-economic relevance and despite increased survival rates one leading cause of overall mortality and hospitalizations. 1-3 To further improve HF treatment calls for comparative value-based patient care programs and standardized quality metrics. 4,5 Numerous scores predicting HF-related mortality or hospital readmissions have been introduced but were still rarely used in clinical practice due to modest performance, insufficient applicability, or lacking external validation. 6 Moreover, many prediction tools were developed using highly selected datasets collected for other purposes that hinder generalizability. 7 The evaluation of large datasets and the application of machine learning (ML) algorithms have the potential to enhance model performance, with already encouraging results in the context of HF hospitalization. [8][9][10] Most existing tools predicting mortality either failed to implement ML models or required variables that were not easily available on a population level. 6,11 This is, however, relevant in order to retrospectively compare disease-related outcomes between cohorts and health care facilities in a standardized way rather than on an individual basis at hospital admission to evaluate influencing factors and facilitate quality care management. Therefore, the aim of this study was to develop algorithms computing expected in-hospital mortality rates in HF patient cohorts using a nationwide, real-world administrative dataset that also includes variables that could only be gathered retrospectively. Doing so, we compared different ML methods with each other and with a classic regression approach regarding their predictive performance.

Data source
Administrative data of 86 Helios hospitals in Germany were retrospectively analysed. Patient cases with inpatient treatment within 1 January 2016 to 31 December 2018 and a main discharge diagnosis of HF defined in accordance to prior publications were identified. 12 Types of admission and discharge were gathered from administrative data, and only cases with both urgent (non-elective) hospital admission and hospital discharge type other than hospital transfer were further studied. In-hospital death as the outcome of interest has been defined based on hospital discharge type. Discharge diagnoses were encoded by the International Statistical Classification of Diseases and Related Health Problems [ICD-10-GM (German Modification)]. Relevant co-morbidities were identified from encoded secondary diagnoses within hospital discharge data according to the Elixhauser co-morbidity score as defined previously without a distinction being made between pre-existing comorbidities and new medical conditions. 13,14 Cases with missing information for New York Heart Association (NYHA) class (n = 5315 cases) were discarded due to adequate calibration of ML models. Detailed information regarding used ICD codes and a comparison of datasets with and without the exclusion of cases with missing NYHA class is provided in the Supporting Information, Tables S1-S3. The investigation conforms with the principles outlined in the Declaration of Helsinki. Given the anonymized data analysis of administrative data, ethics committee approval was determined not to be required in accordance with German law [Professional Code for Physicians (Saxony) §15]. Due to the retrospective study of anonymized data, informed consent has not been obtained.

Statistical analysis
All analyses were performed within the R environment for statistical computing (Version 3.6.1, 64-bit build). 15 The dataset has been randomly split using 75% for model development and 25% for model testing. Within the development dataset, models were evaluated using three concurrent variable settings with all of them implementing baseline variables (age, gender, admission year, NYHA class, length of hospital stay, and length of intensive care unit stay) and each one set containing Elixhauser co-morbidities as separate variables, Elixhauser weighted co-morbidity scores (Elixhauser score), or Elixhauser weighted co-morbidity score quintiles (Elixhauser index). Because no cross-linking of patients' cases between different hospitals was possible, no variables based on historic information (e.g. previous HF-associated hospitalizations) were used. Variables that are only known at hospital discharge (e.g. length of stay) were included because the aim of this project was to develop models for comparing expected and observed mortality on a population basis under different circumstances rather than creating a tool for individual outcome prediction. Variables being highly sparse and unbalanced (near-zero variance) were removed prior to the analysis. Near-zero variance variables were defined as variables with a per cent of unique values (number of unique value/number of samples * 100) below 10% and a frequency ratio (frequency of most prevalent value over the second most prevalent value) over 95/5. All variables were scaled and centred before the analyses.
The three development data subsets were evaluated using five algorithms: logistic regression [generalized linear models (GLM)], random forest (RF), gradient boosting machine (GBM), single-layer neural network (NNET), and extreme gradient boosting (XGBoost). Even though ML algorithms can implicitly take into account interactions between variables and non-linearity, we decided not to specify interactions or non-linear effects in the GLM for several reasons: (i) to keep the model specification as simple as possible for comprehensibility, (ii) to reflect the approaches already existing in the literature, and (iii) because non-linearity was not expected from a clinical perspective. 16,17 The algorithms were tuned using a grid search with a k-fold approach, using three repetitions of 10-fold each. During each repetition, the training dataset was split into 10 equal chunks, and each model was run with 9/10 of the training dataset for every combination of hyper-parameters and evaluated on the remaining 1/10. This has been performed 10 times for each repetition so that each 10th was used once for validation. After all iterations, the hyper-parameter values maximizing the area under the precision-recall curve (AUPRC) during cross-validation process were selected, and the model was run on the whole training set. To evaluate the performance of the models trained, the values predicted during the cross-validation process were used to compute receiver operating characteristic Calculation of expected mortality in heart failure using machine learning 3027 (ROC) areas under the curve (AUCs), and the model with the highest AUPRC was considered the best. Accuracy has not been chosen because of the outcome imbalance (less than 10% of the admissions resulted in in-hospital mortality). The relative importance of variables was assessed after the training, and values were scaled to 100 in order to make them comparable across algorithms. The methods used to assess the relative importance of variable were algorithm specific (GLM: absolute value of the t-statistic; RF: average across all trees of the difference between out-of-bag accuracy and out-of-bag accuracy after prediction permutation, normalized by the standard error; GBM and XGBoost: sum across all boosting iteration of the reduction in squared error attributed to a variable in each split based on this variable; and NNET: combination of the absolute values of connecting weights).
Two final steps were carried out before the final evaluation of each model with the test dataset: • The algorithm not based on likelihood or non-linear procedure approximated probabilities only, and hence, the probabilities had to be recalibrated. Here, we trained a logistic generalized additive model to be monotonically increasing, predicting the outcome with the probabilities computed by the initial model using the training set. We then derive probabilities from the test set with our initial algorithm and scale these probabilities with generalized additive model. 18,19 Improvement or degradation of the prediction with the recalibration was estimated with the Brier score. • Due to high outcome imbalances, expected mortality probabilities were likely to be low and the classification threshold had to be changed (i.e. the threshold above which an event is classified positive). Here, threshold has been chosen based on the ROC curve, selecting the threshold that maximizes the F1 statistic.
Using the probabilities predicted within the test data and the optimal threshold, the predictive abilities of each algorithm were assessed by ROC, the precision-recall curve, calibration-in-the-large (overall expected and observed mortality rate), weak calibration (intercept and slope of the calibration curve), calibration plots, and AUCs. 20 A continuous net reclassification improvement index has been computed comparing GLM with each ML algorithm in order to examine differences between model performance in addition to the comparison of the aforementioned metrices with values above zero indicating superiority.

Results
We included 59 125 patient cases from 69 German Helios hospitals into our analysis. The majority of patients were 75 years or older (69.8%), 48.1% were male, and most patients were highly symptomatic with 42.0% and 47.4% presenting with NYHA classes III and IV, respectively. In-hospital mortality was 6.20% overall. Patient cohorts used for model training and model testing were well balanced with regard to age, gender, NYHA class, and Elixhauser co-morbidities. Baseline characteristics as well as a comparison of training and testing dataset are summarized in the Supporting Information, Table S4. In univariable regression analysis, higher age, longer stay at the intensive care unit, male sex, higher NYHA class, and several variables from the Elixhauser co-morbidity score were predictors of in-hospital mortality ( Table 1).

Model training
During the training process, the hyper-parameters of each algorithm (except for GLM) were tuned keeping the following values (three values are specified for variable sets containing the Elixhauser co-morbidities, the Elixhauser score, or the Elixhauser index): • RF: number of variables randomly selected at each split = 3/ 2/2, number of trees = 500; • GBM: number of trees = 300; maximum depth = 3, learning rate = 0.1, minimum number of observations in each node = 2; • NNET: number of units in the hidden layer = 8/11/11, learning rate = 0.6/0.4/0.3; and • XGBoost: maximum number of boosting iterations = 100, maximum depth = 5; learning rate = 0.1, minimum loss reduction = 0.2; proportion of columns sampled per tree = 0.5; minimum child weight = 5; proportion of rows sampled per tree = 0.8.
Comparing the three aforementioned variable sets, ROC AUCs for the GLM were 0.820, 0.812, and 0.809. AUCs for all ML models were higher including RF (0.858, 0.858, and 0.857), GBM (0.867, 0.863, and 0.863), NNET (0.859, 0.859, and 0.858), and XGBoost (0.867, 0.865, and 0.863). For further model testing, the variable set containing the single Elixhauser co-morbidities was used because the corresponding models showed similar or superior ROC AUC values compared with both other variable sets in all models. Specific variable importance values for the baseline variables and Elixhauser co-morbidities are listed in the Supporting Information, Table S5.

Model testing
All ML models performed better than GLM with respect to the ROC AUC. Within ML models, GBM and XGBoost showed the highest ROC AUC values, but 95% confidence intervals (CIs) overlapped with those of RF and NNET. In detail, AUCs  Figure 1.
Calibration metrices are shown in Table 2, and calibration plots are illustrated in Figure 2. Brier scores (uncalibrated) were 0.050 for GLM, 0.045 for RF, 0.043 for both GBM and XGBoost, and 0.044 for NNET. A recalibration of probabilities did not improve Brier scores relevantly. Expected and observed event rates were compared overall and within subsets of different age groups and the year of admission (Figure 3).

Discussion
With the present study, we showed that the calculation of reliable models for the calculation of expected in-hospital mortality rates on a population basis is possible by using widely available administrative data only. Model performance was improved when implementing ML algorithms compared with a classic regression analysis, with GBM and XGBoost providing the most encouraging results. These kinds of models could be used in a second step to compute a standardized mortality ratio for further scientific evaluations and quality management programs by comparing temporal or regional disparities between expected and observed event rates in specific patient cohorts retrospectively, which could also be interesting with respect to hospital benchmarking. To date, prediction tools for mortality in HF patients are rarely used in routine practice outside clinical studies, both overall and especially in the setting of mortality prediction on a population level rather than on an individual basis. This is most likely caused by either the lacking availability of required variables on a population level or poor predictive performance of less complex scores. 6,11 Existing risk stratification models for mortality of individual HF patients (with most of them relating to long-term mortality risk) showed a wide range with regard to C-statistics ranging from 0.60 to 0.89 for different follow-up periods and HF subgroups with all models with values >0.80 either using data of laboratory results, clinical metrices, or medication data except from one. 11 Reflecting this fact, N-terminal pro-brain natriuretic peptide, serum creatinine, blood urea nitrogen, systolic blood pressure, heart rate, and left ventricular ejection fraction are under the most commonly reported variables used for patient-based outcome prediction. 6 However, implementing those or even more disease-specific values did not result in a further improvement of statistic performance neither in established HF risk scores for long-term risk prediction nor in newly introduced models. 21-25 This is also true for common clinical risk prediction models of individual in-hospital mortality in HF patients. 26,27 All of those prediction tools estimate the individual, patient-based risk, which was not the intention of our project, and referencing them is therefore not meant to be as a comparison with our results. However, it shows an existing conflict between variable availability and model integration to a larger scale. Only two prior studies solely focused on administrative data computing Figure 1 Summarized areas under the precision-recall curve from the testing dataset for all investigated models. GBM, gradient boosting machine; GLM, generalized linear models; NNET, single-layer neural network; RF, random forest; XGBoost, extreme gradient boosting.    overall acceptable AUCs of 0.72 to 0.78 with only one of them predicting in-hospital mortality specifically. 28,29 Nevertheless, a direct comparison with our models was also not possible because several information included in both referenced analyses were not available from our dataset (medication use, number of prior HF-related hospitalizations, ethnicity, and insurance information). The observed event rate in our cohort was rather higher when compared with the cohort of Lagu et al., which is likely to influence the model quality in the development phase potentially leading to higher AUCs. Differing baseline characteristics including a higher proportion of patients older than 75 years could be one explanation for higher in-hospital mortality rates in our HF cohort. The better performance of both our regression models and ML algorithms when compared with the work of Desai and colleagues may be linked to the comparatively low number of patients of less than 10 000 cases in their database exceeded more than six-fold by our cohort. Interestingly, they also analysed different ML algorithms with GBM showing the best AUC value but without a significant difference to a classic regression model. 28 Other studies examining ML methods for mortality prediction reported of comparable or lower AUC values but did so in either different patient cohorts (both inpatients and outpatients) or investigating different endpoints. 8,21 RF and dynamic radius means were presented as the most reliable models, which differs from our findings. However, the different subsets of implemented variables as well as the already mentioned methodological deviations should be major influencing factors. When looking for other cardiovascular studies comparing several ML methods for endpoint prediction aside from mortality in HF, there are publications supporting different models also investigated in our manuscript. In a recent analysis of data from GARFIELD-AF and ORBIT-AF, predictive ability of GBM and GLM was comparable whereas neural network models had the lowest discriminatory power. 30 In contrast, another study propagated neural networks to be superior to other ML methods under several circumstances with regard to data diversity and density when predicting incident HF. 31 Our results are in between showing no significant differences between NNET and RF, GBM, or XGBoost but with a better performance compared with GLM. Two other studies propagated RF models to outperform established risk prediction tools including GLM, which is in line with our findings. 32,33 Nevertheless, both of them did not compare RF with other ML algorithms, which would be of interest because values of AUC and AUPRC were slightly worse for RF than those of GBM and XGBoost in our calculations, even when not meeting statistical significance. Lastly, in an Australian multicentre analysis of almost 40 000 patients, several tested ML models showed higher predictive abilities in comparison with classic GLM in predicting in-hospital mortality following outof-hospital cardiac arrest, which could be transferred to our findings. 34 Whether an augmentation by data from electronic medical records, especially clinical and lab data, has the potential to further improve our models will be subject of future research. 28,35 However, one goal of our analysis was the introduction of a reliable model, which can be reproduced from widely available data.
Our models are not intended as mortality prediction tools for individual patients resulting in therapy adaptations. Rather, after future validation, it is conceivable that those models could contribute to further scientific research as well as quality management programs by the implementation of risk-adjusted and therefore standardized calculation of expected mortality rates in large HF cohorts comparing different geographic regions, hospitals, or time periods. In a second step, a broad integration is imaginable at least in the context of quality management programs. Furthermore, the impact of certain external factors such as the ongoing pandemic caused by SARS-CoV-2 on health care of HF patients could be examined by comparing expected and observed in-hospital mortality rates.

Limitations
Retrospectively collected data are widely considered to be of inferior quality compared with datasets with a prospective data assessment. Nevertheless, existing literature suggested that data collection mode per se did not influence the discriminatory power of the derived model. 11 The analysis of data derived from the Helios hospital network only could possibly result in a selection bias with respect to local differences regarding socio-economic factors, ethnicity, and other factors. However, due to the size of our cohort and the distribution of Helios hospitals across Germany serving about 7-8% of all German inpatient cases, we presume our database to be representative. Moreover, standardized treatment protocols within our hospital group may influence care pathways and outcome. Nonetheless, this analysis includes data from all hospital classes, including community hospitals as well as tertiary or university centres, which should partly alleviate the last-mentioned bias.
Our study analysed administrative data not being stored for research interests but for remuneration reasons, which could potentially affect the encoded information. Quality of the results depends to a large extent on the correct encoding of hospital discharge diagnoses. 14,36 However, regarding the main discharge diagnosis and the adequacy of hospitalization as well as encoding, there is a continuous evaluation by reimbursement companies/health insurances, which supports the assumption of overall valid information with respect to the diagnoses and the appropriateness of the patient's hospitalization. Moreover, used ICD codes have been validated internally using electronic medical records in previous works of this working group. 12,37 Information regarding patients' specific medical history, time of the onset of symptoms, cardiac imaging, laboratory results, medication, and treatment-related data was not available due to the type and structure of the analysed database. In particular, NYHA classification is influenced by the subjective assessment of the treating physician, and the addition of more objective criteria of disease severity is not possible when only using administrative data. Moreover, information regarding prior HF-related hospitalizations would have been likely to improve the performance of our models. Finally, an external validation of our models is required.

Conclusions
Machine learning algorithms are reliable metrics to calculate expected in-hospital mortality rates in HF patients outperforming regression analyses in a large, multicentre, real-world administrative database. Identifying a model based on widely available data with high predictive power could supplement quality measurement programs and therefore improve future HF patient care.

Acknowledgement
Open access funding enabled and organized by Projekt DEAL.

Conflict of interest
G.H. received grants through the Leipzig Heart Institute from Boston Scientific (Boston Scientific Corporation, Marlborough, Massachusetts, USA) and Abbott/St. Jude Medical (Abbott Laboratories, Chicago, Illinois, USA); no personal payments are declared. All other authors state that there is nothing to declare.

Funding
There has been no funding in connection with this study.

Permissions information
The authors do hereby declare that all illustrations and figures in the manuscript are entirely original and do not require reprint permission.

Data availability statement
The data underlying this article will be shared on reasonable request to the corresponding author. The same applies to the codes used to perform the analyses.

Supporting information
Additional supporting information may be found online in the Supporting Information section at the end of the article. Table S1: ICD-codes used as tracers for the identification of HF and for the definition of NYHA classes. Table S2: ICD-codes used to calculate Elixhauser Comorbidity Score (weighting according to AHRQ algorithm). Table S3: Comparison of the total dataset and the cohort after exclusion of cases with missing NYHA classes. Table S4: Baseline characteristics overall and as a comparison for training and testing dataset.