Introduction

Currently, there are ever increasing technologies employed to integrate medical treatment with technology, enabling doctors to integrate technology to enhance medical treatment and reduce human errors, thus improving benefits. In numerous medical articles many scholars apply machine learning methods for both study and prediction purposes. Yin et al.1 developed a stroke outcome prediction model using a deep convolutional neural network. Huang et al.2 applied the YOLO model to construct a lung cancer detection system. Additionally, Huang et al.3 employed a deep learning-based time series approach to predict ventilator weaning outcomes. Lee et al.4 proposed a prediction model for malaria diagnosis and concluded that RF could achieve better prediction results when comparing multiple machine learning models. Talukder and Ahammed5 proposed a predictive model for childhood malnutrition in Bangladesh using a Random Forest model. Seo et al.6 proposed a method to predict postprandial hypoglycemia and concluded that a Random Forest approach could effectively predict postprandial hypoglycemia better than a variety of models. Hsiue et al.7 found that cancer patients receiving MV in the ICU have a lower rate of successful extubation compared to non-cancer patients. Su et al.8 suggest that age is an important factor for successful extubation and long-term survival. Milbrandt et al.9 found that half of patients admitted to intensive care units (ICU) are aged over 65 years, thus, aging populations will increase stress in ICUs. Danaga et al.10 note that nearly half of ICU patients need to use mechanical ventilators (MV) to ensure adequate oxygenation to maintain basic physiological functions. Respiratory failure occurs when patients are unable to maintain proper respiratory function due to various disease conditions. Wu et al.11 believe that many factors, such as prolonged hospital stay and increased BUN levels, will affect the likelihood of extubation failure. Yang et al.12 found that the inclusion of MV use under Taiwan’s national health insurance scheme has increased their use.

The rapid advancements in the Internet of Medical Things (IoMT) have revolutionized healthcare by enabling real-time medical monitoring and data analysis. Efficient medical monitoring systems require high-speed data processing and minimal latency to ensure timely clinical decision-making. However, traditional cloud-based medical systems often suffer from delays due to data transmission and server processing limitations. Edge computing offers a promising solution by processing and analyzing data close to the source; this reduces transmission time, thereby reducing the burden on central servers, and enhancing system reliability. By integrating edge computing with machine learning techniques, medical data can be processed efficiently at the point of care before being uploaded to the server, thereby improving both system responsiveness and decision-making accuracy. Several studies have demonstrated the potential of edge computing in healthcare applications. Jiang et al.13 highlighted that combining fuzzy logic, neural networks, and edge computing can enhance disease prediction and diagnosis. Rahman and Hossain14 proposed an IoMT-based system for COVID-19 symptom detection, showing its effectiveness in home health management. Kong et al.15 introduced an edge computing-based mask detection framework (ECMask) for real-time public health monitoring, while Hsu et al.16 applied edge computing in preprocessing signal data for aircraft engine operation monitoring using deep learning techniques.

In recent years, machine learning has been widely applied in the field of medicine, providing doctors with expanded reference for decision-making. Maini and Dhanka17 proposed an RBF-SVM model for breast cancer prediction and concluded that the method can effectively enhance prediction. Kumar et al.18 used a hybrid genetic algorithm model for heart disease prediction and concluded that the method could improve early detection. Uddin et al.19 stated that Random Forest can achieve excellent prediction results compared to SVM models in disease prediction by many scholars.

Despite these advancements, one critical challenge in critical care remains: accurately predicting the success or failure of ventilator extubation in patients with acute respiratory failure. Incorrect extubation decisions can lead to severe complications, prolonged ICU stays, and increased healthcare costs. To address this issue, this study integrates edge computing and machine learning algorithms, specifically Random Forest and XGBoost, to develop a predictive model for ventilator extubation. By leveraging real-time ventilator-generated data, the proposed system aims to provide clinicians with a reliable decision-support tool, enabling faster and more accurate extubation assessments while reducing server processing loads. The findings of this study have the potential to enhance clinical efficiency, improve patient outcomes, and optimize healthcare resource utilization.

Literature review

Random forest

Random Forest is a decision tree generated by multiple Gini algorithms. Random Forest adds training data in a random manner to achieve the final calculation results, as shown in Eq. (1).

$$\text{Gini}\left(\text{D}\right)=1-\sum_{i=1}^{n}{P(i|t)}^{2}$$
(1)

