Classification of pulmonary diseases using machine learning and deep learning models on GLI-2012 standardized spirometry features.

Save

Background

Artificial intelligence applications play an increasingly important role in medical diagnosis processes, nowadays. Spirometry, which is widely used among lung function tests, is an important method in the early diagnosis of pulmonary diseases and monitoring. In this study, the performances of different machine learning and deep learning algorithms in classifying pulmonary diseases were examined using a set of Global Lung Initiative 2012 standardized spirometry features.

Methods

The study analyzed demographic variables and different spirometry parameters to make classification for multi class classification. This was defined for both a standard four class and an extended five class problem. In this context, logistic regression, support vector machine, k-nearest neighbor, random forest, and XGBoost methods, as well as deep neural networks, convolutional neural networks models were applied in the study.

Model accuracy was increased by applying preprocessing and standardization techniques to the data set. Model performances were analyzed with evaluation criteria such as accuracy, sensitivity, specificity, F1-score, F1-macro and the area under the receiver operating characteristic curve metrics.

Results

Under the subject-disjoint test set, tree-based models achieved the highest generalization performance. The XGBoost model achieved the highest success rate with 99.24 ± 0.59% accuracy, followed by the random forest model at 97.23 ± 2.04%. The deep learning models, deep neural networks and convolutional neural networks achieved 81.61 ± 5.83% and 77.57 ± 5.55% accuracy, respectively, on the same conventional normal feature set.

Conclusions

Machine learning based approaches have offered strong potential in early diagnosis of pulmonary diseases. In addition, the need for additional optimization to improve the performance of these models has been emphasized. This study provides important findings for the integration of artificial intelligence supported spirometry analysis into clinical use.

However, validation of the proposed methods on larger patient groups is a critical step for the integration of these technologies into the healthcare system.

Introduction

In recent years, pulmonary diseases have become one of the most common health problems. Pulmonary diseases affect the airways and other structures of the lungs. It has been observed that this disease has significantly increased morbidity and mortality rates in the human population [1].

Some of the most common are chronic obstructive pulmonary disease (COPD), asthma, occupational lung diseases and pulmonary hypertension [2, 3]. Lower pulmonary tract infections seen in childhood, air pollution, exposure to cigarette smoke, occupational chemicals and dust can be listed as the factors. If not diagnosed early, they can lead to serious problems.

Importance of spirometry

Spirometry is a test to detect lung function disorders and their degree [4, 5]. In addition, information about the risks of surgical intervention can be obtained with the spirometry test. There are three basic measurements in spirometry.

These are volume, time and flow parameters. Lung functions physiologically consist of four volumes [6]. These are;

Expiratory reserve volume (ERV).Inspiratory reserve volume (IRV).Residual volume (RV).Tidal Volume (TV).

These four volumes give the total lung capacity (TLC). In the measurement made with spirometry, forced vital capacity (FVC), air volume in the 1st second of forced expiration (FEV1), mid-expiratory flow rate (FEF25 − 75 or MEFR), peak expiratory flow rate (PEFR), vital capacity (VC), inspiratory reserve volume (IRV) and expiratory reserve volume (ERV) values ​​can be measured. Demographic information and measurements are also used in the evaluation [7–9].

Lung volumes and capacities are shown in Fig. 1.

Fig. 1Lung volumes and capacities

In spirometry, FEV1 and FVC values ​​are the two most important parameters that provide information about the pulmonary airways [10]. FEV1 usually provides information about the status of the large airways. FVC is the volume of air that is exhaled quickly and forcefully after deep inspiration.

Healthy individuals can exhale 80% of their lung volume in 6 s or less. FVC detects cystic fibrosis, bronchiectasis, asthma, and obstructive and restrictive neuromuscular diseases. The FEV1/FVC ratio is a ratio that helps analyze these diseases and lung restrictions.

A decrease in the FEV1/FVC ratio indicates obstruction. The FEV1 value also indicates the severity of this obstruction [11].

Demographic parameters are also effective in the evaluation of spirometry data. Parameters that influence spirometry results have been identified by the Global Lung Initiative (GLI) and the US National Center for Health Statics. Also, ethnic differences are important to consider in lung analysis.

Therefore, the assessment of lung function depends on key variables such as sex, age, height, and race [12, 13]. Some studies have indicated that weight can also be considered as a parameter for assessment [14].

AI applications in spirometry

Artificial intelligence (AI) has become an important component of the detection and diagnosis of pulmonary diseases as well as other diseases. Therefore, studies can be considered beneficial in improving accuracy and efficiency that using AI in healthcare. AI applications are notably used in the analysis and evaluation of spirometry tests.

Also, AI can help physicians interpret spirometry data, so provide real time feedback and increase diagnostic accuracy. This makes them very useful in situations where spirometry analysis is misinterpreted or underutilized due to many case or time constraints. A randomized study showed that clinicians using AI support systems had better diagnostic accuracy than others [15].

AI algorithms can diagnose various pulmonary diseases, such as asthma or COPD by evaluating spirometry data in this context. In addition, different AI methods are successful in treating interstitial lung disease (ILD). An important aspect of ILD diagnosis is that it relies on previously recorded spirometry data before clinical diagnosis can be made.

Therefore, early diagnosis can lead to improved patient outcomes and enable timely intervention [16, 17].

The quality of spirometry data can be analyzed through comparative analyses using different AI methods. This is also effective in reducing variability in decision making processes between physicians. Therefore, it is very important in clinical trials and routine practice [18, 19].

Furthermore, as these models become more complex such as deep learning, ensuring their clinical acceptance requires new methods in explainable artificial intelligence (XAI) to make their predictions transparent and interpretable [20–22]. Pulmonary diagnostics and other healthcare domains emphasize that explainability is essential for building clinical trust and validating model decisions [23, 24].

