Abstract
BACKGROUND: Machine learning models have shown great potential in preventive medicine but require large datasets, which is a challenge due to strict privacy regulations in the healthcare sector. Federated learning is an approach that enables collaboration between institutions while preserving data privacy. The focus today in research is highly on developing federated learning methods using artificial neural networks. In this study, we aimed to contribute federated learning modelling methods applied for random forests with an use-case of predicting delirium in hospitalised patients using data from multiple hospitals. METHODS: We collected data from eleven hospitals, including 29,479 patients and 627 features. We developed individual random forest models for each hospital data and a general model using all data. We developed federated learning models by averaging the predictions of the individual hospital models, with different schemes based on the number of samples, positives cases, minority cases and maximum possible diversity and evaluated the models using area under the receiver operating characteristic curve (AUROC). RESULTS: The general model outperformed all the other models with an AUROC of 0.855 [0.845–0.865]. Models trained on data from single hospitals varied in performance with an AUROC ranging from 0.633 to 0.829. Models from hospitals with large datasets performed better than those of small hospitals. Federated learning models outperformed individual models. With an AUROC of 0.794 [0.782–0.806], unweighted averaging achieved the worst results. Among the weighting algorithms, the number of positive cases performed the best reaching an AUROC of 0.843 [0.832–0.854], followed by minority cases (AUROC = 0.841 [0.830–0.852]), maximum possible diversity (AUROC = 0.836 [0.825–0.847]) and number of samples (AUROC = 0.830 [0.819–0.841]). CONCLUSIONS: Results show that federated learning models can perform better than hospital-specific models in some cases, especially hospitals with limited data. In case of datasets of different size, we suggest weighted averaging based on the number of samples. If the datasets are class imbalanced, minority cases or maximum possible diversity should also be considered. Additionally, federated learning models maintain consistency compared to hospital specific models. CLINICAL TRIAL REGISTRATION: Not applicable. SUPPLEMENTARY INFORMATION: The online version contains supplementary material available at 10.1186/s12911-025-03322-y.