where D is defined as the patient extubation data containing n samples, and \(P\left(i|t\right)\) is the probability generated by the attribute value. Sharma et al.20 evaluated six ML models for predicting arrhythmia and found that Random Forest generated better prediction results. Dhanka and Maini21 compared four machine learning models for predicting heart disease and found that random forests had good predictive power. Huang et al.22 proposed a model using Random Forest to effectively predict successful extubation in mechanically ventilated patients. Dhanka and Maini23 used a Random Forest model to predict heart disease. Menon24 proposed a model using logistic regression and Random Forest to effectively predict the high-cost and non-high-cost categories of patients’ medical expenditures. Hanko et al.25 proposed using Random Forest to generate a model to evaluate the mortality and postoperative results of patients with traumatic brain injury, positing that such an approach could produce good predictive effects. Chandana and Krishna26 proposed using random forests to generate an algorithm to achieve more accurate predictions for breast cancer. Mursalin et al.27 proposed applying correlation-based feature selection and Random Forest models to EEG signals to effectively detect epileptic seizures.

XGBoost

XGBoost proposed by Chen and Guestrin28 provides a fast and scalable way to solve prediction and classification problems in many application fields. It provides early prediction values for the tree root and calculates the residual value of the data set to produce a tree diagram. Dhanka and Maini29 proposed a novel hybrid XGBoost framework to predict heart disease results. Dhanka and Maini30 proposed two models named HyOPTRF and HyOPTXGBoost to predict heart disease outcomes. Dhanka et al.31 compared logistic regression and XGBoost for monitoring coronary artery heart disease, achieving an accuracy of 91.85% after parameter optimization in XGBoost. Kuo et al.32 proposed combining XGBoost analysis and rule-based methods to achieve a good monitoring effect for fetal heart rate monitor signals. Prabha et al.33 proposed the use of photovolume signals and basic physiological data to detect diabetes and suggested that XGBoost can achieve good prediction results with fewer features and lower workload. Półchłopek et al.34 proposed using time mode for data mining in electronic medical records, finding that XGBoost achieves the highest predictive effect in selected age groups. Tseng et al.35 suggested the RF + XGBoost model can achieve better preset results than by random forest models alone to predict cardiac surgery–associated acute kidney injury (CSA-AKI). The XGBoost model is mainly generated through addition, as shown in Eqs. (2)–(3).

$$\widehat{{y}_{i}}=\sum_{k=1}^{t}{f}_{k}\left({x}_{i}\right)$$
(2)
$${\widehat{{y}_{i}}}^{(t)}={\widehat{{y}_{i}}}^{(t-1)}+{f}_{t}({x}_{i})$$
(3)

where \(\widehat{{{\varvec{y}}}_{{\varvec{i}}}}\) is the final predicted value; \({{\varvec{f}}}_{{\varvec{k}}}\left({{\varvec{x}}}_{{\varvec{i}}}\right)\) is the prediction of the k-th tree for the i-th data point, and \({\widehat{{{\varvec{y}}}_{{\varvec{i}}}}}^{({\varvec{t}}-1)}\) is the prediction form of the previous iteration.

Model evaluation

This research uses Sensitivity, Specificity and Accuracy for model evaluation, as shown in Eqs. (4)–(6).

$$\text{Sensitivity}=\frac{TP}{TP+FN}$$
(4)
$$\text{Specificity}=\frac{TN}{TN+FP}$$
(5)
$$Accuracy=\frac{TP+TN}{TP+TN+FP+FN}$$
(6)

where TP is True positive; FP is False positive; TN is True negative; and FN is False negative.

Methods

The hardware setup for this study includes a Raspberry Pi 4 Model B with 4 GB RAM, operating on Ubuntu 22.04. The software implementation is based on Python, incorporating key libraries such as Pandas, NumPy, and Scikit-learn. The research process of this research is mainly divided into four steps: Dataset, Data Preprocessing, Feature Extraction, and Model Training and Evaluation as shown in Fig. 1. The complete architecture of the proposed system is illustrated in Fig. 2, which outlines the integration of edge computing with machine learning for real-time ventilator extubation prediction.

Fig. 1
Fig. 1The alternative text for this image may have been generated using AI.
Full size image

Research flow.

Fig. 2
Fig. 2The alternative text for this image may have been generated using AI.
Full size image

Research Structure.

Data collection

This study analyzed demographic and clinical data from a total of 233 patients collected at a hospital in Taiwan. Of these, 28 patients experienced extubation failure, while 205 achieved successful extubation. The dataset includes 3.5 h of continuous physiological recordings per patient, capturing key respiratory parameters such as tidal volume (Vte), respiratory rate (RR), peak airway pressure (Ppeak), mean airway pressure (Pmean), positive end-expiratory pressure (PEEP), and fraction of inspired oxygen (FiO2). A detailed breakdown of the demographic variables is presented in Table 1, while the structure and types of physiological data are described in Table 2.