Machine learning (ML) is important in regression and classification processes in increasing the accuracy of spirometry tests. It is seen that lung volumes can be estimated more precisely with ML models, disease classifications are determined accurately and diagnostic information is improved [25, 26]. It also contributes to the development of portable and accessible spirometry solutions for the diagnosis of pulmonary diseases such as COPD and asthma [27].

Static lung volumes such as RV and TLC can be estimated from spirometric data using different ML algorithms. Tomita et al. [28] reported that models such as XGBoost and RF successfully classified the detection of asthma diseases and achieved high accuracy in volume estimations. Yin et al. [29] created and evaluated ML models that predict the probability of acute exacerbation of COPD.

Moreno et al. [30] also used variables with the highest predictive power derived from an active case-finding program to identify COPD cases. They reported that it increased diagnostic efficiency in primary care. However, regression-based classifiers are practical in distinguishing normal, obstructive and restrictive lung function disorders [31].

Das et al. [32] evaluated techniques such as convolutional neural networks (CNN) to assess the spirometry data based on American Thoracic Society (ATS) and European Respiratory Society (ERS) criteria for maneuver acceptability and usability. In addition, pulmonary system parameters are estimated using feedforward neural networks, and validations with simulated spirometry data show that such models are an important tool in determining pulmonary functions [33].

Singh et al. [34] demonstrate that alternative methods to traditional spirometry methods have been developed using time series pulmonary models. Convolutional dense neural networks that utilize MEL-spectrogram features allow the estimation of FVC. In addition, models that evaluate the validity of spirometry tests using sound signals are being developed [35, 36].

ML models are also becoming widespread in the interpretation of alternative pulmonary function tests [37, 38]. In particular, it is emphasized that models with high accuracy distinguishing normal and restrictive pulmonary functions show less variability and provide consistent results compared to expert interpretations. In addition, the SVM, k-NN algorithms has been optimized to successfully classify lung diseases, increasing its accuracy [39, 40].

Advanced algorithms such as XGBoost, LightGBM and CatBoost have successfully predicted COPD [41]. Trivedy et al. [42] correctly classified abnormal spirometry using a stacked autoencoder (SAE) based neural network by extracting features from the flow-volume curve.

Different studies have been conducted in the literature to increase the diagnostic accuracy of spirometry and pulmonary function tests. With further application and analysis of ML and DL models, they may have an effective position in the future in remote monitoring processes as well as clinical detections [43–46].

Motivation and objective

In recent years, the effectiveness of ML and DL models in medical data analysis and disease diagnosis has increased significantly [47]. AI based approaches used for the analysis of spirometry data have the potential to accelerate clinical processes and provide more accurate diagnoses. While many studies have applied AI to spirometry data, two critical gaps often limit their clinical relevance.

First, many rely on outdated, fixed-ratio thresholds (e.g., FEV1/FVC < 0.7) instead of the modern GLI-2012 Z-score standard. Second, many studies risk data leakage by failing to use strict subject-disjoint validation, which can lead to overly optimistic results.

The main contribution of this work is to provide a robust and reproducible benchmark for ML and DL models. The study addresses this issue using GLI-2012 standardized feature set that includes extended parameters such as TLC and RV. Second, the subject uses a discrete authentication protocol.

The aim is to determine the actual and generalizable performance of the models. Also, compare the DL models with ML models on tabular data. And finally, evaluate the results, advantages and limitations of both approaches.

Structure of the paper

The paper is organized as follows. Data sources, preprocessing steps, and the implemented ML and DL models are described in Sect. 2.

Section 3 presents the model performance and main findings. Section 4 evaluates the results of the study. Furthermore, the final section includes limitations and some suggestions for future research.

Materials and methods

In this study, a dataset provided by Michael Falvo et al. [48] was used. The dataset included raw spirometry data obtained from healthy adults in two different laboratory visits [49]. In the study, data were collected from a total of 129 participants aged 18–40.

Basic demographic information of the participants, such as age and gender, was also included in the dataset. The workflow diagram followed in the study is given in Fig. 2.

Fig. 2Workflow diagram of the study

Data preprocessing and analysis

The dataset contained a total of 2,287,213 observations. Data preprocessing analysis was performed to clean the data. After removing rows labeled as NaN, non-numbers, etc., the number of observations was reduced to 1,055,236.

A total of 1,055,236 observations were processed and converted into 1,237 pulmonary function data for 129 individuals. Each of these 1,237 entries represents a single, complete spirometry maneuver (trial) from which the key features were extracted. The dataset contained six variable columns.

Each observation contained the ID number given to a specific participant, the number of visits, the number of experiments in the visit, and time series measurement values ​​for flow and volume. These measurements were recorded during spirometry tests. In addition, a file named Timezero File.xlsx was used in the study.

This file contains the time zero offset values ​​for each trial. It refers to the time between the start of data collection and the point at which spirometry was used. This value was used to determine the start of the full expiratory movement and to align the measurement data correctly.

The dataset consists of various spirometry measurements such as FEV1, FVC, FEF25 − 75, and demographic variables (age, gender, ethnicity, height). These values ​​were calculated for each test due to processing the raw data. An example of the flow-volume graph obtained as a result of processing the raw data is presented in Fig.

3.

Fig. 3A flow volume graph for ID 229

Data analysis includes statistical and ML methods to process time series data. Training and evaluation of classification models were performed by combining demographic information and spirometry measurements. In this process, data pre-processing and cleaning steps such as one-hot encoding were applied for categorical variables (ethnicity, gender).

