---
title: "Machine learning prediction of pain intensity in low back pain: Random Forest vs XGBoost with lumb"
id: "plos-one-1-prediction-of-factors-contributing-to-pain-intensity-among-low-back-pain"
canonical_url: "https://medichelpline.com/clinical-feed/plos-one-1-prediction-of-factors-contributing-to-pain-intensity-among-low-back-pain"
content_type: "clinical_feed_article"
specialty: "Radiology"
source_name: "PLOS ONE (Medicine)"
source_url: "https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0354370"
published_at: "2026-07-21T14:00:00.000Z"
evidence_level: "Journal Feed"
license: "CC-BY-NC-4.0 / Informational Use"
---
# Machine learning prediction of pain intensity in low back pain: Random Forest vs XGBoost with lumb
## Provenance & Clinical Metadata
- **Canonical URL:** https://medichelpline.com/clinical-feed/plos-one-1-prediction-of-factors-contributing-to-pain-intensity-among-low-back-pain
- **Specialty:** [Radiology](https://medichelpline.com/clinical-feed/radiology.md)
- **Primary Source:** PLOS ONE (Medicine)
- **Source URL:** [Original Journal Publication](https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0354370)
- **Published At:** 2026-07-21T14:00:00.000Z
- **Evidence Rating:** Journal Feed
## Executive GIST (TL;DR)
- This cross-sectional study evaluated predictors of **pain intensity** (NRS 7–8 vs 9–10) in adults with low back pain (LBP) using two machine learning models: **Random Forest (RF)** and **XGBoost**. Data came from 61 patients referred for lumbar MRI at King Fahad Specialist Hospital, Tabuk, Saudi Arabia. - Predictors included demographics (age, sex, BMI), MRI features (disc level, number of affected levels, pathology type), and lifestyle factors (exercise time, sitting hours). Pain was dichotomized into strong (NRS 7–8) and very strong (NRS 9–10). - MRI acquisition used a Siemens Espree 1.5 T scanner; two consultant radiologists independently reviewed scans with substantial to almost-perfect inter-rater agreement (κ = 0.748 for level; κ = 0.839 for pathology type). - The final analytic sample was 61 after screening 127 and excluding incomplete data. The authors acknowledge this is below typical ML sample-size recommendations (n ≥ 200) and performed a post-hoc learning-curve analysis to assess stability. - Models were trained with a 70/30 train-test split, 5-fold cross-validation, fixed seed (42), and tuned hyperparameters (RF: 500 trees; XGBoost: 100 rounds, depth 5, eta 0.1, subsample 0.7, colsample 0.7, gamma). - RF performance on test set: accuracy = 0.579 (95% CI 0.334–0.800), AUC = 0.607 (0.340–0.875), specificity = 0.917, sensitivity = 0.000. Top RF predictors by importance included number of affected disc levels (MDG = 0.62), L4–L5 disc location (MDA = 0.48), age (0.31), and exercise time (0.28). - XGBoost achieved 66.67% accuracy but low sensitivity (0.33); class imbalance (72.1% very strong pain) likely affected sensitivity and convergence. XGBoost provided SHAP-based feature-level explanations complementary to RF. - Authors conclude RF showed limited clinical utility in current form; recommend larger multi-center samples (n ≥ 200), addressing class imbalance, and further validation before clinical translation. Data are not publicly available due to institutional restrictions. - Ethical approvals were obtained from the University of Tabuk (UT-739-453-2025). No specific funding; no competing interests declared.
## Clinical Analysis & Structured Key Points
SKIP TO MAIN CONTENT Advertisement plos.org Create account Sign in About Browse Publish advanced search 0 Save 0 Citation 18 View 0 Share OPEN ACCESS PEER-REVIEWED RESEARCH ARTICLE Prediction of factors contributing to Pain Intensity among low back pain patients: A comparative machine learning frameworks (Random Forest versus XGBoost) Maaidah M. Algamdi , Ali H. Alghamdi Published: July 21, 2026 https://doi.org/10.1371/journal.pone.0354370 Article Authors Metrics Comments Media Coverage Abstract Introduction Methods Results Discussion Conclusions Supporting information Acknowledgments References Reader Comments Figures Abstract Background Predicting pain intensity in patients with low back pain (LBP) remains a complex task due to the biopsychosocial nature of pain. Pain intensity is shaped by multifaceted interactions among demographic, lifestyle, and clinical factors. Aim This study aimed to predict factors contributing to pain intensity in adults with lower back pain (LBP) using Random Forest (RF) and XGBoost models. It evaluated the association between lifestyle factors and lumbar spine MRI abnormalities, classifying pain intensity into strong (NRS 7–8) and very strong (NRS 9–10) categories among patients with lumbar disc disorders. Methods Cross-sectional study of 61 LBP patients (Numerical Rating Scale ≥ 7) at King Fahad Specialist Hospital, Saudi Arabia. Predictors included demographics (age, sex, body mass index), MRI findings (disc location, number of affected levels, pathology type), and lifestyle factors (exercise, sitting time). Random Forest (500 trees, 70/30 train-test split, 5-fold cross-validation) and XGBoost were compared. Results RF achieved accuracy = 0.579 (95% CI: 0.334–0.800), AUC = 0.607 (0.340–0.875), specificity = 0.917, and sensitivity = 0.000. The strongest predictors were number of affected disc levels (MDG = 0.62), L4–L5 disc location (MDA = 0.48), age (0.31), and exercise time (0.28). XGBoost achieved 66.67% accuracy but sensitivity of only 0.33, likely due to class imbalance (72.1% very strong pain). RF outperformed XGBoost in overall stability; XGBoost provided complementary feature-level insights via SHAP. These findings highlight the potential of machine learning as a decision-support tool for identifying pain-related risk factors in LBP. Implications RF demonstrated limited predictive utility in its current form, insufficient for clinical application. Future research should involve multi-center designs with larger sample sizes (n ≥ 200) and address class imbalance prior to considering clinical translation. Perspective This study demonstrates how integrating lumbar MRI findings with machine learning improves pain intensity prediction in low back pain, supporting more objective risk stratification and informed clinical decision-making. Figures Citation: Algamdi MM, Alghamdi AH (2026) Prediction of factors contributing to Pain Intensity among low back pain patients: A comparative machine learning frameworks (Random Forest versus XGBoost). PLoS One 21(7): e0354370. https://doi.org/10.1371/journal.pone.0354370 Editor: Ravi Shankar Reddy, King Khalid University, SAUDI ARABIA Received: February 7, 2026; Accepted: July 7, 2026; Published: July 21, 2026 Copyright: © 2026 Algamdi, Alghamdi. This is an open access article distributed under the terms of the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited. Data Availability: The data underlying this study consist of patient health information collected at King Fahad Specialist Hospital, Tabuk, Saudi Arabia. The study received ethical approval from the Local Research Ethics Committee (LREC) at the University of Tabuk (Approval No. UT-739-453-2025, dated 19 October 2025), in accordance with the National Committee of Bioethics (NCBE) regulations. Data were obtained under a formal institutional Data Sharing Agreement (RSA-03) with Tabuk Health Cluster, which prohibits public sharing of the data due to patient confidentiality requirements and national health information regulations in the Kingdom of Saudi Arabia. In accordance with the agreement, the data is being securely destroyed within the stipulated institutional timeline. Researchers interested in accessing similar data may contact the LREC at the University of Tabuk (rec@ut.edu.sa) or the Executive Administration of Academic and Training Affairs, Tabuk Health Cluster (Cctabuk@moh.gov.sa). Access is subject to institutional review and the signing of a formal data sharing agreement. Funding: The author(s) received no specific funding for this work. Competing interests: The authors have declared that no competing interests exist. Introduction Back pain is a disabling condition that affects a large percentage of the world’s population, posing serious risks to people’s health and placing heavy financial strain on society [1,2]. Lower back pain (LBP) is the leading cause of disability worldwide and is responsible for more years of life with disability than any other health condition [3]. The mean global prevalence of LBP ranges from 8% to 31% with variations in age, sex, and region [4]. It affects nearly half of the world’s population, with 39–45% experiencing chronic or recurrent pain that often necessitates medical intervention [5]. Approximately 60–70% of adults experience back pain at least once in their lifetime, resulting in significant healthcare costs and productivity losses [3,6]. In Saudi Arabia, the prevalence of LBP ranges from 63.8% to 89% [7]. In a sample from King Abdulaziz University Hospital, up to 85.5% of nurses reported experiencing LBP at some point in their lifetime, with a notably higher prevalence among those working in surgical wards [8]. Another study conducted in Najran, found that 88.2% of participants experienced mild-to-moderate localized back pain influenced by workplace environmental factors [9]. In a sample of Saudi adolescents aged 13–18 years, approximately 19% had LBP, with 57.8% reporting symptoms in the past year [10]. LBP prevalence among university students ranges from 60% to 80% [11]. In medical students, it ranged between 80% and 94%, indicating unique occupational and academic stressors [12,13]. Several physical and lifestyle-related risk factors play crucial roles in the development of LBP. Weak core musculature, poor posture, prolonged sitting, and lack of exercise contribute to spinal instability and muscle strain [14,15]. Psychosocial stressors, including chronic stress, sleep deprivation, and emotional distress further intensify pain perception and hinder recovery [16]. Chronic musculoskeletal pain has been associated with higher rates of depression and anxiety and diminished quality of life [13,17]. In severe cases, it may lead to maladaptive coping mechanisms such as excessive analgesic use or opioid dependence [18]. Recent studies have emphasized the importance of lumbar magnetic resonance imaging (MRI) for evaluating disc degeneration and detecting pain-associated spinal anomalies. Deep learning and AI-assisted MRI models have achieved diagnostic accuracies comparable to those of expert radiologists in detecting and grading lumbar disc degeneration [19,20]. Automated MRI segmentation and quantitative analyses have shown high reliability and reproducibility, reducing observer variability while maintaining diagnostic precision [21]. Additional research has shown that MRI-based radiomics can reveal nuanced tissue alterations associated with pain intensity and functional disabilities [22]. Collectively, these findings highlight MRI’s dual role of MRI as both a diagnostic cornerstone and an analytical foundation for integrating imaging biomarkers into Machine Learning (ML) frameworks for low back pain research [23]. RF also handles non-linear relationships and correlated predictors, both common in MRI data, without requiring variable transformation [24,25]. XGBoost was included for comparison because it supports SHAP (SHapley Additive exPlanations) values, which provide interpretable, patient-level explanations of model output; its regularization parameters further reduce overfitting. However, XGBoost generally requires larger samples (n ≥ 200) for stable convergence, a constraint acknowledged throughout this study [26]. Together, the two models offer a balance between predictive stability and interpretability. To our knowledge, no prior study has applied machine learning to predict pain intensity in a Saudi Arabian LBP population, combined MRI structural variables with lifestyle factors (exercise time, sitting hours) and clinical demographics in a single ML framework, or directly compared RF and XGBoost for dichotomized pain intensity (strong vs. very strong). This study addresses these gaps by providing the first Saudi-specific ML analysis of LBP pain predictors, with comparative model evaluation and SHAP-based interpretability. Methods Study design This study employed a cross-sectional descriptive design to evaluate the association between lifestyle factors and lumbar spine MRI abnormalities in adults with LBP using two ML models, RF and XGBoost. A cross-sectional approach was chosen [27], as it allows the simultaneous assessment of exposures (such as lifestyle habits) and outcomes (including MRI abnormalities and pain intensity) without requiring longitudinal follow-up. Study setting and duration This study was conducted at the King Fahad Specialist Hospital, Tabuk, Saudi Arabia, where clinical MRI facilities and diagnostic imaging records are readily available. The data were collected between November 2025 and January 2026. Study population The target population included adult patients with LBP referred for lumbar MRI. Participants were recruited from the hospital’s radiology and outpatient departments. Inclusion criteria Adults aged 18 years presenting with LBP severe enough to warrant lumbar spine MRI. Willing and able to provide informed consent and capable of completing the study questionnaire. Exclusion criteria History of spinal surgery (including fusion and laminectomy). Chronic or neurological disorders influence spinal health (such as ankylosing spondylitis and multiple sclerosis). Contraindications to MRI (such as metal implants, pacemakers, and claustrophobia). Incomplete imaging or clinical data. Sampling technique and sample size A consecutive non-probability purposive sampling approach was employed [28], including all eligible participants who met the inclusion criteria during the recruitment period. The estimated sample size was 100 participants, which provided sufficient statistical power for the correlation analysis between MRI findings and lifestyle indicators. A total of 127 patients with LBP were initially screened between October and January 2026. After cleaning and excluding missing data, the final sample size was 61 participants. While n = 61 is below the conventional machine learning threshold (typically n ≥ 200 for stable model convergence), a post-hoc learning curve analysis was performed to assess stability, variance, and to improve generalization, consistent with the strengths of the Random Forest (RF) model. Ethical considerations Ethical approval was obtained from the Institutional Review Board (IRB) of the University of Tabuk (NO: UT-739-453-2025) and facilitated by the IRB of King Fahad Specialist Hospital. Each participant was briefed about the purpose of the study and provided written informed consent. Confidentiality was maintained by assigning unique codes to each participant, and all data were stored securely in password-protected systems accessible only to authorized personnel. Data collection procedures Data collection was conducted in two main stages: (1) completion of a structured questionnaire and (2) MRI and radiological evaluation (Fig 1). The involvement of the participants in this cross-sectional study was intended to be a singular, integrated encounter, as demonstrated below. Download: PNG larger image TIFF original image Fig 1. Participant flowchart. Of 127 adults initially screened for low back pain (LBP), 61 met the eligibility criteria (Numerical Rating Scale [NRS] ≥ 7, lumbar MRI-confirmed disc pathology, no prior spinal surgery, complete data) and were enrolled. Data collection comprised two sequential stages: a structured questionnaire (sociodemographic, lifestyle, and clinical items) followed by lumbar spine MRI performed on a 1.5 T Siemens Espree system by a qualified radiological technologist. MRI = magnetic resonance imaging; NRS = Numerical Rating Scale. https://doi.org/10.1371/journal.pone.0354370.g001 Data collection details frequency and duration. Data were gathered at a single point in time (cross-sectional). The overall time a person must spend is approximately 45–60 min, which includes giving their consent, filling out the questionnaire, and obtaining an MRI scan. Personnel: Data were collected in two key roles: 1) Approaching patients, obtaining informed consent, and presenting the questionnaire will be the responsibility of a qualified individual, such as a research coordinator with a bachelor’s or master’s degree in a health science discipline. 2) A qualified Radiology Technologist performed the lumbar spine MRI in accordance with established clinical standards. They are not members of the research team but fulfill their standard clinical responsibilities. Methods and Instruments. Participants completed a paper-based questionnaire about demographics, clinical pain history, and lifestyle factors (diet and physical activity). The participants completed a pretested structured questionnaire prior to MRI scanning. The questionnaire included the following sections: (A) Demographics: Age, gender, and marital status. Anthropometric parameters: height and weight. Lifestyle factors: Frequency and duration of exercise, sitting time per day, and number of daily meals. B) Clinical symptoms: pain intensity, numbness, movement difficulty, and prior injury. Pain intensity was measured using the 11-point Numerical Rating Scale (NRS; 0 = no pain, 10 = worst imaginable pain). Scores were dichotomized into strong pain (NRS 7–8) and very strong pain (NRS 9–10); patients with NRS < 7 were excluded to focus the analysis on clinically meaningful severe pain. Of 127 patients initially screened, 61 met the inclusion criteria and were retained for analysis. Inter-rater reliability for MRI readings was assessed using Cohen’s kappa between two consultant radiologists. Agreement was substantial for disc level classification (κ = 0.748, 86.9% agreement) and almost perfect for pathology type (κ = 0.839, 90.2% agreement), confirming adequate reliability of the imaging data. Internal consistency of the questionnaire was examined using Cronbach’s alpha. The sociodemographic subscale yielded α = 0.623 and the clinical subscale α = 0.549. Both values are considered acceptable for exploratory studies with samples below 100, where alpha estimates carry wider standard errors and heterogeneous item content is expected [29,30]. Model tuning and preprocessing Hyperparameters for both models were selected via grid search with 5-fold cross-validation on the training set. All analyses used a fixed random seed (set.seed = 42) to ensure reproducibility. Categorical variables (sex, marital status, employment, exercise type, disc pathology type) were one-hot encoded prior to model fitting; ordinal variables (age group, sitting time) were treated as numeric; continuous variables (height, weight, exercise duration) were not scaled, as tree-based models are invariant to monotonic transformations. A post-hoc variance inflation factor (VIF) assessment confirmed no problematic multicollinearity among predictors (all VIF < 3). For RF, the final configuration used 500 trees (ntree), three features per split (mtry = √p), and a minimum node size of 1. For XGBoost, the best-performing settings were 100 boosting rounds, maximum tree depth of 5, learning rate of 0.1, subsample of 0.7, column subsampling of 0.7, and gamma of 0. Full parameter grids and selection rationale are presented in Table 4. MRI assessment All subjects underwent lumbar spine MRI using a Siemens Espree 1.5 Tesla superconducting system (Siemens Healthineers, Erlangen, Germany) equipped with a dedicated spine array coil. Imaging was standardized using sagittal T1-weighted, sagittal T2-weighted, and axial T2-weighted sequences to ensure high diagnostic reliability across all cases. The slice thickness was 4 mm with an interslice gap of 0.5–1.0 mm, and the field of view (FOV) was adjusted to the patient’s body habitus to optimize spatial resolution. The matrix size was 384 × 384, providing a detailed visualization of the intervertebral discs and adjacent structures. All scans were performed using typical routine clinical parameters and standardized patient positioning to maintain reproducibility. Two consultant radiologists, independently blinded to the clinical data, reviewed the MR scans to evaluate the number, level, and morphology of the affected discs, including posterior disc bulge, protrusion, extrusion, or associated spondylosis changes. Discrepancies in interpretation were resolved by consensus. The following MRI features were recorded: type of disc pathology, posterior disc bulge, protrusion, posterolateral extrusion, and spondylosis, spinal levels affected (L1–L2, L2–L3, L3–L4, L4–L5, L5–S1), and number of affected discs. Disagreements in image interpretation were resolved by a consensus between two senior radiologists to ensure reliability. Radiological abnormalities included lumbar disc degeneration as shown on MRI, the type of degeneration (bulge, protrusion, extrusion, or spondylosis), and the location (at a specific spinal level). Statistical analyses All collected data were coded and entered into SPSS version 26.0. Data cleaning procedures included the identification of missing values, logical inconsistencies, and outlier detection. The MRI data were stored in the DICOM format to ensure compatibility for radiological review and model training. Descriptive statistics were used to summarize participant demographics, MRI findings, and pain levels (mean, standard deviation, and proportion). All statistical analyses were conducted using the R software (version 4.5.1; R Development Core Team, Vienna, Austria). The following R packages were used: psych for correlation analysis, random forest for developing the RF classification model, care for computing the model accuracy and confusion matrices, and XGBoost for constructing the Gradient Boosting Machine (GBM) model. ML such as RF and XGBoost [31], were trained to classify patients with strong and very strong pain. Statistical inference of the model factors was performed to identify the factors that significantly contributed to strong and very strong pain risk. Prior to model development, the dataset was stratified randomly divided into training (70%) and testing (30%) subsets to ensure an unbiased model evaluation. Model tuning was conducted using 5-fold cross-validation to determine the optimal hyperparameters. The model evaluation metrics included the accuracy, sensitivity, specificity, and out-of-bag (OOB) error rate. Feature importance was measured using the Mean Decrease in Accuracy (MDA) and Mean Decrease in Gini (MDG) for RF and the SHapley Additive exPlanations (SHAP) values for XGBoost to interpret the variable influence. Cross-validation ensured model generalization and minimized overfitting. Overfitting was assessed by comparing cross-validated training accuracy (0.612) with held-out test accuracy (0.579); the difference of 0.033 suggests minimal overfitting, consistent with RF’s inherent regularization via bootstrap aggregation (bagging). The dataset was verified to be complete and free of missing va
## Related Clinical Research

- [2026 Stroke Rehabilitation Guideline: Start Early and Address Physical, Cognitive, and Mental Heal](https://medichelpline.com/clinical-feed/medical-news-today-0-stroke-rehab-guidelines-emphasize-early-support-for-physical-cognitive-and.md)
- [Diet and Alzheimer’s risk: Why no single best diet fits everyone](https://medichelpline.com/clinical-feed/medical-news-today-0-is-there-a-best-diet-to-help-lower-alzheimer-s-risk.md)
- [Impact of Music-Based Therapies on Rehabilitation in Multiple Sclerosis: A Systematic Review](https://medichelpline.com/clinical-feed/bmj-open-9-potential-benefits-of-music-based-therapies-on-rehabilitation-outcomes-in.md)
- [North West London Diabetes Cohort: multiethnic EHR resource for diabetes complications research](https://medichelpline.com/clinical-feed/bmj-open-2-large-scale-multiethnic-electronic-health-record-resource-for-diabetes.md)
- [Fitspiration vs Thinspiration: Effects on Body and Functionality Appreciation in Young Chinese Wom](https://medichelpline.com/clinical-feed/plos-one-9-rethinking-fitspiration-in-social-media-experimental-insights-from-young.md)

## Navigation
- [← Back to Radiology Feed](https://medichelpline.com/clinical-feed/radiology.md)
- [← All Clinical Specialties](https://medichelpline.com/clinical-feed.md)
## Medical & Regulatory Disclaimer

> [!CAUTION]
> MedicHelpline content is structured for research, educational, and professional discovery purposes. It does not constitute individual medical advice, clinical diagnosis, or treatment recommendations.
> Always verify dosing, contraindications, and regulatory alerts against official product labeling and primary regulatory sources before clinical decision-making.