Table 1 Demographic characteristics table.
Table 2 Dataset description.

Data preprocessing

In data preprocessing, this research employs an approach which averages values over specific time intervals to reduce noise and enhance data interpretability. The averaging process is conducted at intervals of 1, 30, 60, 120, 180, and 300 s. This step is crucial for summarizing raw data into more manageable and representative forms, enabling a clearer analysis of trends and patterns.

Feature selection

In feature selection, the Entropy of the original and expanded fields on the success or failure of extraction was calculated by using the Information Gain method proposed by Kullback and Leibler (1951) for feature selection. The entropy value is expressed between 0 and 1, where 0 means the field cannot be partitioned for extubation success or failure, while 1 means that the field can be effectively divided, shown as Eqs. (7)–(9), and the analysis results are shown in Table 3. The original field can predict the extubation data without any difference in the squared data, with good predictive effect for the degree of difference.

Table 3 Information gain results.

Table 4 shows whether using the first n selected feature attributes can achieve a good prediction effect due to feature extraction. Using the first three hours of data for the 233 patients with the Random Forest algorithm, this study finds that the model can obtain good prediction results without deleting any of the six features. Therefore, the feature selection in this research uses the original Vte, RR, Ppeak, Pmean, PEEP, and FiO2 data as model input fields.

Table 4 Model accuracy with n features.
$$\text{Entropy}\left(\text{Q}\right)=\sum_{i=1}^{j}{p}_{i}{log}_{j}\left(\frac{1}{{p}_{i}}\right)=-\sum_{i=1}^{j}{p}_{i}{log}_{j}\left(\frac{1}{{p}_{i}}\right)$$
(7)
$$\text{Entropy}\left({\text{N}}_{di}\right)=\sum_{i=1}^{|{N}_{d}|}\frac{{N}_{di}}{Q}*\text{Entropy}\left({\text{N}}_{di}\right)$$
(8)
$$\text{IG}\left({\text{N}}_{d}\right)=\text{Entropy}\left(\text{Q}\right)-\text{Entropy}\left({\text{N}}_{di}\right)$$
(9)

Entropy(Q) is the calculation of the total information content in the entire classification, where Q is the number of data, j is the number of categories, and \({p}_{i}\) is the probability of the i-th category appearing in the Q items of data. \(\text{Entropy}\left({\text{N}}_{di}\right)\) is the information content before the i-th value, category, and data quantity of the d features, and the obtained information content is summed and expressed as the information content of a single feature. \(\text{IG}\left({\text{N}}_{d}\right)\) is the information gain obtained for the d-th feature, which is the total information content of the entire data set, which will be generated by the difference between the d-th feature contents to obtain the information gain of each feature.

Model training and evaluation

This research uses four verification methods for model training on the edge device, where M1, M2, M3 Holdout Cross-Validation respectively splits the data from the first 3 h of the 233 data sets into ratios of 6:4, 7:3 and 8:2 for training and Validation sets (respectively 1h48m/1h12m, 2h6m; 54 m, and 2h24m/36 m), while M4 uses a tenfold method to split the data for the first three hours of the 233 sets into one set used for validation, while the rest are used for training. This research splits the data from half an hour of the 233 data sets before extubation for testing set. This research uses two different machine learning methods: Random Forest and XGBoost. Comparison is made with four validation methods, and the model evaluation method should be compared with validation Accuracy. In this study, the specific parameter settings of Random Forest and XGBoost are shown in Table 5.

Table 5 Model reference settings.

Results

The results in Fig. 3 show the verification for M1, indicating that Random Forest can achieve the best results by averaging every 120 s, while XGBoost can achieve the best results by averaging Per 180 s; the validation results of XGBoost are slightly lower than Random Forest except for Per 1 s and Per180 seconds. The results in Fig. 4 show the ROC values of XGBoost are all better than those of Random Forest, except for the accuracy of Per 30 s, Per 120 s, and Per 180 s, which is slightly lower than that of Random Forest.

Fig. 3
Fig. 3The alternative text for this image may have been generated using AI.
Full size image

M1 validation results.

Fig. 4
Fig. 4The alternative text for this image may have been generated using AI.
Full size image

M1 prediction sample test results.

The results in Fig. 5 show the verification results for M2, indicating that those of XGBoost are better than Random Forest’s, and the results in Fig. 6 show the ROC values of XGBoost are all better than Random Forest, and XGBoost is better than Random Forest’s except for the accuracy of Per 60 s and Per 120 s, which is slightly lower than Random Forest.

Fig. 5
Fig. 5The alternative text for this image may have been generated using AI.
Full size image

M2 validation results.