Fundamental statistical analyses were also performed before moving on to ML and DL.

Firstly, relationships between gender and spirometry values ​​were examined using the t-test. According to the independent sample t-test results, FEV1, FVC, FEV1/FVC, FEF25 − 75, and PEFR values ​​show statistically significant differences between genders (p < 0.05). This finding indicates that men generally have larger lung volumes and higher airflow rates.

In addition, the ANOVA test was used to compare spirometry parameters according to race groups. According to ANOVA test results, FEV1, FVC, FEV1/FVC, FEF25 − 75, and PEFR values ​​​​show statistically significant differences between race groups (p < 0.05). A comparison of spirometry parameters according to gender and race groups is presented in Table 1.

Table 1Ethnic and gender comparison with spirometry parametersParameterComparisonStatistic Valuep-ValueFEV1 (ml)Sex27.105p < 0.05Ethnic70.316p < 0.05FVC (ml)Sex29.887p < 0.05Ethnic57.157p < 0.05FEV1/FVCSex-2.128p < 0.05Ethnic18.207p < 0.05FEF25 − 75 (L/s)Sex19.432p < 0.05Ethnic35.115p < 0.05PEFR (L/s)Sex24.104p < 0.05Ethnic17.116p < 0.05

A correlation matrix was also obtained to examine the relationships between spirometry parameters and demographic variables. The correlation matrix is ​​presented in Fig. 4.

FEV1 and FVC show strong positive correlation with height (r > 0.6, p < 0.05).

Fig. 4Heat map

Regression analysis was used to examine the relationship between demographic parameters and pulmonary function. In this way, FEV1 is the dependent variable and ethnicity, height, weight and age are independent variables. The effect of independent variables on FEV1 was investigated with this analysis.

The least squares regression model was applied as a statistical method. The formula is given as follows:1\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned}\:{FEV}_{1}&={\beta\:}_{0}+{\beta\:}_{1}Age+{\beta\:}_{2}Weight\cr&\quad+{\beta\:}_{3}Height+{\beta\:}_{4}Ethnic+\varepsilon\end{aligned}$$\end{document}

In the analysis, the constant term represents the regression coefficients and the error term. The assumptions of normality of error terms and absence of multicollinearity were checked. Statistical validity was also ensured of the model.

The significance of each independent variable was assessed using the p value (p < 0.05). The regression model showed moderate predictive power. It means that the selected independent variables could explain 53.5% of the variance in FEV₁.

This analysis was included to verify that the dataset confirmed known physiological relationships. It was not used as a direct input for subsequent classification models. This finding, which confirms the influence of demographic characteristics, provides a data-driven rationale for the study’s key methodological choice.

This choice was to adopt the GLI-2012 Z-score equations, which normalize spirometry values against these factors, rather than using traditional fixed-ratio thresholds.

Standardization and GLI-2012 calculations

Global Lung Initiative (GLI), 2012 reference values are based on factors such as age, gender, height and ethnicity to determine the estimated values used for lung function tests. These coefficients are used to estimate FEV1 and FVC measurements. The coefficients are different for European, African, Asian (Southeast Asian and Northeast Asian) and other ethnic groups.

These coefficients have separate formulas for each age and height range. In the first stage of data analysis, demographic information (age, gender, height, weight and ethnicity) of each participant was defined for GLI-2012 calculations. Then, Z-scores of each participant were calculated based on GLI-2012 calculations.

In GLI-2012 calculations, age and height dependent prediction equations were developed for FEV1, FVC and other pulmonary parameters using the lambda-mu-sigma method [12]. In this model:2\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned}\:Y&=a+b.H+c.A+age-spline\cr&\quad+d1.group+d2\left(group.A\right)\end{aligned}$$\end{document}

Here;

Y: Expected spirometry value (e.g. FEV1, FVC),

H: Height,

A: Age,

Spline function: Age-related variability,

Group: Variables are determined based on ethnicity.

This equation was used to make the estimates more precise by modelling the effect of age and height. Instead of using the threshold value of FEV1/FVC < 0.7, a classification based on the GLI-2012 Z-score was made. In the Z-score calculations, the standard deviation (SD) was calculated according to the following formula using the lower limit of normal (LLN) and upper limit of normal (ULN) values:3\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\:\sigma\:=\frac{ULN-LLN}{2\times\:1.645}$$\end{document}

The Z-score calculates as follows:4\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\:Z=\frac{x-\mu\:}{\sigma\:}$$\end{document}

GLI-2012 suggests defining the disease according to the Z-score:

Z < -1.64 → Abnormal (Suspicious of disease).

Z < -2.0 → Obstructive or restrictive.

Z > -1.64 → Normal.

This method offers a better and more accurate classification than using the threshold value of FEV1/FVC < 0.7. Studies have shown that the Z-score method can better predict the presence and level of disease. Age, height, sex and ethnicity appear to be important in decision making processes or reducing misdiagnosis [50–52].

Two classification sets were used in the study. Normal classification based on FEV1, FVC and FEV1/FVC. Normal classification is named also conventional.

The extended classification includes additional parameters. Especially, the small airway disease is defined with FEF25 − 75. This is in accordance with the 2012 ETS/ATS standards [50].

These guidelines identify this threshold as indicative of potential mild or early-stage airway disease when FEV1 and FVC are normal. For the restrictive disease category, the criterion of a TLC Z-score < -2.0 was used. This value represents a statistically robust threshold (two standard deviations below the mean).

This specific cutoff was selected over the standard 5th percentile LLN (Z-score < -1.64) to increase the specificity of the restrictive label, thereby minimizing potential false positives.

Computational models

