3.1. Study Design and Setting
This study was a secondary pooled, record-level, cross-sectional analysis of data from two phases of the population-based KERCADRS study conducted in Kerman, Iran. Phase 1 was conducted during 2009 - 2011, and Phase 2 during 2014 - 2016. The datasets included demographic, examination, laboratory, behavioral, and psychological questionnaire variables.
Because a validated participant-level linkage identifier was unavailable in the analytic dataset, repeated participation across the two KERCADRS phases could not be explicitly identified or accounted for. Consequently, some records may represent the same individual across phases and may have been allocated to both the development and test sets. Such overlap may violate the assumption of record independence and could yield overly narrow confidence intervals and modestly optimistic estimates of hold-out test performance. Therefore, the findings are interpreted as pooled record-level, cross-sectional screening performance rather than participant-level, longitudinal, temporally validated, or externally validated performance.
3.2. Outcome Definition
The primary outcome was a binary classification of current glycemic status: diabetes versus normal/prediabetes. Diabetes was defined as FBS ≥ 126 mg/dL or current use of antidiabetic medication, consistent with the KERCADRS definitions. Records with FBS < 100 mg/dL were classified as normal, and those with FBS 100 - < 126 mg/dL were classified as prediabetes. Normal and prediabetes were combined as the negative class for binary modeling.
The normal, prediabetes, and diabetes categories were retained for descriptive reporting only. HbA1c was not used because it was not available as a consistent analytic variable across the pooled dataset.
3.3. Predictors
To prevent target leakage, FBS and antidiabetic medication variables were used exclusively for outcome construction and were excluded from model inputs. Participant identifiers, visit codes, phase indicators, and date-related variables were also excluded.
Candidate predictors were restricted to clinically interpretable variables available across both study phases: age, sex, body mass index (BMI), waist circumference, blood pressure measures, total cholesterol, triglycerides, high-density lipoprotein (HDL) cholesterol, low-density lipoprotein (LDL) cholesterol, physical-activity level, Beck Anxiety Inventory (BAI) score, and Beck Depression Inventory-II (BDI-II) score. Derived candidate features included the triglyceride-to-HDL ratio, pulse pressure, mean arterial pressure, and BMI thresholds. Variables without a verified clinical definition in the available data dictionary were not considered.
Consistent with the revised terminology, the predictor set did not operationalize a full biopsychosocial framework. Social-determinant variables such as education, income, occupation, and social support were not available as harmonized variables in the analytic dataset and were therefore not evaluated.
3.4. Data Integration and Cleaning
Variable names were standardized, and the two phase-specific datasets were aligned according to their shared variables before record-level concatenation. Variables available in only one phase were not included as predictors to avoid missingness by design. Analytic records were retained when the binary outcome could be constructed.
Missing predictor values were imputed within the modeling pipelines using median imputation for numeric variables and most-frequent-category imputation for categorical variables. No formal assessment of the missingness mechanism was conducted; therefore, the imputation approach should not be interpreted as addressing missing-not-at-random mechanisms.
3.5. Statistical Analysis and Feature Selection
Analyses were performed in Python using scikit-learn. The analytic dataset was divided using a stratified, record-level split into a development set (80%; n = 12,671) and a hold-out record-level test set (20%; n = 3,168).
Within the development set, a fitting subset was used for feature selection and initial model fitting. Random Forest permutation importance, calculated only in the fitting data, was used to rank the 20 candidate predictors. The 12 highest-ranked predictors were retained for subsequent modeling: age, triglycerides, waist circumference, triglyceride-to-HDL ratio, LDL cholesterol, BMI, pulse pressure, total cholesterol, anxiety, depression, systolic blood pressure, and HDL cholesterol. Selection was not repeated using the test set.
3.6. Algorithm Modeling, Calibration, and Validation
Three algorithms were compared: class-weighted Logistic Regression, Random Forest, and HistGradientBoosting. For each algorithm, preprocessing and model fitting were performed using the fitting subset. The remaining calibration subset was divided into two stratified parts: one was used to fit an isotonic-regression probability calibrator, and the other was used to select a classification threshold.
Thresholds were chosen to maximize the F1 score subject to a minimum sensitivity target of 0.75. The calibrated probabilities and selected threshold were then applied unchanged to the hold-out record-level test set.
Performance was summarized using AUC, accuracy, Macro-F1, balanced accuracy, sensitivity, specificity, precision, negative predictive value (NPV), and Brier score. Uncertainty in the main classification metrics was estimated using 1,000 bootstrap resamples of the hold-out record-level test set.
HistGradientBoosting was selected as the primary model for detailed reporting because it achieved the highest hold-out test-set AUC and balanced accuracy. For this model, predictor importance was assessed using permutation importance, quantified as the mean reduction in AUC after permuting each predictor across 50 repetitions.
To assess the joint incremental contribution of psychological measures, HistGradientBoosting fitted with the full selected predictor set was compared with an otherwise identical reduced model excluding anxiety and depression. Both models were fitted, isotonic-calibrated, and thresholded separately using the same development-data procedure. Paired bootstrap resampling of the hold-out test set was used to estimate 95% confidence intervals for between-model differences in AUC, balanced accuracy, and Brier score.