Fig. 6
Fig. 6The alternative text for this image may have been generated using AI.
Full size image

M2 prediction sample test results.

The results in Fig. 7 show the verification for M3, indicating that XGBoost is better than Random Forest and can achieve the best results; the results in Fig. 8 show the ROC values of XGBoost are all from Random Forest, and XGBoost accuracy is better than Random Forest’s except that per 120 s is slightly lower than Random Forest every 120 s.

Fig. 7
Fig. 7The alternative text for this image may have been generated using AI.
Full size image

M3 validation results.

Fig. 8
Fig. 8The alternative text for this image may have been generated using AI.
Full size image

M3 prediction sample test results.

The results in Fig. 9 show the verification for M4, indicating that XGBoost is better than that of Random Forest in Per 1 s, Per 120 s, and Per 300 s, while the others are better than that of Random Forest; the results in Fig. 10 show the ROC values of XGBoost are better than Random Forest’s, and XGBoost accuracy is better than Random Forest except that Per 60 s, Per 120 s, and Per 300 s are slightly lower than Random Forest.

Fig. 9
Fig. 9The alternative text for this image may have been generated using AI.
Full size image

M4 validation results.

Fig. 10
Fig. 10The alternative text for this image may have been generated using AI.
Full size image

M4 prediction sample test results.

Table 6 shows the time required for M1, M2 and M3 to make predictions at different data acquisition frequencies. The results show that when the model is trained using data acquired per second, although a larger amount of data is acquired, this also leads to a longer computation time for the model to perform the prediction. In contrast, averaging the data over a longer time interval effectively reduces the amount of input data, which in turn reduces the computational burden on the model, resulting in a more efficient prediction process and shorter inference time. This suggests that appropriate adjustment of the data acquisition method can help improve the predictive efficiency of the model.

Table 6 Time complexity of model predict on Raspberry Pi.

Discussion

In this study, it is found that XGBoost outperforms Random Forest in different cross validation methods such as 6:4, 7:3, 8:2, and tenfold cross validation, which indicates that Random Forest is stable but not flexible enough to handle low entropy data, whereas XGBoost belongs to the Boosting technique domain. XGBoost is a Boosting technique, which can summarize the data efficiently and accurately derive better prediction results. There is a significant difference between Random Forest and XGBoost in terms of prediction time as XGBoost has faster prediction time.

Since the data used in this study are processed on a per second basis, edge computing can effectively reduce the delay in data transmission because for a patient, if the prediction is performed every three minutes, there will be 1080 pieces of data that need to be uploaded to the server and then averaged and computed, which will lead to the possibility of delay in data transmission. If the prediction is performed on an edge device, it is possible that the data will be delayed. If the computation is performed on the edge device, only the prediction results need to be uploaded to the server for clinical staff to make decisions, which will reduce the data transmission by 83.33%, making the healthcare system more stable and thus reducing the burden on the server. Edge computing can minimize the data leakage problem.

This study found a way to improve the success rate of extubation: real-time AI prediction can not only help clinicians to more accurately determine whether or not the patient is suitable for extubation, as well as reduce the failure rate of extubation and the incidence of complications. It can also reduce the failure rate of extubation and decrease the incidence of complications, which in turn can shorten the ICU hospitalization time, reduce the waste of medical resources and increase the recovery rate of patients. In this study, only the parameters of the ventilator can be used to make effective predictions without the need for additional vital signs, which means that it can be more immediate, and the type of the ventilator only needs to be able to allow it to be carried out in the way of the Internet of Things (IoT) in order to use the system of this study.

Currently, only one hospital’s data is used in this study to verify the applicability of the inter-organizational testing model, which is an important limitation of the study, and other inter-organizational collaborations can ensure that it can be run stably in different healthcare scenarios. The feasibility of this study can also be demonstrated in different hospital data environments.

Conclusion

In this study, an edge computing-based machine learning approach was implemented to predict ventilator extubation outcomes using real-time ventilator-generated data. The model was trained and validated on an edge device, leveraging different data processing and validation techniques, including Holdout cross-validation and tenfold cross-validation. Among the evaluated algorithms, while Random Forest showed competitive performance in some cases, XGBoost demonstrated superior overall accuracy and efficiency in processing medical data on edge devices. The proposed system effectively reduces server workload by processing data locally before transmission, leading to an 83.33% reduction in data uploads. This architecture enhances system stability, robustness, and sustainability, making it well-suited for real-time clinical applications. Furthermore, this research highlights the potential of integrating patient-specific variables and additional algorithms to refine prediction accuracy in future studies. By enabling physicians to use machine learning-based predictions as a reference for extubation decisions, this approach aims to improve patient management and outcomes in critical care settings.