In this study, different ML and DL models were applied to predict pulmonary diseases. The study includes two distinct multi classification tasks. They are a standard four class and an extended five class problem.

The models were divided into two groups, including classical machine learning and deep learning approaches. Five machine learning models were used to predict spirometry results, including logistic regression (LR), random forest (RF), extreme gradient boosting (XGBoost), support vector machine (SVM) and k-nearest neighbors (k-NN). Deep neural network (DNN) and convolutional neural network (CNN) are also included for comparison with ML algorithms.

LR is an algorithm used for binary classification [53]. Used in research to model and estimate the probability of categorical outcomes [54]. It can increase the predictive power and robustness in data analysis [55].

RF is an effective and powerful learning method used for classification and regression. It provides successful results in many different fields such as engineering and medical predictions [28, 56–60]. Its high accuracy and robustness effectively handle nonlinear and imbalanced data.

It provides better performance on datasets with less noisy features. Its complexity level is relatively high compared to simpler models. It can also be less interpretable in some aspects.

But, it can be ineffective in areas with limited data availability [28, 56, 58].

SVMs are a supervised learning model used for classification and regression tasks in ML. SVM is used in healthcare applications such as heart diseases, cancer diagnosis, neurological diseases, and pulmonary diseases. SVMs perform well with sensitive parameters and data.

However, the success rate may be relatively low on nonlinearly separable data [61–68].

k-NN is a supervised ML algorithm used for classification and regression tasks. k-NN is used in various fields including medical imaging, recommender systems, and clustering [69–71]. It has disadvantages such as computational inefficiency and sensitivity to noise in large datasets. These issues are important in parameter selection such as dimensionality reduction or data preprocessing to improve the performance.

It requires more attention and care in the operations performed [72–74].

XGBoost is an algorithm based on the classification tree model known for its high accuracy and fast running speed. XGBoost is used in medical diagnosis, prognosis, cybersecurity, sentiment analysis, and industrial prediction. It requires care in overfitting and hyperparameter tuning to achieve optimal performance [75, 76].

In addition to ML methods, DL models that can adapt to more complex and large data sets were also applied in the study. DNN is a classical artificial neural network model consisting of fully connected layers. DNN is a class of ML models that have attracted significant attention due to their ability to model complex patterns and relationships in data [77].

It is effective in signal processing, security systems, environmental monitoring, and healthcare. It has some disadvantages, such as computational complexity and energy consumption [78, 79]. CNN is a deep learning model that is especially successful in time series and image data [80].

As the data consists of a structured vector of derived features, a 1D-CNN model was applied. The objective was to treat this feature vector as a 1-dimensional sequence, allowing the convolutional filters to explore potential local relationships and hierarchical patterns among the features themselves, rather than analyzing the original signal over time.

All models were trained on a standardized tabular feature vector derived from GLI-2012 Z-scores with demographics, rather than raw flow/volume waveforms. Each instance was represented as a multivariate 1-D feature vector; no windowing or segmentation was applied. The DNN consumed the vector via fully connected layers.

The 1D-CNN applied a Conv1D→Pooling→Dense stack to the same 1-D vector, serving as a nonlinear baseline on tabular inputs. The end-to-end data flow was: raw files → GLI Z-score derivation → standardized tabular vector → ML/DL models.

The validation strategy employed a nested, subject-disjoint protocol. The outer loop used a GroupShuffleSplit with participant ID as the group, ensuring patient isolation for the test set for 20 iterations. Tis loop produced the final Mean ± SD metrics.

The inner loop, for hyperparameter tuning, used a 5-fold StratifiedGroupKFold on the training data. All preprocessing was encapsulated in a scikit-learn Pipeline fitted only on the training folds to prevent data leakage.

The specific architectures chosen for the DNN (e.g., 2 hidden layers with 128/64 neurons) and 1D-CNN (e.g., 16/32 filters) represent conventional, baseline designs for tabular data, not the result of an exhaustive neural architecture search. An epoch count of 100 was set as an upper limit, as the actual training duration was determined by early stopping based on the validation F1-Macro score. A batch size of 64 was also chosen as a standard value for stable training.

The detailed hyperparameter search spaces for all models are provided in Table 2.

Table 2Model architectures and hyperparameter tuning search spacesModelParameterSearch Space / Architecture DetailsLRpenalty[’l1’, ‘l2’]C[0.01, 0.1, 1, 10, 100]SVMkernel‘linear’ (C: [0.01–100], class_weight: [None, ‘balanced’])‘rbf’ (C: [0.1–20], gamma: [‘scale’-0.0005], class_weight: [None, ‘balanced’])k-NNn_neighbors[3, 5, 7, 11]weights[‘uniform’, ‘distance’]p (distance)[1 (Manhattan), 2 (Euclidean)]RFn_estimators[100, 200]max_depth[3, 5, 10]min_samples_split[5, 10, 20]min_samples_leaf[5, 10]max_features[‘sqrt’, ‘log2’]XGBoostOptimizationRandomizedSearchCV (n_iter = 24)n_estimatorsrandint: 600–1501learning_rateuniform: 0.02–0.12max_depthrandint: 4–9(Others)(subsample, min_child_weight, reg_alpha, reg_lambda)DNNArchitectureHidden 1: Linear(128) -> BatchNorm1d -> ReLU -> Dropout(p = 0.3)Hidden 2: Linear(64) -> BatchNorm1d -> ReLU -> Dropout(p = 0.3)OptimizerAdam, Class-Weighted Loss, epochs:100TuningLR Search: [1e-3, 3e-4], Early Stopping (Patience = 10, Monitor: val_f1_macro)1D-CNNArchitectureConv 1: Conv1d(16 filters, k = 3) -> BatchNorm1d -> ReLU -> Dropout(p = 0.25)Conv 2: Conv1d(32 filters, k = 3) -> BatchNorm1d -> ReLU -> Dropout(p = 0.25)AdaptiveAvgPool1d -> Final Linear LayerOptimizerAdam, Class-Weighted Loss, epochs:100TuningLR Search: [1e-3, 5e-4], Early Stopping (Patience = 8, Monitor: val_f1_macro)

Various evaluation metrics were used to accurately analyze the performance of models. These metrics helped to evaluate the sensitivity, specificity, accuracy, and overall success performance. The performance of the models was also analyzed with the ROC-AUC curve for a more reliable analysis of the optimum threshold selection and separation between classes.

In addition, the model decision mechanisms were explained with Shapley Additive Explanations (SHAP) analysis and which variables were more effective in predictions were determined. The performances of all models were measured using the following metrics [81, 82].

• Accuracy: Shows how accurate all predictions of the model are. However, it can be misleading in unbalanced data sets.5\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\:Accuracy\:=\frac{TP+TN}{TP\:+\:TN\:+\:FP\:+\:FN}$$\end{document}

• Sensitivity – Recall: Measures how well we detect true positives, i.e. individuals with the disease. It is a critical metric, especially in disease diagnosis. It is ideal for situations where false negatives are important.

High sensitivity indicates that the model is less likely to classify patients as false negatives.6\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\:Sensitivity=\frac{TP}{TP+FN}$$\end{document}

• Specificity: Measures how accurately true negatives are detected. It is important to prevent healthy individuals from being labelled as false positives.7\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\:Specificity=\frac{TN}{TN+FP}$$\end{document}

• F1-Score: Balances Recall and Precision. It is the best performance measure for unbalanced data sets. It is used to minimize both false positives and false negatives.8\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\:F1=\frac{2\times\:Precision\times\:Recall}{Precision+Recall}$$\end{document}

• Receiver Operating Characteristic - Area Under Curve (ROC-AUC): The ROC curve shows the sensitivity and specificity of the model at different threshold values. AUC score determines the classification power of the model. The closer it is to 1.0, the better the model.

This study involved standard four and extended five classifications. These binary metrics required an averaging strategy. The reported accuracy metric is overall accuracy.

A weighted average was used for precision, recall and the F1-score. This method calculates the metrics for each class and finds their averages weighted by the actual number of samples for each class which accounts for class imbalance. A macro average was used for the F1 macro score.

This method calculates the F1 score independently for each class. Then it takes the unweighted average. Thus, it assigns equal weight to all classes, regardless of imbalance.

Finally, ROC-AUC score was calculated using the One-vs-Rest (OvR) approach. This calculation takes the macro average of all classes.

Results

Disease classification was performed using FEV₁ Z-score, FVC Z-score, and FEV₁/FVC Z-score by GLI-2012 reference values. The classification criteria were as follows: Z < -1.64 was considered Abnormal (Disease Suspected), while Z < -2 indicated obstructive or restrictive disease. Obstructive disease was detected in 49 subjects, while restrictive disease was diagnosed in 241 subjects.

Additionally, 95 subjects were categorized as abnormal, while 829 subjects were classified as normal. Additional spirometry parameters such as FEF25 − 75 Z-score, RV Z-score, and TLC Z-score were included to increase the classification accuracy. Specifically, TLC Z < -2.0 was included in the restrictive disease classification, and FEF25 − 75 Z < -1.64 was used to define small airway disease (early) as justified based on current ATS/ERS guidelines [43, 45].

Twenty-three individuals were reclassified to the previously undefined small early disease. The restrictive disease category significantly increased, indicating the importance of including lung volume parameters. Figure 5 shows the disease classification distributions for both conditions.

Disease classification for both conditions is given in Table 3.

Fig. 5Disease classification distributions

Table 3Disease distribution determined by normal and additional parametersDisease classificationStandardExtendedNormal974829Abnormal (Suspicious)16595Restrictive49241Obstructive4949Small Airway Disease (Early)---23

To validate the disease classification criteria, the distribution Z-scores of FEV₁, FVC, and FEV₁/FVC were analyzed. Figure 6 shows the histograms of Z-scores with reference threshold values ​​plotted. The number of people with FEV₁ value Z < -1.64 is 181.

For the same threshold value, FVC was 110 people, and FEV₁/FVC was 125 people. For another threshold value, Z < -2.0, FEV₁ was determined as 119, FVC was defined as 55, and FEV₁/FVC was determined as 86 people.

Fig. 6Z-scores histogram

When additional pulmonary parameters were examined, significant differences were observed in some measurements. FEF25 − 75 Z-score ​​was determined in 67 people for the Z<-1.64. And it is determined as 31 for Z<-2.0.

This situation may be a sign of early airway diseases, as it shows that the flow rate in the small airways is reduced. No significant result was observed for the PEFR value. RV Z-score value was determined in 10 people for Z<-1.64.

It was determined as only 1 person for Z<-2.0. In the TLC Z-score analysis, the number of people detected was relatively high. Accordingly, this value was determined as low in 349 people for the Z<-1.64 threshold and in 255 people for the Z<-2.0 threshold.

The Z-score distributions obtained from the additional pulmonary parameters analysis are shown in Fig. 7.

Fig. 7Z-score histogram for additional pulmonary parameters

These results confirm the robustness of the classification method and the necessity of including multiple spirometry parameters. A demographic analysis was also conducted to investigate the relationship between disease classification and factors such as age, gender, and ethnicity. The mean age of individuals classified as restrictive and obstructive disease was higher compared to the normal group.

The prevalence of restrictive and obstructive diseases was higher in males, while cases of Abnormal (Suspicious) and Small Airway Disease (Early) were slightly more common in females. The prevalence of restrictive disease was significantly higher in African Americans and Asians, while obstructive disease was distributed across multiple ethnic groups. These demographic trends are shown in Fig.

8, which shows the distribution of disease classifications across different demographic variables. The result highlights the importance of considering demographic factors when interpreting spirometry-based disease classification.

Fig. 8Demographic distribution of patients by disease classification

Prior to modeling, categorical variables were numerically coded using one-hot encoding. As all features were standardized via GLI-2012 Z-scores, no additional feature scaling was applied. A critical component of the valuation was the prevention of patient-wise data leakage.

The dataset contains multiple observations (N = 1237) from a limited number of participants (N = 129). Therefore, a simple random split of observations would lead to artificially inflated performance metrics. To prevent this, a robust subject-disjoint validation protocol was implemented.

The dataset was repeatedly partitioned (N = 20 – Iterations) using a GroupShuffleSplit, with the participant ID (Subject_ID) as the grouping variable. This method guarantees that all observations from a single participant are confined exclusively to either the 80% training set or the 20% test set in each iteration.

Furthermore, hyperparameter tuning was conducted using a nested, group-aware cross-validation within each training set. This inner loop utilized a 5-fold StratifiedGroupKFold (within GridSearchCV or RandomizedSearchCV). This ensures that participant data is not split across tuning folds.

Finally, all preprocessing steps such as imputation, were embedded within a sklearn.pipeline.Pipeline. This ensures that preprocessing parameters were fit only on the training data for each fold, preventing any data leakage from the test or validation sets. LR, SVM, k-NN, RF, XGB, DNN, and 1D-CNN models were used to evaluate the effectiveness of different algorithms in classifying pulmonary diseases based on spirometry data.

The models were tested with standard GLI-2012 parameters and an extended feature set including additional pulmonary function parameters (FEF25 − 75, TLC, and RV Z-scores). The performance of the models was measured using accuracy, precision, recall, F1-score, F1-macro and ROC-AUC curves. As a result of the performed analyses, the performance metrics of the algorithms are summarized in Table 4.

Table 4Comparative performance metrics of learning modelsModelConventional SpirometryExtended Pulmonary FunctionAccuracyPrecisionRecallF1F1 MacroAccuracyPrecisionRecallF1F1 MacroLR82.48 ± 4.5185.34 ± 5.0682.48 ± 4.5183.23 ± 4.7269.06 ± 11.8281.62 ± 4.9884.84 ± 5.7481.62 ± 4.9882.15 ± 5.3162.32 ± 8.70SVM89.13 ± 4.5790.02 ± 4.9789.13 ± 4.5788.88 ± 5.1276.22 ± 10.8387.70 ± 4.1088.70 ± 4.2387.70 ± 4.1087.65 ± 4.1470.59 ± 9.69RF97.23 ± 2.0497.48 ± 1.7097.23 ± 2.0497.25 ± 2.0094.43 ± 4.6395.01 ± 2.6595.68 ± 2.7395.01 ± 2.6594.88 ± 2.7586.84 ± 6.99k-NN85.46 ± 4.6684.58 ± 6.4785.46 ± 4.6683.81 ± 5.9263.38 ± 12.2081.31 ± 4.6380.26 ± 5.9181.31 ± 4.6379.21 ± 5.5151.06 ± 7.61XGB99.24 ± 0.5999.28 ± 0.5799.24 ± 0.5999.23 ± 0.6098.28 ± 1.7197.00 ± 1.7597.25 ± 1.6597.00 ± 1.7596.83 ± 1.8792.03 ± 6.34DNN81.61 ± 5.8385.75 ± 4.9981.61 ± 5.8382.68 ± 5.5664.25 ± 10.5779.60 ± 6.7885.62 ± 4.6879.60 ± 6.7881.36 ± 5.5161.26 ± 12.691D-CNN77.57 ± 5.5583.61 ± 5.7377.57 ± 5.5579.27 ± 5.3559.24 ± 10.0473.38 ± 8.3282.45 ± 6.6073.38 ± 8.3275.83 ± 7.6351.44 ± 10.83

A clear hierarchy emerged from the results. The tree-based models XGBoost and RF, outperformed all other classical ML and DL approaches across both datasets. On the conventional 4-class set, the XGBoost model achieved the highest performance (Accuracy: 99.24 ± 0.59%, F1-Macro: 98.28 ± 1.71), closely followed by the RF model (Accuracy: 97.23 ± 2.04%, F1-Macro: 94.43 ± 4.63).

In contrast, the DL models showed substantially lower performance and higher variance. This was particularly evident in the F1-Macro scores (DNN: 64.25 ± 10.57%, 1D-CNN: 59.24 ± 10.04), indicating difficulty in generalizing on the imbalanced minority classes under the strict subject disjoint validation.

The extended pulmonary function set introduced a more complex, 5-class problem (including small airway disease). This added challenge resulted in slightly lower, though still high, performance for the top models (e.g., XGB F1-Macro: 92.03 ± 6.34). The foundational models (LR, SVM, k-NN) performed moderately but were consistently outperformed by the ensemble methods.

These performance comparisons are visualized in Fig. 9.

Fig. 9Performance metrics results

To evaluate the discriminative power of each classification model, ROC-AUC curves were evaluated for both conventional spirometry-based models and extended pulmonary function-based models. Figure 10 presents the comparative ROC-AUC curves of seven models using conventional normal spirometry parameters, while Fig. 11 shows the ROC-AUC performance when additional pulmonary function with extended features were added.

Fig. 10Conventional normal spirometry parameters ROC-AUC curves

Fig. 11Extended spirometry parameters ROC-AUC curves

The AUC values ​​showed a significant improvement in the classification ability when the extended feature set was used, especially in distinguishing restrictive and obstructive disease groups. Among the ML models, XGBoost and Random Forest generally achieved the highest AUC values. Furthermore, DNN and 1D-CNN showed comparable or successfully discriminated performance across all disease categories.

Figure 12 shows the training/validation loss and accuracy curves for both the regular and extended parameter sets of 1D-CNN and DNN models. For the DNN model with normal parameters, training and validation accuracies increased steadily. After approximately epoch 20, training accuracy reached around 90%, while validation accuracy reached 85%.

Examining the loss graph, it was observed that the training loss dropped to levels of 0.2, while the validation loss remained around 0.4. This difference between the training and validation losses indicates that the model is starting to overfit the training data rather than generalize. Also, the 1D-CNN model with normal parameters, the accuracy curves gradually increased over time.

Curves stabilized at approximately 80% for both training and validation. The validation loss was slightly lower than the training loss. It indicates that the model did not overfit to the training set due to the regularization effect.

However, it also reveals that the learning is not as robust as for the DNN. The curves obtained for the extended parameters demonstrated successful performance despite the more complex feature set. The training accuracy for the DNN model reached approximately 80–90%.

Validation accuracy also reached approximately 80%. In this context, training and validation losses decreased simultaneously and converged at a low value. This demonstrates that the DNN algorithm, is capable of extracting meaningful features from the extended spirometry parameters.

In the 1D-CNN model for the extended, the validation accuracy of the training model increased rapidly. However, in subsequent epochs, both the accuracy and loss curves showed more limited improvement. The fact that the training and validation losses are close and parallel suggests that no significant overfitting has occurred.

This suggests that the 1D-CNN structure is not as successful as the DNN with the expanded parameter set.

Fig. 12Training and validation loss and accuracy curves for 1D-CNN and DNN models. (a) Results for normal parameters.

(b) Results for extended parameters

A more comprehensive analysis of class-level errors and probability calibration was performed to evaluate model performance within the class distribution. Furthermore, Fig. 13 presents the normalized confusion matrices for the best-performing XGBoost and DNN models.

Values represent the mean percentage and standard deviation (± SD) averaged over N = 20 iterations. On the conventional normal set Fig. 13a, the XGBoost model demonstrated high, consistent accuracy across all four classes, with most errors being minor.

In contrast, the DNN model, Fig. 13b showed significant confusion, particularly misclassifying abnormal (Class 0) cases over 47% of the time. This trend continued on the more complex five class extended set.

The XGBoost model, Fig. 13c demonstrated strong performance even on rare classes, correctly identifying restrictive’ (97.3%) and normal (99.6%) cases with high precision. However, the matrix reveals the difficulty of the small airway disease category, which achieved 48.8% accuracy and was most frequently confused with suspicious (27.6%) and normal (12.7%).

This difficulty and high variance (± 34.8) explain why the extended set’s F1-Macro (92.03%) was lower than the normal set’s (98.28). The DNN model, Fig. 13d showed significantly more confusion across all minority classes, particularly abnormal’ (51.6%) and small airway disease (48.3%).

Fig. 13Mean (± SD) row-normalized confusion matrices on the conventional and extended datasets

Model reliability was assessed via calibration curves, as presented in Fig. 14. The XGBoost model demonstrated excellent calibration, with its probability predictions closely matching the perfect diagonal line.

This is quantitively confirmed by its extremely low macro brier score and macro ECE, as detailed in the Fig. 14. In contrast, the DNN model exhibited poor calibration, with probabilities diverging significantly, resulting in much higher error scores.

Figure 14a and c show the XGBoost model on the conventional and extended datasets, respectively. Figure 14b and d show the DNN model on the conventional and extended datasets, respectively. The XGBoost model shows excellent calibration on both datasets, with macro brier scores of 0.0043 (conventional) and 0.0089 (extended), and macro ECEs scores of 0.0135 (conventional) and 0.0173 (extended).

The DNN model, on the other hand, shows poor calibration with macro brier scores of 0.0698 (conventional) and 0.0630 (extended), and macro ECEs scores of 0.0890 (conventional) and 0.0914 (extended).

Fig. 14Probability calibration curves

To provide quantitative interpretability and validate feature contributions, a growing requirement for XAI in clinical diagnostics a SHAP analysis was performed. Figure 15 presents the SHAP summary plot for the best-performing model, XGBoost, on the normal and extended dataset. The plot provides a clear global ranking of feature importance.

The analysis confirms that primary parameters, such as the FEV1/FVC Z-score and FVC Z-score, are among the most effective predictors, which aligns with clinical expectations.

The SHAP plot also provides the quantitative comparison requested. While the primary parameters were confirmed as highly important, the extended parameters were found to be very important to the model’s success. It reveals that key extended parameters, most notably the TLC Z-score, rank as highly influential predictors.

These extended features often contribute more to the model’s output than some primary parameters. This finding confirms that the inclusion of lung volume (TLC, RV) and small airway function (FEF25 − 75 Z-score) parameters was essential for achieving the model’s high accuracy and provides a strong justification for the extended dataset.

Fig. 15XGBoost SHAP analysis

Conclusion

This study provided a comprehensive benchmark for classifying lung diseases by applying a subject-independent validation protocol to a comprehensive GLI-2012 standardized feature set. The results showed that tree-based ensemble models, specifically XGBoost and RF, achieved the highest and most reliable performance. The results of XGBoost and RF outperformed those of other ML and DL approaches on this specific tabular data task.

The introduction of a more complex 5-class extended lung function scenario highlighted the trade-off between task difficulty and model performance, enabling a more detailed clinical classification. This demonstrates the importance of evaluating multiple spirometry parameters rather than a single criterion in the diagnostic process.

This poor performance does not indicate a flaw in the DL architectures themselves. Rather, it supports the common hypothesis that DL models are data-hungry. The dataset used in this study was likely insufficient for these models to train on a large number of parameters and effectively learn generalizable patterns.

DL models are assumed to be prone to overfitting on training data despite optimization efforts (e.g., dropout, early stopping). Tree-based models have proven to be more robust and better suited for this particular classification task.

These findings demonstrate XGBoost’s robust, leakage-free performance (F1-Macro: 98.28% on the 4-class set), providing a strong benchmark for this dataset. This performance aligns with other studies that have found tree-based models to be effective in lung diagnosis [24, 37]. However, many previous studies focus on simpler binary classifications (e.g., COPD vs.

Healthy) or do not explicitly specify protocols to prevent data leakage on a per-patient basis, which can lead to overestimated results. The high performance achieved here, using rigorous subject-disjoint validation on a complex multi-class problem, provides a reliable and reproducible benchmark for future comparisons.

ML studies using spirometry data have reported similar patterns. Spathis and Vlamos [83] showed that an RF algorithm, when trained with standard spirometric indices, smoking status, and demographic information, could distinguish asthma and COPD with high diagnostic sensitivity. Badnjevic et al. [84] developed an expert diagnosis system to automatically identify asthma and COPD in clinical practice.

Giri et al. [25] emphasized that tree-based ensembles and gradient boosting methods are generally among the most competitive algorithms when evaluated with appropriate validation strategies. These studies also reported that these models often achieved the highest values ​​for metrics such as AUC and F1. In this context, the leakage free XGBoost model presented in our study provides an additional reference point that strengthens the existing evidence by solving a more difficult spirometry problem with 4 and 5 classes under strict subject disjoint evaluation with high macro-F1 values.

It is important to point out an important limitation of this study. The ground-truth labels were derived from established GLI-2012 Z-score thresholds based on ATS/ERS guidelines [45]. These are not from an independent gold standard clinical diagnosis.

While these Z-scores represent the clinical standard for spirometry interpretation, validation against expert clinical diagnoses remains a critical step for future work. Furthermore, this study did not include a Decision Curve Analysis (DCA) to formally quantify the ‘net benefit’ of the ML models over the existing GLI Z-score rules. Such an analysis remains a critical step for future studies aiming at clinical implementation.

This study focused on establishing a benchmark across foundational (e.g., LR, SVM), advanced ensemble (XGB, RF), and foundational DL (DNN, CNN) models. While XGBoost demonstrated state-of-the-art (SOTA) performance for this task, future work should also investigate other modern gradient boosting methods, such as LightGBM and CatBoost, which may offer comparable performance.

Furthermore, as noted in the discussion, the DL models were likely limited by the available dataset size. As larger, more diversified datasets become available, future studies should explore more complex DL architectures. These include Transformer-based models or advanced CNNs (e.g., with residual blocks), which were outside the scope of this benchmark but may be better suited for modeling the raw time-series signal directly or for use with transfer learning techniques.

Future studies should also explore raw waveform transformer-based models. Transformer or hybrid CNN transformer models could be trained directly on inspiratory/expiratory flow-volume and volume-time curves. This could be used to investigate whether they offer additional advantages in distinguishing early obstructive and restrictive patterns, in addition to GLI derived tabular features.

In conclusion, this study demonstrates the effectiveness of AI assisted spirometry analysis in the early and accurate diagnosis of pulmonary diseases. The findings may contribute to the development of AI based clinical decision support systems. For example, such a validated model could be integrated into existing Electronic Medical Record (EMR) systems.

It can automatically screen spirometry results and flag high risk patients that might otherwise be missed, providing specialists with earlier and more reliable diagnostic decisions. From clinical perspective, ML models are not fully autonomous diagnostic systems. However, they can be considered a triage and prioritization tool supporting the physician.

When integrated with an electronic medical record system or lung function laboratory software, they can scan all incoming tests in the background. This allows for automatic flagging of high-risk patterns. They can also add structured risk scores or alerts to the spirometry report for the physician, ensuring consistent and operator independent interpretation across centers.

This approach can reduce the risk of oversight or delayed recognition of obstructive and restrictive diseases. It can also provide remote assessment.

Related articles

PubMed

Small Airway‐Predominant Asthma Revealed During Oscillometry Mannitol Challenge Despite Normal Spirometry.

ABSTRACT Objective confirmation of asthma commonly relies on spirometry, which may not capture distal airway dysfunction. A 58‐year‐old woman with episodic exertional dyspnoea and chest tightness had normal baseline spirometry, including forced expiratory volume in 1 s (FEV1), FEV1/forced vital capacity and forced expiratory flow at 25%–75% of vital capacity. Mannitol challenge was negative by the conventional FEV1 criterion, with no clear obstructive change in the flow‐volume curves. Functiona...

PubMed

The CALLY index, a novel composite biomarker, is inversely associated with preserved ratio impaired spirometry (PRISm): A nationally representative cross-sectional study.

Preserved ratio impaired spirometry (PRISm) is an intermediate pulmonary phenotype with heightened cardiometabolic risk. Effective tools for its identification are lacking. However, its relationship with systemic inflammatory-nutritional balance is underexplored. The CALLY index integrates C-reactive protein, albumin, and lymphocyte count. This composite biomarker reflects inflammatory-nutritional homeostasis. This study aimed to investigate the association between the ln(CALLY) index and PRISm...